Tutorial by Examples

This class is called Greeter. Its responsibility is to output a greeting. It has two dependencies. It needs something that will give it the greeting to output, and then it needs a way to output that greeting. Those dependencies are both described as interfaces, IGreetingProvider and IGreetingWriter....
This builds on the previous example of the Greeter class which has two dependencies, IGreetingProvider and IGreetingWriter. The actual implementation of IGreetingProvider might retrieve a string from an API call or a database. The implementation of IGreetingWriter might display the greeting in the ...
Dependency injection means writing classes so that they do not control their dependencies - instead, their dependencies are provided to them ("injected.") This is not the same thing as using a dependency injection framework (often called a "DI container", "IoC container&quo...

Page 1 of 1