7.7 GRASP原则七: 纯虚构 Pure Fabrication
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的更多相关文章
- 7.6 GRASP原则六: 多态 Polymorphism
GRASP原则六: 多态 Polymorphism How to handle alternative behaviors based on type 如何处理依据类型不同而有 不同行为的一类需求 ...
- 7.4 GRASP原则四:控制器 Controller
4.GRASP原则四:控制器 Controller What first object beyond the UI layer receives and co-ordinates (control ...
- 7.1 通用的职责分配软件原则 GRASP原则一: 创建者 Creator
1.GRASP原则一: 创建者 Creator Who should be responsible for creating a new instance of some class 由谁来负责创 ...
- 运用GRASP原则来做uml交互类图-------pos机实例
重要的几个GRASP原则:1.控制器模式 2.创建者模式 (原则)3.信息专家模式(原则) 4. 高内聚 低耦合 这里所说的模式并不是java中针对具体的事件的设计模式 主成功场景的几个操作: ...
- 7.9 GRASP原则九: 隔离变化
GRASP原则九: 隔离变化 Protected Variations 需求一定会变化的!如何做到以系统的局部变化为代价就可以应对这一点?4.1 GRASP rule9: Protected ...
- 7.8 GRASP原则八: 间接 Indirection
GRASP原则八: 间接 Indirection 若两个对象直接连接,导致耦合太紧,如何解决?3.1 GRASP rule8: Indirection 间接 Name: Indirection ...
- 7.5 GRASP原则五:高内聚 High Cohesion
GRASP原则五:高内聚 High Cohesion How to keep objects focused, understandable and manageable, and as a si ...
- 7.3 GRASP原则三: 低耦合 Low Coupling
3.GRASP原则三: 低耦合 Low Coupling How to support low dependency, low change impact and increased reuse? ...
- 7.2 GRASP原则二:信息专家 Information Expert
2.GRASP原则二:信息专家 Information Expert What is a general principle of assigning responsibility to obje ...
随机推荐
- 基础SQL注入
预备知识对mysql数据库有一定了解:对基本的sql语句有所了解:对url编码有了解:空格=‘%20’,单引号=‘%27’,双引号=‘%22’,井号=‘%23’等 基本步骤1. 判断是什么类型注入,有 ...
- python 中的__new__与__init__
在Python中的class中有两个方法__new__与__init__,有什么区别呢? class TestCls(): """docstring for TestCl ...
- MySql 创建索引原则
https://blog.csdn.net/csdnones/article/details/50412603 为了使索引的使用效率更高,在创建索引时,必须考虑在哪些字段上创建索引和创建什么类型的索引 ...
- 2018年工作终总结&规划
收获满满的2018 收获总结: 1. 换了家有地区牌照的公司,薪酬涨了那么一点点,但是工作压力.强度下降不少,这样有更多时间来学习新知识. 2. 跟同事一起接了维护后台管理系统的私活,每个月多了一点点 ...
- 【Java】NO.84.Project.1.OCEA.1.001-【Dreamcar】-
1.0.0 Summary Tittle:[Java]NO.84.Project.1.OCEA.1.001-[Dreamcar]- Style:Project Series:Java Since:20 ...
- 理解Deadlock
问:为啥以下代码会产生死锁 public class Deadlock { static class Friend { private final String name; public Friend ...
- pip 更改国内镜像
2 pip 更改国内镜像 pip 默认不使用国内镜像,但是我们可以自己设置 -[pypi 镜像使用帮助] 临时使用 pip install -i https://pypi.tuna.tsinghua. ...
- C#ImageList和ListView的使用
一.ImageList ImageList组件,又称为图片存储组件,它主要用于存储图片资源,然后在控件上显示出来,这样就简化了对图片的管理.ImageList组件的主要属性是Images,它包含关联 ...
- Hdu2039 三角形
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2039 三角形 Time Limit: 2000/1000 MS (Java/Others) Me ...
- php 排列组合函数(无重复组合,可重复组合【全排列组合】)
<?php /** * 无重复排列組合 * @Author MAX * @DateTime 2018-09-07T16:28:40+0800 * @param Array $arr 需要排列組合 ...