Not sure what Senior Dev expect me to do
Hello, I'm moving my post to this forum so it will be more visible.
I just finished in my job simple endpoint that returns paginated result, we use clean arch with mediatr - easy. My handler looks something like (pseudo code)
... so not much logic into that,
And then Senior Dev join my Pull Request, marked whole file with comment 'I think that paginated handlers with search and sort can be made in generic way'
Tbh I havent see something like that ever, especially if that used clean arch with Mediatr. So I am now in seek and wonder how to do that and I question myself if its even good practice.. Could I use your wisdom with maybe some example from web?
13 Replies
are there other handlers in the code that return paginated results that you can compare yours to?
it's not clear if they're telling you to follow an established pattern in the code or if they're just brainstorming out loud
It is first handler that requires pagination, search and sort. Fresh app
then i wouldn't bother making it generic until there is a reason to
how could I explain it to senior dev? I'm just regular dev, he is talking from his higher position and I'm not in position to just say 'no'. What would be explanation?
do you expect the application to have many more paginated handlers in the future?
at least one
more is still in planning
If there is an expectation that more are coming, I would make it generic too
following your own pseudo code example, making it generic should be very simple:
You could then create paginated handlers for any type by
Yes, I actually want to come up with something.. thanks for that example. Are you familiar with any articles on that with more code?
Have you looked into this? https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/generics
Generic classes and methods - C#
Learn about generics. Generic types maximize code reuse, type safety, and performance, and are commonly used to create collection classes.
I know how generics work, I'd like to get some ideas behind PaginatedHanler implementations itself. Espesially that I somehow need to combine with sort and search.. hmm. But the most important thing you gave me is that it's not bad practice
I am just wondering... have you talked to your senior dev yet about this directly? Share your thoughts and maybe he can expand on his. Open that communication channel! That's most of the job anyhow.
I haven't. I will do that tomorrow and doing background for that talk
That's a good idea. It's better to clarify these things before you start your implementation.
As an example you could create a generic object (SearchCriteria) that contains fields such as pagination and sorting but it really depends on the requirements and expectations. Remember YAGNI