This is an MVC design/refactoring question.
I am using a Controller and inside I do these tasks:
- I get Price of an object from a database, for which I use a repository pattern
- Create a
LineItemobject, which I initialize with the price and other data
- I Execute the "save to database" command, for which I use a
SaveLineItemservice. It's a simple service that just saves the
Currently all 3 of the above actions happen in the Controller
I am however wondering if I will do better by moving the actions 1 and 2 into the
SaveLineItem service, thus assigning more responsibility to that service.
By doing so I will have a smaller controller, but I will also have a more bloated service. What used to be a service that just dealt with the
LineItem object, will now deal with getting the price of the object, creating the
LineItem object, and then saving it.
My question is, should I do this refactor? Is bloating the service and assigning more responsibility to it outweigh keeping the bloat inside the controller?