GRASP stands for Genernal Responsibility Assignment Software Patterns. The author, Craig Larman, is a great teacher and scholar. I have enjoyed working with Craig back in my ObjectSpace days. This table is from his book.
| Pattern | Description |
|---|---|
|
Who, in the general case is responsible? Assign a responsibility to the information expert -- the class that has the information necessary to fulfill the responsibility. | |
|
Who creates? Assign class B the responsibility to create an instance of class A if one of the following is true:
| |
|
Who handles a system event? Assign the responsibility for handling a system event message to a class representing one of these choices:
| |
|
How to support low dependency and increased reuse? Assign responsibilities so that coupling remains low. | |
|
How to keep complexity manageable? Assign responsibilities so that cohesion remains high. | |
|
Who, 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. | |
|
Who, 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 class that does not represent anything in the problem domain, in order to support high cohesion, low coupling, and reuse. | |
|
Who, 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. | |
|
Who, to avoid knowing about the structure of indirect objects? Assign the responsibility to a client's direct object to collaborate with an indirect object, so that the client does not need to know about the indirect object. Within a method, messages can only be sent to the following objects:
|

浙公网安备 33010602011771号