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

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:

主站蜘蛛池模板: 金溪县| 杭锦后旗| 黑龙江省| 鄂伦春自治旗| 凤翔县| 宾阳县| 义马市| 板桥市| 博兴县| 宁强县| 新巴尔虎右旗| 康马县| 同江市| 博兴县| 弥勒县| 屏东县| 射洪县| 阜阳市| 杭锦旗| 达日县| 敦化市| 托克逊县| 敦化市| 菏泽市| 漠河县| 惠东县| 马尔康县| 大荔县| 桂林市| 盘山县| 安西县| 丰都县| 曲靖市| 莱阳市| 邮箱| 普宁市| 介休市| 阳西县| 津南区| 黄龙县| 潜山县|