General Responsibility Assignment Software Patterns or Principles (GRASP)
来源:互联网 发布:共享单车盈利模式 知乎 编辑:程序博客网 时间:2024/06/05 19:41
Understanding responsibilities is key to good object-oriented design.
---MartinFowler
General Responsibility Assignment Software Patterns or Principles (GRASP)
Pattern/Principle
Description
Information
Expert
A general principle of object design and responsibility assignment?
Assign a responsibility to the information expert the class that has the information necessary to fulfill the responsibility.
Creator
Who creates? (Note that Factory is a common alternate solution.)
Assign class B the responsibility to create an instance of class A if one of these is true:
1. B contains A
4. B records A
2. B aggregates A
5. B closely uses A
3. B has the initializing data for A
Controller
What first object beyond the UI layer receives and coordinates ("controls") a system operation?
Assign the responsibility to an object representing one of these choices:
- Represents the overall "system," a "root object," a device that the software is running within, or a major subsystem (these are all variations of a facade controller).
- Represents a use case scenario within which the system operation occurs (a use-case or session controller)
Low Coupling (evaluative)
How to reduce the impact of change?
Assign responsibilities so that (unnecessary) coupling remains low. Use this principle to evaluate alternatives.
High Cohesion (evaluative)
How to keep objects focused, understandable, and manageable, and as a side-effect, support Low Coupling?
Assign responsibilities so that cohesion remains high. Use this to evaluate alternatives.
Polymorphism
Who is responsible when behavior varies by type?
When related alternatives or behaviors vary by type (class), assign responsibility for the behavior using polymorphic operations to the types for which the behavior varies.
Pure Fabrication
Who is responsible when you are desperate, and do not want to violate high cohesion and low coupling?
Assign a highly cohesive set of responsibilities to an artificial or convenience "behavior" class that does not represent a problem domain concept something made up, in order to support high cohesion, low coupling, and reuse.
Indirection
How to assign responsibilities to avoid direct coupling?
Assign the responsibility to an intermediate object to mediate between other components or services, so that they are not directly coupled.
Protected Variations
How to assign responsibilities to objects, subsystems, and systems so that the variations or instability in these elements do not have an undesirable impact on other elements?
Identify points of predicted variation or instability; assign responsibilities to create a stable "interface" around them.
- General Responsibility Assignment Software Patterns or Principles (GRASP)
- GRASP通用职责分配软件模式(General Responsibility Assignment Software Patterns)
- Atitit GRASP(General Responsibility Assignment Software Patterns),中文名称为“通用职责分配软件模式”
- GRASP——General Responsiblity Assignment Software Patterns
- Software Architecture : Organizational Principles and Patterns
- 《Agile Software Development: Principles, Patterns, and Practices》
- Principles of Software Development
- Principles of Software Testing
- Principles of Software Design
- A list of books on general-purpose algorithms for the practical programmer (or 'software engineer')
- Software Requirement Patterns
- Software Architecture Patterns
- Agile Principles, Patterns, and Practices in C#
- Principles of Software Development (aka Principles of Shipping)
- Principles of Service Design: Service Patterns and Anti-Patterns
- Lean Software Development, Part 1: Seven Principles
- Non-Software Examples of Software Design Patterns
- Design Patterns -- Chain of Responsibility (CoR)
- ubuntu12.10绑定静态mac地址
- mysqldump
- 文件上传与下载
- 动态规划
- 常见面试题 (待续)
- General Responsibility Assignment Software Patterns or Principles (GRASP)
- 科目组(Account Group)、子段状态组(Field Status Group)和子段状态变式(Field Status Variant)
- Android_launcher的源码详细分析
- [c++笔记]关于编译
- Windows 7 + Visual 2010 + WDK 7600.16385.1 配置方法
- xrdp开源项目的代码分析
- VM虚拟机中RedHat系统的基础操作
- SqlCommand类
- 新手SEO,站长必备,各种实用工具