设计模式学习之——六大设计原则之三:依赖倒置原则

来源:互联网 发布:python擅长做什么 编辑:程序博客网 时间:2024/05/01 22:17
定义: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.
定义的含义:
    a. 高层模块不应依赖低层模块,两者应都依赖其抽象
    b. 抽象不应依赖细节
    c. 细节应依赖抽象
    (细节即实现类,抽象即接口或抽象类)
在Java中的表现:
    a. 模块间的依赖通过抽象发生,实现类之间不发生直接的依赖关系,其依赖关系是通过接口或抽象类产生的
    b. 接口或抽象类不依赖于实现类
    c. 实现类依赖接口或抽象类

用更加精简的定义就是:面向接口编程——OOD(Object-Oriented-Design, 面向对象设计)的精髓之一。

0 0