2.3 依赖性倒置原则The Dependency Inversion Principle (DIP)1 2.3.1 依赖抽象Depending upon Abstractions. 显然这样的限制比较严峻,但是我们应该尽可能的遵守这条原则。原因很简单,具体的模块变化太多,抽象的则变化少得多。
基于48个网页-相关网页
高层不应该依赖底层模块,两者应该抽象(无法被实例话的接口,类啥的);抽象不应该依赖细节;细节应该反而依赖抽象,换句话说也就是面向接口编程。
High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions.
他们都应该依赖于抽象。
细节应该依赖于抽象。
应用推荐