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的更多相关文章

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

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

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

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

  3. 7.7 GRASP原则七: 纯虚构 Pure Fabrication

    GRASP原则七: 纯虚构 Pure Fabrication  如果依据信息专家原则获得的解决方案不合适,既不想违反低耦合.高内聚,也不想违 反其他的原则, 该如何把职责分配给对象?  左右为难… ...

  4. 7.6 GRASP原则六: 多态 Polymorphism

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

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

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

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

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

  7. Effective C# 学习笔记(原则二:为你的常量选择readonly而不是const)

    原则二.为你的常量选择readonly而不是const      Prefer readonly to const 对于常量,C#里面有两个不同的版本:运行时常量(readonly)和编译时常量(co ...

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

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

  9. 7.8 GRASP原则八: 间接 Indirection

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

随机推荐

  1. php-memcache基本用法

    //create a memcache object        $mem = new Memcache(); //create connection        $mem->connect ...

  2. bounds的应用

    frame是参考父view的坐标系来设置自己左上角的位置.设置bounds可以修改自己坐标系的原点位置,进而影响到其“子view”的显示位置.   向上滚动scrollview,我们就不断增加scro ...

  3. 020-并发编程-java.util.concurrent之-jdk6/7/8中ConcurrentHashMap、HashMap分析

    一.概述 哈希表(hash table)也叫散列表,是一种非常重要的数据结构,应用场景及其丰富,许多缓存技术(比如memcached)的核心其实就是在内存中维护一张大的哈希表. 是根据关键码值(Key ...

  4. java框架之SpringBoot(12)-消息及整合RabbitMQ

    前言 概述 大多数应用中,可通过消息服务中间件来提升系统异步通信.扩展解耦的能力. 消息服务中两个重要概念:消息代理(message broker)和目的地(destination).当消息发送者发送 ...

  5. PHP中new self()和new static()的区别探究

    1.new static()是在PHP5.3版本中引入的新特性. 2.无论是new static()还是new self(),都是new了一个新的对象. 3.这两个方法new出来的对象有什么区别呢,说 ...

  6. IdentityServer4授权和认证集成Identity和profile

    identiyt的使用可以看之前的文章:https://www.cnblogs.com/nsky/p/10323415.html 之前的ids4授权服务器都是用的in-men方式把数据添加到内存, 现 ...

  7. C#设计模式(9)——装饰者模式(Decorator Pattern)(转)

    一.引言 在软件开发中,我们经常想要对一类对象添加不同的功能,例如要给手机添加贴膜,手机挂件,手机外壳等,如果此时利用继承来实现的话,就需要定义无数的类,如StickerPhone(贴膜是手机类).A ...

  8. Ajax 监听

    $.ajaxSetup({ beforeSend: function (XMLHttpRequest) { alert("ajax请求之前"); } });

  9. torch随机数 manual_seed

    import torch seed = 2018 torch.manual_seed(seed) torch.cuda.manual_seed(seed) a=torch.rand([1,5]) # ...

  10. js 图片无缝滚动

    html部分 <div id="roll"> <a href="javascript:void(0)" class="prev&qu ...