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

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:

主站蜘蛛池模板: 河西区| 芦山县| 兴化市| 宽甸| 栾城县| 扶绥县| 上林县| 巴林左旗| 西吉县| 荃湾区| 清水县| 黔南| 尼勒克县| 绥德县| 牟定县| 民乐县| 巫溪县| 横山县| 徐水县| 徐闻县| 泊头市| 库车县| 岳西县| 安福县| 揭阳市| 海门市| 德化县| 玉山县| 乌什县| 万山特区| 都匀市| 吴江市| 凤山县| 佛学| 陆川县| 大同市| 武城县| 武胜县| 广西| 宿迁市| 修武县|