7.2 GRASP原则二:信息专家 Information Expert
2、GRASP原则二:信息专家 Information Expert
What is a general principle of assigning responsibility to objects?
为一个对象 分配职责的一般原则是什么?
“鸡鸣狗盗” 战国时候,齐国的孟尝君喜欢招纳各种人做门客,号称宾客三千….
2.2 GRASP rule2: Information Expert
Name: Information Expert (信息专家)
Problem:
What is a general principle of assigning responsibility to objects?
Solution:
Assign responsibility to the class that has the information necessary to fulfill responsibility
Information
an object's own state,
about other objects, the world around an object,
information the object can derive,
and so forth
Answer to Mini exercise 2
2.3 Information Expert — How to?
步骤
1)Clearly state the responsibility
2)Look in Design Model for relevant classes
3)Else look in Domain Model and create design classes
信息专家的优点
封装性 Encapsulation
对象充分利用自身的信息 objects support their own information
支持低耦合 supports low coupling
系统行为分布到不同的类 Behavior is distributed across classes
支持高内聚 supports high cohesion
7.2 GRASP原则二:信息专家 Information Expert的更多相关文章
- 7.3 GRASP原则三: 低耦合 Low Coupling
3.GRASP原则三: 低耦合 Low Coupling How to support low dependency, low change impact and increased reuse? ...
- 运用GRASP原则来做uml交互类图-------pos机实例
重要的几个GRASP原则:1.控制器模式 2.创建者模式 (原则)3.信息专家模式(原则) 4. 高内聚 低耦合 这里所说的模式并不是java中针对具体的事件的设计模式 主成功场景的几个操作: ...
- 7.7 GRASP原则七: 纯虚构 Pure Fabrication
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 由谁来负责创 ...
- Effective C# 学习笔记(原则二:为你的常量选择readonly而不是const)
原则二.为你的常量选择readonly而不是const Prefer readonly to const 对于常量,C#里面有两个不同的版本:运行时常量(readonly)和编译时常量(co ...
- 7.9 GRASP原则九: 隔离变化
GRASP原则九: 隔离变化 Protected Variations 需求一定会变化的!如何做到以系统的局部变化为代价就可以应对这一点?4.1 GRASP rule9: Protected ...
- 7.8 GRASP原则八: 间接 Indirection
GRASP原则八: 间接 Indirection 若两个对象直接连接,导致耦合太紧,如何解决?3.1 GRASP rule8: Indirection 间接 Name: Indirection ...
随机推荐
- java中equals()和==的区别
java中的数据类型 基础数据类型 基础数据类型有byte.short.char.int.long.float.double.bool.String.除了 String 会比较地址,其它的基础类型的比 ...
- python迭代-可迭代对象与迭代器对象
可迭代对象与迭代器对象 问题举例 某软件要求,从网络抓取各个城市的气温信息,并依次显示: 北京:15~22 上海:18~23 ...... 如果一次抓取所有城市气温信息再显示,显示第一个城市的气温时会 ...
- Python之__slots__ &运算符重载反向运算
1.运算符重载之反向运算 class A: def __init__(self,x): self.x = x def __add__(self, other): try: x = other.x re ...
- tensorboard窥视
运行神经网络时,跟踪网络参数,以及输入输出是很重要的,可据此判断模型是否在学习,损失函数的值是否在不断减小.Tensorboard通过可视化方法,用于分析和调试网络模型. 使用tensorboard的 ...
- laravel容器container 阅读记录
今天抽时间又仔细看了一下laravel的container,记录一下. 所谓容器,听名字就知道,是一个仓库,装东西用的,所以,container所有的功能,都围绕一个主题:管理装. 类名称:Illum ...
- 《CSS世界》读书笔记(六)
<!-- <CSS世界> 张鑫旭著 --> min-width/max-width和min-height/max-height min-width/max-width出现的场景 ...
- vue.js中的computed和watch的区别
1.computed在调用时不需要加(),watch是不需要调用的2.computed如果属性没有发生改变时会从缓存中读取值,watch当属性发生改变时会接收到2个值:一个为新值,一个为旧值3.com ...
- myeclipse集成meavn
环境准备: JDK 1.6 Maven 3.0.4 myeclipse 8.6.1 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Maven是 Apache 下的一个项目,目前最新版 ...
- oracle(2)
create table aaa( id number, name varchar2(100) ); select decode((select max(id) from aaa),null,'x', ...
- Spring Boot Log4j2 日志学习
简介 Java 中比较常用的日志工具类,有: Log4j. SLF4j. Commons-logging(简称jcl). Logback. Log4j2(Log4j 升级版). Jdk Logging ...