SOLID is not a single theory — where the five principles came from
The word SOLID gives the impression that the five principles were designed as a single theory. They were not. Trace their origins and the proposers, the dates, and the motivations are all different; the bundling came later.
This chapter goes to the original text to confirm where the five came from. That is not a taste for history. It matters because treating the five as an equal-ranked monolith leaves you unable to decide when the principles collide with each other.
The original text does not list five principles
The starting point is usually taken to be "Design Principles and Design Patterns," published by Robert C. Martin in 20001. It predates the SOLID name and lays out the principles of object-oriented design as a list.
Here are the principles that document names, in the order they actually appear.
Principles of class design (the section in the original is titled "Principles of Object Oriented Class Design")
| Abbreviation | Definition in the original |
|---|---|
| OCP | "A module should be open for extension but closed for modification." |
| LSP | "Subclasses should be substitutable for their base classes." |
| DIP | "Depend upon Abstractions. Do not depend upon concretions." |
| ISP | "Many client specific interfaces are better than one general purpose interface" |
Principles of package design (the section titled "Principles of Package Architecture")
Three concerning cohesion (REP / CCP / CRP) follow, then three concerning coupling (ADP / SDP / SAP). CCP, for instance, is "Classes that change together, belong together."
Two things stand out here.
First, SRP is absent. The single responsibility principle appears neither in the body of the document nor in its bibliography. Martin's own articles listed in the bibliography are six: [OCP97], [LSP97], [DIP97], and [ISP97], plus [Granularity97] and [Stability97] (the sources for the six package design principles). None corresponds to SRP.
Second, the class principles and the package principles are listed as equals. The four now discussed as SOLID and the six package principles get equal treatment in this document. The idea of pulling out only one group and making a set of five is not there yet.
In other words, as of 2000 there was no grouping called "the five SOLID principles." What existed was a list of ten principles side by side.
Where each of the five came from
Here are the origins, organized as far as the original text and what it points to allow.
| Principle | Whose idea | Source |
|---|---|---|
| SRP | Robert C. Martin | Not in the 2000 document above. The venue of first publication is unconfirmed |
| OCP | Bertrand Meyer | Martin writes "It originated from the work of Bertrand Meyer" and refers to Object-Oriented Software Construction2 |
| LSP | Barbara Liskov | Martin says it was "coined by Barbar Liskov" (spelling as in the original) and lists "Data Abstraction and Hierarchy" in the bibliography3 |
| ISP | Robert C. Martin | The bibliography key is [ISP97] |
| DIP | Robert C. Martin | The bibliography key is [DIP97] |
All six bibliography keys Martin attached to his own articles carry 97. Commentary articles state that these were a series in the magazine C++ Report, but the bibliography in the original omits publication details (several entries simply trail off with "..."), so the month and year of publication cannot be established from the original text. This series treats them at the granularity of "Martin's own articles from the late 1990s."
Looking at the distribution of origins, two of the five are other people's work. OCP is something Meyer wrote for a different purpose, and LSP comes from the type theory of programming languages. The remaining three are Martin's, but of those, SRP alone is not in the original list.
The name "SOLID" came later
The acronym SOLID was created not by Martin but by Michael Feathers, around 2004. This is a secondary source, however — Wikipedia states it with a citation, but no primary source in which Feathers himself describes coining the name could be reached4.
The order in which the name arrived looks like this. The principles are proposed individually (late 1980s through the 1990s) → they are collected into a list (2000) → five are selected and made into an acronym (around 2004).
What the acronym hid
In exchange for memorability, the acronym dropped several pieces of information.
The principles that were not selected disappeared from view. The six package design principles were equals in the original text. Not many people can recite them today. They did not fit into five letters.
Differences in level of abstraction were flattened. The five are not rules of the same granularity. LSP is a property a type hierarchy must satisfy; break it and the types lie. SRP is guidance on how to divide modules, and there is latitude in whether you follow it. DIP is about the direction of dependencies, and its unit is between modules. They are all called by the same word, "principle," but the severity of what happens when you violate them differs.
The fact that the principles collide disappeared from view. Of the acronym's side effects, this is the one that bites hardest in real work. And the original text states the collision explicitly. On the three principles concerning package cohesion, Martin writes:
These three principles are mutually exclusive. They cannot simultaneously be satisfied.
The original says the principles can be mutually exclusive, yet the acronym presents them as "a list of five things you should all follow." The five in the acronym are no different: push splitting in the direction of SRP and one change touches more files; prepare extension points ahead of time for OCP and unused abstractions are left behind. That said, what the original states this explicitly about is the three package principles; collisions on the class side are what you observe in practice. Which one to take is not settled by staring at a list of principles.
The original also has something to say about the relationships among the principles. At the end of the section on LSP violations, Martin writes:
Thus, violations of LSP are latent violations of OCP.
The five are not parallel; they have dependencies. This relationship is revisited in the final chapter.
How to read this series
With that in place, this series covers the five principles in the following order. Rather than the order in the original text (OCP / LSP / DIP / ISP), it takes the order of the acronym (SRP / OCP / LSP / ISP / DIP). That is to match the order readers already know, not an endorsement of the original's structure.
Every chapter has the same shape.
- What the original said — confirming what the proposer actually wrote, without going through a secondary source
- Why follow it — identifying the cost the principle is trying to reduce
- How it gets misused — covering what happens when you follow it too far
- When it's OK to break it — writing down the conditions under which not applying it is sound
- Where TypeScript stands today — covering the places where the language's type system changes the premises
Where a claim could not be confirmed against the original text, the body says so. In this chapter, that applies to the venue of SRP's first publication and to who coined the acronym.
Summary
- The 2000 original text lists four principles of class design and six of package design, and SRP appears neither in the body nor in the bibliography
- Of the five, OCP is Meyer's work and LSP is Liskov's; people other than Martin proposed them in different contexts
- The acronym SOLID is said to have been created by Michael Feathers around 2004 (secondary source)
- The acronym hid the principles that were not selected, the differences in level of abstraction, and the collisions among the principles
- The original itself writes, of the three package cohesion principles (REP / CCP / CRP), that they are mutually exclusive and cannot be satisfied at the same time
What to read next
The next chapter covers the single responsibility principle. We look at how this principle, absent from the original list, came to be defined afterward, and how the proposer himself made explicit what its "reason" refers to.
Exercises
Of the following four claims, pick the ones that are wrong in light of the original text confirmed in this chapter, and say why
- The five SOLID principles were presented as a single group by Robert C. Martin in his 2000 document
- OCP derives from the work of Bertrand Meyer rather than Martin
- Violating LSP means latently violating OCP as well
- The principles are mutually independent, and you can aim to satisfy all of them at once
Sample answer
The wrong ones are 1 and 4.
Why 1 is wrong: the class design principles the 2000 document lists are the four OCP / LSP / DIP / ISP, and SRP appears neither in the body nor in the bibliography. The six package design principles are also listed as equals, so the grouping "a set of five" does not exist at that point. Selecting five and making them an acronym is attributed to Michael Feathers around 2004 (secondary source).
Why 4 is wrong: on the three principles concerning package cohesion, the original states explicitly, "These three principles are mutually exclusive. They cannot simultaneously be satisfied." That principles can be mutually exclusive is the original's position.
2 and 3 match what the original says. 2 corresponds to "It originated from the work of Bertrand Meyer," and 3 to "violations of LSP are latent violations of OCP."
One qualification on 4: what the original describes as mutually exclusive is the three package design principles. It does not say the five in the acronym are exclusive in the same sense. In practice, though, trade-offs do arise among the five as well. That point is covered in the final chapter.