The SOLID Principles

Building software that is flexible to change

SOLID is an acronym for a set of design principles used to build flexible and maintainable software.


What are the SOLID design principles?

  • Single Responsibility
  • Open / Closed
  • Liskov Substitution
  • Interface Segregation
  • Dependency Inversion

Why do we need SOLID?

We need solid to allow our software designs to evolve and avoid turning into a big ball of mud. What we need is design flexibility without over engineering our solution for requirements that may never materialise. The less existing code you have to change for new requirements the less likely you are to introduce bugs. The SOLID principles sit at the core of good software engineering practice and with TDD can help reduce the fear of change and needless complexity.

What 'Design Smells' do the SOLID principles tackle?

Rigidity - Makes systems hard to change, small changes cause full rebuilds and builds take a long time to complete. Long build times can mean high coupling.

Fragility - A small change to one module causes others to change. E.g. fix one bug and something unrelated breaks.

Immobility - How portable are your modules? Immobility is caused by couplings and dependencies and prevents code being reused outside it's original context.

Let's investigate how SOLID can help us as we look at The Single Responsibility Principle