2 ms·
I'm not sure whether this whole article is just an elaborate troll or if the author has never worked on anything but the greenest of greenfield applications. D
by _pmf_ 12y ago
I'm not sure whether this whole article is just an elaborate troll or if the author has never worked on anything but the greenest of greenfield applications.
DI is not a pattern.
The argument that DI breaks encapsulation does not make any sense at all; in fact, it's an argument in favor of DI, since it cleanly allows configurable behavior (the alternative requiring some way of configuring the host object to behave in a certain way using constructor arguments or setters).
Dependency injection is a direct application of coding to interfaces instead of implementations (or to abstractions). In the absence of polymorphic constructions, the only way to achieve this is to either inject the dependency or a factory for the dependency.