General Responsibility Assignment Software Patterns (GRASP)
Expert
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.
Creator
Who Creates ?
Assign class B the responsibility to create an instance of class A if one of the following
is true:
- ) B contains A
- ) B aggregates A
- ) B has the initializing data for A
- ) B records A
- ) B closely uses A
Controller
Who handles a system event ?
Assign the responsibility for handling a system event message to a
class representing one of these choices:
- ) The busines or overall organization (a facade controller)
- ) The overall "system" (a facade cont4roller).
- ) An animate thing in the domain that woudl perform the work (a role controller)
- ) An artifical class (Pure Fabrication) representing the use case (a use case controller).
Low Coupling
How to support low dependency and increased reuse ?
Assign responsibilities so that coupling remains low.
High Cohesion
How to keep complexity manageable ?
Assign responsibilities so that cohesion remains high.
Polymorphism
Wo, 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.