A better solution to resource retrieval is to apply IoC. The idea of this principle is to invert the
direction of resource retrieval. In a traditional lookup, components seek resources by making
requests to a container, and the container duly returns the resources in question.With IoC, the
container itself actively delivers resources to itsmanaged components. A component has only
to choose a way of accepting the resources. This could be described as a passive formof
lookup.
IoC is a general principle, while DI is a concrete design pattern that embodies this principle.
In the DI pattern, a container is responsible for injecting appropriate resources into each
component in some predetermined way, such as via a setter method.
The IoC principle resembles Hollywood’s infamous catchphrase, “Don’t call us, we’ll call
you,” so it is sometimes called the “Hollywood principle.”Moreover, as DI is themost typical
implementation of IoC, the terms IoC and DI are often used interchangeably.
No comments:
Post a Comment