Dear Jayakumars,
1. What is Dependency Injection in ASP.NET MVC 4? In Object Oriented Programming paradigm, objects work together in a collaboration model where there are contributors and consumers. Naturally, this communication model generates dependencies between objects and components, becoming difficult to manage when complexity increases.
You have probably heard about the Factory Pattern and the separation between the interface and the implementation using services, where the client objects are often responsible for service location.
The Dependency Injection pattern is a particular implementation of Inversion of Control. Inversion of Control (IoC) means that objects do not create other objects on which they rely to do their work. Instead, they get the objects that they need from an outside source (for example, an xml configuration file).
Dependency Injection (DI) means that this is done without the object intervention, usually by a framework component that passes constructor parameters and set properties.
The advantages of using Dependency Injection pattern and Inversion of Control are the following:
- Reduces class coupling
- Increases code reusing
- Improves code maintainability
- Improves application testing
Note: Dependency Injection is sometimes compared with Abstract Factory Design Pattern, but there is a slight difference between both approaches. DI has a Framework working behind to solve dependencies by calling the factories and the registered services.
2. Difference between Dependency Injection and 3 tier For this you can see the below links:-
http://stackoverflow.com/questions/11338297/traditional-3-tier-architecture-vs-3-tier-with-iochttp://stackoverflow.com/questions/485519/dependency-injection-in-an-n-tier-application http://stackoverflow.com/questions/13561450/ioc-in-3-tier-architectureHappy Coding,
If it helps you or directs U towards the solution,
MARK IT AS ANSWER Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator