Dependency injection: Difference between revisions

Content deleted Content added
Assembly: Minor improvements
Tags: Mobile edit Mobile web edit
Types of dependency injection: Method injection is another important injection concept. Also setter injection is conceptually the same as property injection, but I was not sure how clearly explain it.
Line 80:
There are three main ways in which a client can receive injected services:<ref>{{cite web|author=Martin Fowler |url=http://www.martinfowler.com/articles/injection.html#FormsOfDependencyInjection |title=Inversion of Control Containers and the Dependency Injection pattern – Forms of Dependency Injection |publisher=Martinfowler.com |date=2004-01-23 |access-date=2014-03-22 }}</ref>
* Constructor injection, where dependencies are provided through a client's class [[Constructor (object-oriented programming)|constructor]].
* Method Injection, where dependencies are provided to a method only when required for specific functionality.
* Setter injection, where the client exposes a setter method which accepts the dependency.
* Interface injection, where the dependency's interface provides an injector method that will inject the dependency into any client passed to it.