Answer the question
In order to leave comments, you need to log in
Where to delegate functions that are part of the controller but are too large to be left there?
Good afternoon!
Let's say there is a registration method that has 200 lines of code. I used to break this into several methods (like checkUser, addUser) that were private in the controller, but this made the controller too thick. Is it worth moving this functionality into a separate unrelated component (function library), or is it worth creating a separate controller B that will respond to requests from controller A?
I would be grateful for advice, thanks.
Answer the question
In order to leave comments, you need to log in
The controller should not contain logic, except for extracting user input, processing it using services or models (in fact, there can be any layer, there are a lot of options) and a response. In your case, there are two popular approaches to solving the problem:
For SOA, you will really need a DependencyInjection Container (or ServiceLocator), which is quite difficult for beginners to master. In the MVC approach, everything is much simpler and more obvious, so I recommend trying it first, and then, when you run into thick models, move on to SOA and use the service layer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question