Sometimes, when developing an application, more complex situations occur.
For example, I have a category, which is assignable to either a post or a user,
with the post and user obviously being to different entities in the db.
Let's say I want to use the post and user, populated with their assigned categories in the frontend.
And let's also say, fetching a categories desired 'return object' is a bit complex, as additional joins with other
tables need to happen, in order to populate some meta data.
One way to solve this problem, would be to have the same category fetching logic in the post and user router.
This however leads to code duplication.
Another way would be to create a service, which is responsible for fetching a category and returning the 'return object',
which is most likely wrapped in some sort of interface, so it is easier to reuse.
I'm just thinking out loud, does anyone have some recommendations, to handle more complex business logic,
without having to duplicate a lot of code? Do you recommend using a simple service pattern?