Composition

Engineers achieve big things by solving little problems. If we can solve all the little problems, we can combine the solutions to solve bigger problems.

Why do we break down problems? This is due to the limitations of the human mind – we can only deal with a small number of concepts at a time, so we break down problems, and break them down again until they’re just the right size that we can mentally digest them.

A well-decomposed problem will produce the most elegant solution.

composition-full

We solve each problem, zooming in to focus on a single arrow, ignoring everything else.

composition-full

In programming we solve small problems by writing functions; these are expressions that get you from a to b.

Finally, we zoom out again to combine the solutions.

We should never lose sight of the purpose of programming: to decompose complex problems into a series of simpler ones.

Bartosz Milewski, The Dao of FP

Being able to decompose bigger problems into smaller problems, and then combine the solutions, that’s essentially the description of… well, I don’t know it depends on who you are, you will say that’s the description of what I’m doing as a programmer, and a mathematician will say that’s the description of what I’m doing as a mathematician, and a physicist will say that’s what I’m doing as a physicist. It’s like, everybody’s doing this. This is the essence of all human activity.

Bartosz Milewski on the Corecursive podcast

The psychological profiling (of a programmer) is mostly the ability to shift levels of abstraction, from low level to high level. To see something in the small and to see something in the large.

An interview with Donald Knuth. Dr. Dobb’s Journal, pages 16–22 (April 1996)