zoukankan      html  css  js  c++  java
  • 7.1 通用的职责分配软件原则 GRASP原则一: 创建者 Creator

    1、GRASP原则一: 创建者 Creator
       Who should be responsible for creating a new instance of some class

        由谁来负责创建某个类的新实例(对象)
    1.1 GRASP 原则

       GRASP

         General Responsibility Assignment Software Patterns

         初学对象技术的同学,在编码或绘制交互图和类图时,应该理解并应用 GRASP的内在思想,

          以便尽快地掌握这些基本原则,它们是设计OO系统 的基础

         GRASP原则可以帮助设计人员理解面向对象设计的本质,并以一种有条理 的、理性的、

          可解释的方式应用这些设计原则

          The GRASP patterns are a learning aid to help one understand essential object design,

          and apply design reasoning in a methodical, rational, explainable ways
       GRASP 原则共9条

         Creator

         Information Expert

         Low Coupling

         Controller

         High Cohesion
         Polymorphism

         Indirection

         Pure Fabrication

         Protected Variations
    1.3 GRASP rule1: Creator (创建者)

       Name: Creator

       Problem:

         Who should be responsible for creating a new instance of some class?

       Solution:

         Assign class B the responsibility to create an instance of class A if one of these is true (the more the better) :

         1. B “contains” or compositely aggregates A

         2. B records A

         3. B closely uses A

         4. B has the initializing data for A that will be passed to A when it is created (B is an expert with respect to A)

           如果有一个以上的选项适用,通常首选聚集或包含A的类  Note:  B and A refer to software objects, not domain model objects

  • 相关阅读:
    原生和jQuery的ajax用法
    sublime常用快捷键
    用filter:grayscale将图片过滤成灰色
    Docker搭建Zookeeper集群问题总结
    Linux下jdk环境配置
    window MySQL解压缩版部署及配置
    Windows下Nginx的配置及配置文件部分介绍
    JS 特性:可选链(?.)
    509道Java面试题解析:2020年最新Java面试题
    阿里面试题BIO和NIO数量问题附答案和代码
  • 原文地址:https://www.cnblogs.com/mayZhou/p/10550011.html
Copyright © 2011-2022 走看看