solid

The Purpose of The SOLID Principles

What are The SOLID Principles? Where in our code do they apply? What are the objectives of SOLID?

I’ll answer these questions today.

 

The SOLID Principles are a collection of five software design guidelines:

The first letter of each principle spells S.O.L.I.D.—thus the name. 

 

These principles outline how we should compose our software at the module level. Modules are mid-level software artefacts. They encapsulate functions and data.

In Object-Oriented (OO) languages, modules are classes. However, the SOLID Principles apply to all non-trivial software systems, not just those written in OO languages. Constructs combining functions and data exist in all programming languages. 

 

The SOLID Principles advise us on:

  • How to combine functions and data structures into modules, and
  • how to interconnect those modules.

That is no small thing. We can cause much damage to a program’s structure if we are unaware of how to arrange code at the module level. 

Examples of these problems are evident in many codebases: Classes with several thousand lines of fragile, buggy code; mixing unrelated responsibilities in the same class—like UI and data access code.

The SOLID Principles are helpful because they guide us to create modules that

  • are easy to change, and
  • are easy to understand, and
  • maximise reusability.

The aspirational purpose of SOLID is to help us build modules that are the opposite of what we must so often work with: ill-defined, incomprehensible, bloated classes that do too much. 

High adherence to SOLID promises that our efforts will be rewarded with small, laser-focused, purposeful modules working nicely with one another. In addition, abstract or generic classes created with SOLID will be reusable on other software applications.

A team of developers who adhere to the SOLID Principles will be well on the road to producing maintainable software.

Further reading:

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply