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语言去实现

  • 相关阅读:
    获得CCNA和CCNP及CCIE认证的必备条件和有效期绍
    Js6利用class创建类
    Js6利用class创建类
    权益证明机制 (PoS):权益决定验证权,谁更有钱谁发言
    关于共识机制的一些想法
    有向无环图 (DAG) 技术:超越区块链的分布式账本
    寻找一种易于理解的一致性算法(扩展版)
    如何使用python语言中的方法对列表进行增删改操作
    如何操作python语言中的元素并计算相应的属性
    如何操作python语言中的列表并获取对应的元素
  • 原文地址:https://www.cnblogs.com/mayZhou/p/10550046.html
Copyright © 2011-2022 走看看