摘要: 其他面向对象设计原则2  能用组合的地方,不要用继承 Favor object composition over class inheritance6.1 代码重用的两种方式  能用组合的地方不要用继承 Favor object composition over class inheritanc 阅读全文
posted @ 2019-03-18 07:33 otr 阅读(273) 评论(0) 推荐(0) 编辑
摘要: 其他面向对象设计原则1: 开-闭原则OCP  Open-Closed Principle (OCP)5.1 设计变坏的前兆 Signs of Rotting Design  僵硬性 Rigidity  难以更改代码 code difficult to change  从管理角度,拒绝任何的变 阅读全文
posted @ 2019-03-18 07:25 otr 阅读(234) 评论(0) 推荐(0) 编辑
摘要: GRASP原则九: 隔离变化  Protected Variations  需求一定会变化的!如何做到以系统的局部变化为代价就可以应对这一点?4.1 GRASP rule9: Protected Variations  Name: Protected Variations 隔离变化  Pro 阅读全文
posted @ 2019-03-18 07:18 otr 阅读(685) 评论(0) 推荐(0) 编辑
摘要: GRASP原则八: 间接 Indirection  若两个对象直接连接,导致耦合太紧,如何解决?3.1 GRASP rule8: Indirection 间接  Name: Indirection  Problem: 把职责分配到哪里可以避免两个或者多个对象之间的 直接耦合?如何解耦对象以保持 阅读全文
posted @ 2019-03-18 07:15 otr 阅读(380) 评论(0) 推荐(0) 编辑
摘要: GRASP原则七: 纯虚构 Pure Fabrication  如果依据信息专家原则获得的解决方案不合适,既不想违反低耦合、高内聚,也不想违 反其他的原则, 该如何把职责分配给对象?  左右为难….2.1 GRASP rule7: Pure Fabrication 纯虚构  Name: Pur 阅读全文
posted @ 2019-03-18 07:13 otr 阅读(942) 评论(0) 推荐(0) 编辑
摘要: GRASP原则六: 多态 Polymorphism  How to handle alternative behaviors based on type 如何处理依据类型不同而有 不同行为的一类需求 ?  比如,开餐馆  苏州人喜欢甜、四川人喜欢麻、湖南人喜欢辣,咋处理 ?1.1 9条GRAS 阅读全文
posted @ 2019-03-18 07:10 otr 阅读(332) 评论(0) 推荐(0) 编辑
摘要: GRASP原则五:高内聚 High Cohesion  How to keep objects focused, understandable and manageable, and as a side effect support Low Coupling? 如何使对象功能专注、可理解、可管理, 阅读全文
posted @ 2019-03-18 07:03 otr 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 4、GRASP原则四:控制器 Controller  What first object beyond the UI layer receives and co-ordinates (controls) a system operation? 在领域层,由谁负责首先接收并协调来自UI层的系统操作? 阅读全文
posted @ 2019-03-18 05:50 otr 阅读(903) 评论(0) 推荐(0) 编辑
摘要: 3、GRASP原则三: 低耦合 Low Coupling  How to support low dependency, low change impact and increased reuse?  如何保证设计方案支持低的依赖性、低的变化影响度、增加可重用性?3.2 耦合的定义Couplin 阅读全文
posted @ 2019-03-18 05:39 otr 阅读(473) 评论(0) 推荐(0) 编辑
摘要: 2、GRASP原则二:信息专家 Information Expert  What is a general principle of assigning responsibility to objects? 为一个对象 分配职责的一般原则是什么?  “鸡鸣狗盗” 战国时候,齐国的孟尝君喜欢招纳各 阅读全文
posted @ 2019-03-18 05:20 otr 阅读(664) 评论(0) 推荐(0) 编辑