Dependency Injection# Java - 爪哇娇娃
t*e
1 楼
Wikipedia 谈到 dependency injenction 的缺点:
1. Dependency injection can make code difficult to trace (read) because it
separates behavior from construction. This means developers must refer to
more files to follow how a system performs.[citation needed]
2. Dependency injection typically requires more lines of code to accomplish
the same behavior legacy code would.[citation needed]
3. Dependency injection diminishes encapsulation by requiring users of a
system to know how it works and not merely what it does.[5]
4. Dependency injection increases coupling by requiring the user of a
subsystem to provide for the needs of that subsystem.[6]
1 & 2 没有问题。3 & 4 是什么情况?怎么感觉 DI 不要求客户了解 dependency 的细
节?
On the contrary, it increases encapsulation and decreases coupling?
1. Dependency injection can make code difficult to trace (read) because it
separates behavior from construction. This means developers must refer to
more files to follow how a system performs.[citation needed]
2. Dependency injection typically requires more lines of code to accomplish
the same behavior legacy code would.[citation needed]
3. Dependency injection diminishes encapsulation by requiring users of a
system to know how it works and not merely what it does.[5]
4. Dependency injection increases coupling by requiring the user of a
subsystem to provide for the needs of that subsystem.[6]
1 & 2 没有问题。3 & 4 是什么情况?怎么感觉 DI 不要求客户了解 dependency 的细
节?
On the contrary, it increases encapsulation and decreases coupling?