Instead of letting individual objects find or create their own instances
of the objects with which they collaborate, or making them go through
a Service Locator
, we let an external agent find these objects
and then pass them in
to the individual instances instead.
This way, dependencies are "injected" into these collaborators
instead of being hard-wired into the code.
Injectors pass in information about collaborators using constructors and/or setters.
||use this markup:
(Supported languages: java, cpp, csharp, c, python.)
|a method or class name