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 ...
随机推荐
- java框架之Shiro-安全/权限框架
准备 简介 Apache Shiro 是 Java 的一个安全(权限)框架. Shiro 不仅可以用在 JavaSE 环境,也可以用在 JavaEE 环境. Shiro 可以完成:认证.授权.加密.会 ...
- A标签中 href 和 onclick用法、区别、优先级别
(内容摘自:https://blog.csdn.net/chenchunlin526/article/details/77346049) Html A标签中 href 和 onclick 同时使用的问 ...
- postman接口自动化,环境变量的用法详解(附postman常用的方法)
在实现接口自动测试的时候,会经常遇到接口参数依赖的问题,例如调取登录接口的时候,需要先获取登录的key值,而每次请求返回的key值又是不一样的,那么这种情况下,要实现接口的自动化,就要用到postma ...
- Linux更新时,出现无法更新锁
1.查看软件中心是否有更新 2.重启 3.rm/var/lib/dpkg/lock 4.sudo apt-get update 5.sudo dpkg --configure -a
- java求最大公约数,和最小公倍数
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = ...
- C++ Windows API 读写INI文件
BOOL WritePrivateProfileString( LPCTSTR lpAppName, // INI文件中的一个字段名[节名]可以有很多个节名 LPCTSTR lpKeyName, // ...
- js对象添加动态属性
在业务中,经常会遇到使用同个方法调用多个同类型接口,以下简单模拟两个API接口 // api-1 { code: 0, status: 200, title: 'web前端框架', list: [ { ...
- wysiwyg 富文本编辑器(附带图片上传功能)
Fist: 需要的文件 font 文件夹下面的也是需要的哟 Then: 引入文件 <link href="bootstrap/css/bootstrap.css" rel=& ...
- tomcat是怎么找到项目lib目录下的jar包的,求大神解答
是通过java代码动态的修改classpath吗,和classloader有关系吗
- 清空nohup日志
#清空nohup日志cat /dev/null > /tpdata/www/wxapp_domain/nohup.out