Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Service Container allows the usage of the Dependency Injection Pattern through a container for classes that another class  depend  depends on. Services are the implementation of a the dependency of another a class. The terms Services and Service Container have been adopted from the .NET Visual Designer implementation (http://msdn.microsoft.com/en-us/library/system.componentmodel.design.servicecontainer%28v=vs.110%29.aspx). In the .NET Visual Designer the design canvas, the property grid or a the name generator for new control instances are services required to implement the whole designer functionality. The service container decouples the components in the whole system from each other.

When building systems of dependent classes the service container solves the problem of accessing central (to the session or an application context, e.g. a Form) objects providing functionality to other objects.  The service container allows object instances to be registered and returns them on request from other classes. The “key” for requesting object instances is typically an interface that the requested class (the dependency) implements and thus the “role” it plays for the requestor (the dependent class).

...

As a consequence dependency injection makes unit testing much simpler. In essence the service container and the dependency injection pattern allow the injection of mockup services. Mockup services simulate the behavior of a dependency in a much simpler and thus potentially fault free way. As the result a unit test can be specialized on just testing the dependent bits of code – simplifying the location of the cause for failure failures compared to debugging a whole complex system.

...