Principles of Object-Oriented Design

Use object-oriented design principles in Java to shape responsibilities, abstractions, and dependencies before pattern names enter the discussion.

Object-oriented design principles help Java teams decide where behavior belongs, which abstractions are worth introducing, and which dependencies should remain stable. They are more useful as review tools than as slogans.

This chapter covers SOLID, DRY, KISS, YAGNI, composition over inheritance, the Law of Demeter, and GRASP responsibility-assignment patterns so design choices stay explicit before a codebase hardens around them.

In this section

  • SOLID Principles
    Apply SOLID in Java to separate responsibilities, extend behavior safely, preserve substitutability, narrow interfaces, and invert dependencies.
  • DRY Principle in Java
    Reduce harmful Java duplication while avoiding premature abstractions that make simple changes harder to understand.
  • KISS Principle in Java
    Keep Java designs simple enough to maintain by removing unnecessary abstraction, branching, and framework ceremony.
  • YAGNI Principle in Java
    Avoid speculative Java features and extension points until real requirements justify the extra design weight.
  • Composition Over Inheritance in Java
    Compare delegation and inheritance in Java so reuse stays flexible without creating brittle class hierarchies.
  • Law of Demeter in Java
    Reduce Java object navigation chains so collaborators expose useful behavior instead of leaking internal structure.
  • GRASP Principles
    Use GRASP in Java to assign responsibilities, reduce coupling, preserve cohesion, and protect designs from unstable variation points.
    • 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.
Revised on Thursday, April 23, 2026