Featured Post

Event Sourcing Video from Michael Ploed

Event Sourcing I want to share a great video I found few days ago that describes very well what Event Sourcing is.

Monday, October 8, 2012

Grasp Pattern

GRASP is an acronim for General Responsibility Assignment Software Pattern. These patterns, as the name suggests, deal with assignment of responsibility.
In my opinion, learn these patterns leads to improve the capability of analysis and programming. The main GRASP design patterns are the followings:
  • Controller
  • Creator
  • High Cohesion
  • Indirection
  • Information Expert
  • Low Coupling
  • Protected Variation
  • Pure Fabrication


Controller suggests to use an object to intercept system calls. This object represents the entire system for a specific use case, therefore it's the first object called when a client calls the system. It delegates to other objects the responsibility to solve a request.


Creator solves the problem of assigning the responsibility to create objects in a software system. Given two objects A and B, Creator suggests to use A to create B if:
  • A contains or aggregates instance of B
  • A uses B
  • A has the information to inizialize B

High Cohesion

Hign Cohesion suggests to augment the cohesion inside the same class. This means a good class has methods that satisfy the less number of responsibilities as possible. So a good class has a single specific function and all of its methods, have this goal.

Information Expert

Information Expert solves the problem of assigning a specific responsibility to a class. It suggests to give the responsibility to the class that is the best candidate to perform a responsibility. This class has to have the required information to manage this particular responsibility.

Low Coupling

Low Coupling suggests to reduce dependencies among classes. This leads to limit the impact of changes from a class to another.


Indirection solves the problem of avoiding coupling among classes. It suggests to introduce an intermediate object that acts as an adapter between two components that have to be decoupled.

Protected Variation

Protected Variation aims to find points of variation/change in a system and suggests to protect these points so that other software components could not suffer from these changes. Java Interfaces are the best candidate to reach his goal. When a client interacts with a software system, it has to know only the direct interlocutor. An interface permits developers to change real implementation of a software component maintaining the same interface exposed.

Pure Fabrication

Pure Fabrication solves the problem of assigning responsibility when either Expert either HighCohesion either Low Coupling are in conflict to assign this responsibility. Pure Fabrication suggests to put the responsibility into a class that is not a class belonging to the application domain. Now this class can follow High Cohesion e Low Coupling design patterns.

No comments :

Post a Comment