The Dependency Injection pattern describes a solution:
Define a separate Injector object
that
creates and injects the objects
a class requires.
A class accepts the objects it requires
from an Injector object
instead of creating the objects directly.
Describing the Dependency Injection design in more detail is the
theme of the following sections.
See Applicability section for all problems
Dependency Injection can solve.
[See also MFI]
Injector object:
ServiceA -> ServiceA1,
ServiceB -> ServiceB1).
Client)
accepts the objects it requires automatically at run-time.
ServiceA,ServiceB)
and doesn't have to care about
how the objects are created.