From the Spring Framework Reference Documentation: "Code is cleaner with the DI principle and decoupling is more effective when objects are
provided with their dependencies. The object does not look up its dependencies, and does
not know the location or class of the dependencies."
This is so wrong. While code may be cleaner with DI it is also harder to understand (instances appear magically at run time) and much harder to debug (one can't easily trace objects back to their creation). Further more each object has to know its dependencies - otherwise they would not compile.
And the half-sentence about decoupling seems only to be there to increase the buzzword score, as it makes no sense at all (objects do always have to be provided with their dependencies and that does not change coupling in any way).
Keine Kommentare:
Kommentar veröffentlichen