Created August 15, 2010
Last updated August 15, 2010
[ Japanese | English ]

Object-oriented design and GRASP Pattern

  In this page , I will introduce 1 the GRASP Pattern 2 that is a pattern about assigning responsibility to classes when we design in object-oriented.

  Before reading this page , if you don't know the module cohesion and module coupling , please read "Object-oriented and the Module Cohesion and the Module Coupling - Dharma's Excel VBA" previously.

-----
Note.
1. I'm sorry , I don't know the GRASP pattern in detail. Therefore , I can not explain it.
2. The GRASP pattern is a range of UMTP L3.

1. What is the GRASP Pattern ?
2. Reference


1. What is the GRASP Pattern ?

  The GRASP Patten( General Responsibility Assignment Software Patterns ) is a pattern about assigning responsibility to classes when we design in object-oriented.

  The GRASP Pattern has the followings patterns (Table 1).

Table 1 - Patterns in the GRASP Pattern
1. Information Expert
Problem: What is a basic principle by which to assign responsibilities to Objects ?
Solution: Assign a responsibility to the class that has the information needed to fulfill it.
Merit: The informations are encapsulated. The module coupling between classes becomes lower. The informations are dispersed and understandable. And the class that the module cohesion is high is defined.
Related patterns:Low Coupling Pattern , High Cohesion Pattern
2. 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):
  • B "contains" or compositely aggregates A.
  • B records A.
  • B closely uses A.
  • B has the initializing data for A that will be passed to A when it is crated. Thus B is an Expert with respect to creating A.

Merit: The module coupling between classes becomes lower.
Related patterns: Low Coupling Pattern
3. Controller
Problem: What first object beyond the UI layer receives and coordinates ("controls") a system operation ?
Solution: Assign the responsibility to a class representing one of the following choices:
  • Major subsystem classes
  • A use case scenario classes within which the system event occurs
Merit: The classes are more reusable. The chance to judge the state of the use case is obtained.
4. Low Coupling
Problem: How to support low dependency, low change impact, and increased reuse ?
Solution: Assign a responsibility so that coupling remains low.
Merit: The class is more independent from the change of the other classes. The class is more understandable. The classes are more reusable.
Related patterns: Protected Variations Pattern
5. High Cohesion
Problem: How to keep objects focused, understandable, and manageable, and as a side effect, support Low Coupling ?
Solution: Assign a responsibility so that cohesion remains high.
Merit: The clearness and understandability of the design is higher. The maintenance and enhancing is easier. The module coupling between classes becomes lower.
6. Polymorphism
Problem: How to design the choices which is dependent by the class ?
Solution: The same name operations (methods) in the difference classes is defined. And assign a responsibility to the class the class that the behavior is changed.
Merit: When the variation ( choice ) increases newly, it is possible to enhance it easily.
Related patterns: Protected Variations Pattern. There are related patterns in Gang of Four Design Patterns.
7. Pure Fabrication
Problem: How to become higher cohesion and lower coupling ? (When it doesn't go well in other pattern )
Solution: Define a class for convenience' sake that doesn't express the concept of the problem area at all.
Merit: The module cohesion of the class is higher. The classes are more reusable.
Related patterns: Low Coupling Pattern , High Cohesion
8. Indirection
Problem: To de-couple objects so that Low coupling is supported and reuse potential remains high?
Solution: Assign the responsibility to an intermediate object to mediate between other components or services, so that they are not directly coupled.
Merit:The module coupling between classes becomes lower.
Related patterns:Protected Variations Pattern , Low Coupling Pattern , Pure Fabrication Pattern. There are related patterns in Gang of Four Design Patterns.
9. Protected Variations
Problem:How can we design objects , subsystems and systems such that the variations in these do not have an undesirable impact on other elements in the system?
Solution: Assign responsibility to create a stable interface around an unstable or predictably variable subsystem or component.
Merit: When the variation increases newly, it is possible to enhance it easily. The module coupling between classes becomes lower.
Related patterns: There are a lot of related pattern in the GoF design patterns.

  If you think the Table 1 is not understood easily ( I'm soryy ) , please read the "2. Reference".
  If you don't know the GRASP Patterns , I think that the practiced one is most 1.   In the GRASP Patterns , the most important patterns are "Low Coupling" and "High Cohesion". If you need the details , please read "Object-oriented and the Module Cohesion and the Module Coupling - Dharma's Excel VBA".
-----
Note. 1:
  Then, isn't it significant to this? It is No. The thing that the pattern is named, is important. When in reviewing the specifications , coaching subordinates and communicating other person , if name is not existed , we have a hard time.
And , by named, the persuasive power become higher.
Back to Top

2. Reference

  The following tables are pages that I referred to create this page.


No.

Linked Website Name

Description

Linked date

1 GRASP - Designing Objects with Responsibilites - A Methodical Approach to Basic OO Design This page introduces the GRASP Pattern. August 15, 2010
2 GRASP patterns This page introduces the GRASP Pattern. August 15, 2010
3 GRASP Patterns This page introduces the GRASP Pattern. August 15, 2010
4 GRASP (Object Oriented Design) This page introduces the GRASP Pattern. August 15, 2010

No.

Author

Book Name

ISBN

1 Craig Larman Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition) 978-0131489066


Prev Up Next  Top
Back to Top

I doesn't assume the responsibility of any damage that occurs because of the use of this page.

Microsoft ,Windows ,Visual Basic and Excel are registered trademarks of Microsoft Corporation in the United States and other countries.
Visual Basic® for Applications may represent a VBA.
Mac ,Mac OS ,Mac OS X ,AppleScript are trademarks of Apple Inc., registerd in the U.S. and other countries.
Other brands and their products are trademarks or registered trademarks of their respective holders and should be noted as such.

The author of this page and these companies do not have any relationship.