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

  • 相关阅读:
    VS2019 .Net Core 3.1 Web 项目启用动态编译
    IntelliJ IDEA自动注释作者信息和日期时间
    Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.1.RELEASE from/to
    MS SQL Server数据批量插入优化详细
    更改VisualStudio默认创建类和接口不加public问题
    WIN10 报错 "此共享需要过时的SMB1协议,而此协议是不安全"的解决方法
    Delphi XE8,C++ Builder XE8,RAD Studio XE8 官方 ISO 文件下载,附激活工具
    PC 安装MAC
    InnoSetup能够实现“安装细节描述”界面吗?
    在Unicode版Inno Setup中使用ISSkin
  • 原文地址:https://www.cnblogs.com/mayZhou/p/10550046.html
Copyright © 2011-2022 走看看