2 ms·
> When their back is against the wall with a deadline...just throw some more beans in there, who cares how they're wired together, it's all handled by Spring!
by kazagistar 10y ago
> When their back is against the wall with a deadline...just throw some more beans in there, who cares how they're wired together, it's all handled by Spring!
I just came across a controller in our code that had over 50 spring injected services. Our entire code base is only like 5 years old.
The problem is that this is my first job out of college... even if I know things are messed up, I don't really have an example of an application like this that is actually done right.
- qw 10y agoI prefer controllers to have only one service. A controller should do as little as possible. Its responsibility is just to pass data from the request to the service. The same should apply to repositories unless it is absolutely necessary. It should ideally just know enough to manage itself A service may reference other services if it needs to coordinate actions. We need to be careful not to make huge services that contains too much logic though I have found that this pattern makes it not only easier to structure the application, but also much easier to make mocked tests.