The Abstraction Ladder

In this post I hope to help you come to a better understanding of levels of abstraction in software design. I’ll use the clean architecture concept and the abstraction ladder to illustrate it. Let’s start with the ladder.

The Ladder

The abstraction ladder is a way to organize things from concrete to abstract. At the bottom of the ladder are all concrete things. At the top are abstract concepts. In the middle are things that are not very concrete, but also not very abstract. This idea was coined by S. I. Hayakawa in his book Language in Thought and Action” published in 1939. He gave the following example of an abstraction ladder:

8. Wealth
7. Asset
6. Farm assets
5. Livestock
4. Cow
3. Bessie
(2. Object of experience, how we perceive the “process-cow”)
(1. “Process-level”-cow, the atoms, electrons, etc. that Bessie consists of)

Lots of other examples can easily be found in biological taxonomy, e.g.

7. Animalia (Kingdom)
6. Chordata (Phylum)
5. Mammalia (Class)
4. Primates (Order)
3. Hominidae (Family)
2. Homo (Genus)
1. Homo sapiens (Species)

Of course the ladder can be applied to a very wide range. I’ll include one more example to illustrate:

7. Information
6. Publications
5. Books
4. Novels
3. Science-fiction novels
2. Dirk Gently’s Holistic Detective Agency
1. My copy of Dirk Gently’s Holistic Detective Agency

As you may notice, when you move up the ladder, the description related to the rung you are on has fewer characteristics than the rung below it.

Code Example

The Dagger (2) documentation contain a good example of how the ladder can be applied to code as well. They’re describing how to abstract and construct a coffee maker. The ladder that we can build from this example looks like this:

4. Coffee maker
3. Drip coffee maker
2. Drip coffee maker with thermosiphon and electric heater
(1. A particular instance of a drip coffee maker with thermosiphon and electric heater)

Clean Architecture

In his article “The clean Architecture” Uncle Bob illustrates software architecture as a set of concentric circles. Each layer represents an area of responsibility within the software. Working from the inner to the outer circle, the following responsibilities are listed:

  • Entities
  • Use Cases
  • Controllers / Presenters / Gateways
  • Web / UI / External interfaces / DB / Devices

Relation to the abstraction ladder

So how does clean architecture relate to the abstraction ladder? I’m sure you’ve already spotted it. If you look at the layers listed above, the most concrete concept is at the bottom and the most abstract is at the top.

Uncle Bob already made the connection between writing code and writing an article in his book “Clean Code”. The abstraction ladder is another tool that authors can use while writing texts.

It can be a tremendous help for you as software developer when you are able to order your software design concepts on the abstraction ladder. It’ll help you put code on the right level of abstraction. After that you can also make sure that calls you make from one class to another are not jumping across multiple levels of abstraction (or in the example of the ladder, multiple rungs).
Further, it might also make communication with peers easier if you simply draw up a ladder of all the concepts you’re talking about.

Further reading

Leave a Reply

Your email address will not be published. Required fields are marked *