liveBook · Manning

SOLID principles

As explained in Grokking Software Architecture

SOLID principles are a group of object-oriented design principles for improving software structure, flexibility, and maintainability.

SOLID is a pre-flight checklist for designing object-oriented code that is easier to maintain, test, and change. It supports separation of concerns, high cohesion, and loose coupling. section 3.1 section 3.11

The five principles guide how classes and components should handle change:

  • Single Responsibility: Give a class one reason to change. section 3.11
  • Open/Closed: Extend behavior by adding code rather than modifying existing code. section 3.11
  • Liskov Substitution: Make child classes true substitutes for their parent class. section 3.11
  • Interface Segregation: Keep interfaces small and specific. section 3.11
  • Dependency Inversion: Depend on abstractions rather than concrete details. section 3.11

Shared contracts such as interfaces and abstract classes help make systems safer to change and easier to test. Good structure also limits a change’s or failure’s blast radius. section 3.10 section 3.11

How Grokking Software Architecture covers it

How deep it goes
Defines all five principles and demonstrates an SRP refactor of order processing, with less concrete treatment of the remaining four.
Examples
Uses junk drawers, toolboxes, LEGO connections, and order processing to illustrate structure and an SRP refactor.
What it assumes
Builds on object-oriented programming and refreshes encapsulation, abstraction, inheritance, and polymorphism.
What you can do after
Evaluate class and component design against principles that support easier maintenance, testing, and change.
How it connects
Connects SOLID to Separation of Concerns, cohesion, coupling, abstractions, interfaces, blast radius, and composability.

Also explained in

Compare how 5 books explain SOLID principles →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.