GRASP原则七: 纯虚构 Pure Fabrication
   如果依据信息专家原则获得的解决方案不合适,既不想违反低耦合、高内聚,也不想违 反其他的原则,

    该如何把职责分配给对象?

   左右为难….
2.1 GRASP rule7: Pure Fabrication 纯虚构

   Name: Pure Fabrication

   Problem: 依据一些原则(比如,信息专家)获得的解决方案不合 适的情况下,既不想违反低耦合、高

    内聚,也不想违反其他的原则, 如 何 把 职 责 分 配 给 对 象 ?

    What objects should have the responsibility, when you do not want to violate High Cohesion

    and Low Coupling, or other goals, but solutions offered by Expert (for example) are not appropriate?

   Solution: 把高度内聚的职责分配给虚构出来的一个类,这个类在 领域模型里没有对应的概念

    Assign a highly cohesive set of responsibilities to an artificial or convenience class that does

    not represent a problem domain concept – something made up to support high cohesion,

    low coupling, and reuse

   推论: 这种方式在有的场合能起到支持低耦合、高内聚、重用的效果
2.3 纯虚构原则讨论

   应用纯虚构原则

     A Pure Fabrication should be designed with high potential for reuse

       – The responsibilities must remain small and cohesive

       Reuse potential should increase

     Many existing GOF patterns are examples of Pure Fabrication

     多数情况下是按功能类定义新的类,所以,是一种“功能为中心的”对象

      It is partitioned on related functionality, and so is a kind of function-centric object

     如果功能的相关性比较高的话,满足高内聚 High Cohesion is supported if functions are highly related    风险

     宽泛地说,虚构对象分为两类 design of objects can be broadly divided into two groups:

       代表性概念为主的分解 representational decomposition, ex, sale

       行为性概念为主的分解 behavioral decomposition, ex, PersistentStorage

     可能导致面向功能或者面向过程的分析/设计,然后用OO语言去实现

7.7 GRASP原则七: 纯虚构 Pure Fabrication的更多相关文章

  1. 7.6 GRASP原则六: 多态 Polymorphism

    GRASP原则六: 多态 Polymorphism  How to handle alternative behaviors based on type 如何处理依据类型不同而有 不同行为的一类需求 ...

  2. 7.4 GRASP原则四:控制器 Controller

    4.GRASP原则四:控制器 Controller  What first object beyond the UI layer receives and co-ordinates (control ...

  3. 7.1 通用的职责分配软件原则 GRASP原则一: 创建者 Creator

    1.GRASP原则一: 创建者 Creator  Who should be responsible for creating a new instance of some class 由谁来负责创 ...

  4. 运用GRASP原则来做uml交互类图-------pos机实例

    重要的几个GRASP原则:1.控制器模式   2.创建者模式 (原则)3.信息专家模式(原则) 4. 高内聚 低耦合   这里所说的模式并不是java中针对具体的事件的设计模式 主成功场景的几个操作: ...

  5. 7.9 GRASP原则九: 隔离变化

    GRASP原则九: 隔离变化  Protected Variations  需求一定会变化的!如何做到以系统的局部变化为代价就可以应对这一点?4.1 GRASP rule9: Protected ...

  6. 7.8 GRASP原则八: 间接 Indirection

    GRASP原则八: 间接 Indirection  若两个对象直接连接,导致耦合太紧,如何解决?3.1 GRASP rule8: Indirection 间接  Name: Indirection ...

  7. 7.5 GRASP原则五:高内聚 High Cohesion

    GRASP原则五:高内聚 High Cohesion  How to keep objects focused, understandable and manageable, and as a si ...

  8. 7.3 GRASP原则三: 低耦合 Low Coupling

    3.GRASP原则三: 低耦合 Low Coupling  How to support low dependency, low change impact and increased reuse? ...

  9. 7.2 GRASP原则二:信息专家 Information Expert

    2.GRASP原则二:信息专家 Information Expert  What is a general principle of assigning responsibility to obje ...

随机推荐

  1. JQuery插件之【jqGrid】常用语法整理

    jqGrid常用语法整理,包含数据获取.常用函数.触发事件等 jqGrid表格数据获取相关语法 获取表格所有数据 $("#grid").jqGrid("getRowDat ...

  2. 对象的创建与OOP-Klass模型

    1.JVM中OOP-KLASS模型 在JVM中,使用了OOP-KLASS模型来表示java对象,即:1.jvm在加载class时,会创建instanceKlass,表示其元数据,包括常量池.字段.方法 ...

  3. Cartographer源码阅读(8):imu_tracker

    IMU的输入为imu_linear_acceleration 和  imu_angular_velocity 线加速和角速度.最终作为属性输出的是方位四元数.  Eigen::Quaterniond ...

  4. 算数运算符: + - * / //(地板除) %(取余) **(幂运算) / 比较运算符 > < >= <= == !=

    # ### python运算符 #(1) 算数运算符: + - * / //(地板除) %(取余) **(幂运算) var1 = 5 var2 = 8 # +res = var1 + var2 pri ...

  5. js 获取时区

    js的时区函数: 设datename为创建的一个Date对象 ====================datename.getTimezoneOffset()--取得当地时间和GMT时间(格林威治时间 ...

  6. python迭代-可迭代对象与迭代器对象

    可迭代对象与迭代器对象 问题举例 某软件要求,从网络抓取各个城市的气温信息,并依次显示: 北京:15~22 上海:18~23 ...... 如果一次抓取所有城市气温信息再显示,显示第一个城市的气温时会 ...

  7. 19 Python标准异常总结 (转)

    Python标准异常总结 AssertionError 断言语句(assert)失败 AttributeError 尝试访问未知的对象属性 EOFError 用户输入文件末尾标志EOF(Ctrl+d) ...

  8. C#-----中使用using详解

    1.using指令 using + 命名空间名字 例:using System;        using System.Data; 2.using语句 定义一个范围,在范围结束时处理对象,出了这个范 ...

  9. django+nginx+python3 生产环境部署

    一.安装python基础环境 1.安装各类基础模块 yum install  gcc-c++ wget openssl-devel bzip2-devel expat-devel gdbm-devel ...

  10. SPOJ - AMR11E

    Arithmancy is Draco Malfoy's favorite subject, but what spoils it for him is that Hermione Granger i ...