独望枫

人在尘世间,有缘自相见,变化千千万,未开窍,已迷恋
posts - 45, comments - 0, trackbacks - 0, articles - 1
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

2016年7月10日

     摘要: 依赖倒置原则:Dependence Inversion Principle,简称DIP。

定义: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。

翻译成中文如下:

高层模块不应该依赖低层模块,两者都应该依赖抽象
抽象不应该依赖细节
细节应该依赖抽象
  阅读全文

posted @ 2016-07-10 15:59 小菜枫 阅读(395) | 评论 (0)编辑 收藏

     摘要: 单一职责原则:Single Responsibility Priciple,简称SRP。

定义:There should never be more than one reason for a class to change,即不能存在多于一个导致类变更的原因。通俗说法:一个类只负责一项职责。

由来:类C负责两项职责,职责R1,职责R2,当职责R1因某需求导致需要更改类C时,原本正常的R2发生异常。
  阅读全文

posted @ 2016-07-10 14:08 小菜枫 阅读(492) | 评论 (0)编辑 收藏