- 2073 Bhadra · 4 marks
Short note: GRASP
Short answer
GRASP (General Responsibility Assignment Software Patterns) by Larman provides nine principles for allocating responsibilities, including Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, and Protected Variations, guiding robust object-oriented design.
Write a short note on GRASP.
GRASP stands for General Responsibility Assignment Software Patterns (Principles), described by Craig Larman. They are a set of guidelines for deciding which class should be responsible for what in an object-oriented design. Responsibilities are of two kinds: doing (compute, create, control others) and knowing (private data, related objects).
The nine GRASP patterns
- Information Expert - give the responsibility to the class that holds the needed information.
- Creator - class B creates A if B contains, aggregates, records or closely uses A.
- Controller - first object beyond the UI that receives and coordinates a system event (a use case or session controller).
- Low Coupling - keep dependency between classes low.
- High Cohesion - keep the responsibilities of a class strongly related and focused.
- Polymorphism - use polymorphic operations for behaviour that varies by type, not conditionals.
- Pure Fabrication - create an artificial class (not from the domain) to achieve low coupling and high cohesion, e.g. a database storage class.
- Indirection - add an intermediate object to decouple two classes.
- Protected Variations - protect elements from the variations in other elements using stable interfaces.
Example: in a POS, Sale.getTotal() follows Information Expert, Sale creates SalesLineItem (Creator), and ProcessSaleController handles enterItem() (Controller).
GRASP gives the reasoning behind good object design and is applied while drawing interaction diagrams.
✓ Answer checked by Claude Sonnet 5.5
All Object Oriented Analysis and Design chapter 3 questions →