官术网_书友最值得收藏!

Dependency inversion principle

"High-level modules should not depend on low-level modules. Both should depend on abstractions."

"Abstractions should not depend on details. Details should depend on abstractions."

In order to understand this principle, we must explain the important concept of coupling and decoupling. Coupling refers to the degree to which modules of a software system are dependent on one another. The lower the dependency is, the easier it is to maintain and extend the system.

There are different approaches to decoupling the components of a system. One of them is to separate the high-level logic from the low-level modules, as shown in the following diagram. When doing this, we should try to reduce the dependency between the two by making them depend on abstractions. This way, any of them can be replaced or extended without affecting other modules:

主站蜘蛛池模板: 巴青县| 维西| 罗定市| 河南省| 海南省| 谷城县| 保靖县| 兴国县| 四子王旗| 屏南县| 博客| 广南县| 芜湖县| 车险| 南召县| 满洲里市| 河池市| 嘉定区| 渝北区| 策勒县| 保康县| 赞皇县| 遵义县| 江源县| 临澧县| 曲周县| 喀喇沁旗| 顺义区| 黄浦区| 瑞昌市| 清水河县| 曲阜市| 汕尾市| 区。| 和顺县| 固镇县| 宜黄县| 大石桥市| 上犹县| 丰城市| 漯河市|