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. 我对于B-树索引的内部结构与索引类型所做的笔记

    图 3-1 B-树索引的内部结构 分支块和页块 B-树索引有两种类型的块: 用于查找的分支块和用于存储值的叶块.B-树索引的上层分支块包含指向下层索引块的索引数据.在图 3-1 中,根分支块包含条目 ...

  2. Cestos7安装Elasticsearch5.4.3

    Elasticsearch及配件下载地址:https://www.elastic.co/cn/downloads 为了简单起见,我们使用tar文件. 在/usl下创建elk目录 一.安装elastic ...

  3. DjangoMTV模型之视图层views及模板层template

    Django视图层中views的内容 一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容(render),也可以是一个重定向( ...

  4. 小程序 navigator 无法跳转 tabBar上的页面

    解决方法一: navigator 的 open-type 设置为 switchTab 解决方法二: 使用 wx.switchTab({ url: ‘../cart/index’ }) 进行跳转

  5. js页面路径拼接字符串进行参数传递

    页面路径拼接字符串进行参数传递: 参数传递页面: <style> input,button{ border: 1px solid red; } body { font-size:24px; ...

  6. RAMPS1.4 3d打印控制板接线与测试

    “工欲善其事,必先利其器”,在开始工作之前,你应该准备下面所说的工具(包括软件和硬件). 1.需要下载的软件 1.1 固件上传工具——Arduino IDE 这是上传固件的必备工具,有了这个软件让上传 ...

  7. 0003-20180422-自动化第三章-python基础学习笔记

    3章 内容回顾: 1. 计算机组成 2. 程序编译器 3. 变量 4. 条件 5. 循环 6. py2与py3区别 - 默认编码, - 除法, - input ,raw_input 7. 位,字节关系 ...

  8. [openjudge-动态规划]Maximum sum

    题目描述 题目原文 描述 Given a set of n integers: A={a1, a2,-, an}, we define a function d(A) as below: d(A)=m ...

  9. 看懂MSSQL执行计划,分析SQL语句执行情况

    打开SQL执行计划窗口 执行计划的图表是从右向左看的 SQL Server有几种方式查找数据记录 [Table Scan] 表扫描(最慢),对表记录逐行进行检查 [Clustered Index Sc ...

  10. go中 -strconv包的使用

    strconv 包中的函数和方法 // atob.go ------------------------------------------------------------ // ParseBoo ...