I have been reading a lot in the past few weeks about dependency injection, inversion, techniques, IoC and so on and so on... Although I understand the principle I can't get a few stuff so far.
Lets say we have a controller that has to do a subscription for some service. What we need is the following:
- Validate request (month, year, plan)
- Add subscription to database
- Add Billing invoice to database(payment information)
- Update user to specify that he is subscribed
- Process the payment
- Display the information to the user and redirect to success page
This is a complex task and if we have to follow the Skinny Controller and Fat Model means it will be hard. Many developers also state that if you have more then 4 dependencies you have to simplify your classes and follow the one Responsibility principle. This brings a lot of questions for me.
- How do I proceed here?
- How do I isolate the controller?
- How do I make it all testable?
- How do I pass all the dependencies from the controller/classes?