GRASP Principles
Use GRASP in Java to assign responsibilities, reduce coupling, preserve cohesion, and protect designs from unstable variation points.
General Responsibility Assignment Software Patterns (GRASP) help answer a practical Java design question: which class should do this work? The patterns focus less on object diagrams and more on responsibility placement, coupling, cohesion, and stable seams.
This section covers common GRASP choices such as Information Expert, Creator, Controller, Low Coupling, High Cohesion, Pure Fabrication, Indirection, and Protected Variations.
In this section
- Information Expert in Java
Assign Java responsibilities to the classes that already hold the required information without turning them into overgrown god objects.
- Creator Principle in Java
Decide which Java class should create another object based on containment, initialization data, and lifecycle ownership.
- Controller Principle in Java
Use Java controllers to receive system events and coordinate application work without absorbing domain logic.
- Low Coupling in Java
Reduce unnecessary Java dependencies so modules can change, test, and deploy with fewer ripple effects.
- High Cohesion in Java
Keep Java classes focused around related responsibilities so behavior remains easier to understand, test, and evolve.
- Polymorphism in Java Design
Use Java polymorphism when substitutable behavior clarifies variation better than conditionals or scattered type checks.
- Pure Fabrication in Java
Introduce Java service or helper classes when a non-domain abstraction improves cohesion and reduces coupling.
- Indirection Principle in Java
Add Java indirection only when an intermediate abstraction genuinely reduces coupling or isolates variation.
- Protected Variations in Java
Shield Java code from predictable change by placing stable interfaces around volatile behavior, data, or infrastructure.