Since you are using ASP.NET MVC 3, you can write a custom dependency resolver . Of course, you will still design your controllers using the interfaces in your constructors to loosen the connection between the layers. And then in the custom dependency converter, to satisfy the ridiculous requirements that were imposed on you, you will have to manually say that when you have ISomeService , you return an instance of SomeServiceImpl . You know that the things that object containers and DI frameworks already do for you. Therefore, you basically have to reinvent multiple wheels. By the way, Iyende wrote about how you could create a custom IoC container in 15 lines of code , but of course, this is not the reason why you should ever do something like this.
People who impose such requirements must be brought to justice and sentenced to never have to approach the design of the application. The imposition of such a requirement illustrates some general lack of knowledge about best practices in application design. These people should be advised before they bring additional damage to the company.
So, just explain to people that when reinventing the wheels, there are 2 errors:
- you will spend a lot of time on what has already been done by someone else.
- you will make mistakes since you will not take into account all cases of edges that have been taken into account by someone who designs reusable DI frames.
At the end of the day, you will send the application later on schedule (since you would take the time to write a plumbing code), and even worse you will send an application that will contain potential errors.
Conclusion: expensive and buggy product. Your leadership must have really passed out :-)
Conclusion 2: use the existing DI structure. Management does not even notice, because they do not seem to understand the technical aspects of the application, imposing such requirements.
source share