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

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:

主站蜘蛛池模板: 华亭县| 新密市| 东丽区| 三门县| 郑州市| 格尔木市| 韶山市| 双峰县| 惠安县| 泽普县| 阿图什市| 建水县| 泰兴市| 囊谦县| 泉州市| 赫章县| 朝阳市| 三台县| 鄂伦春自治旗| 扶沟县| 大安市| 阳新县| 景洪市| 盐津县| 兰溪市| 海原县| 波密县| 登封市| 高雄县| 马尔康县| 兴安盟| 阜平县| 定州市| 西乌珠穆沁旗| 万山特区| 大邑县| 昌平区| 堆龙德庆县| 波密县| 平昌县| 玉山县|