zoukankan      html  css  js  c++  java
  • 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语言去实现

  • 相关阅读:
    微信小程序中,block的作用
    关于小程序 页面中的生命周期函数
    MySQL -- 修改root密码
    Python3 -- time 获取任意前N天的日期
    linux -- 解决配置vim中文乱码的问题
    Linux -- iTem2 长时间保持会话(不断开)
    数据结构与算法 -- Python实现【归并排序算法】
    Git -- 目录
    Linux -- screen 命令
    python3 -- Linux 离线安装pip3方法
  • 原文地址:https://www.cnblogs.com/mayZhou/p/10550046.html
Copyright © 2011-2022 走看看