10. Gradients

Adaptation is a recurring theme throughout this series. We feel comfortable, and we feel that our surroundings are natural, when centers are adapted to their context.

The forces that shape centers vary continuously throughout space. As a result, when a structure is made of many similar centers, the centers will generally not be exactly the same. Each one will be slightly different as it adapts to the unique combination of forces in its particular location. The result will be a gradient of shapes, which reflects the gradient of forces in the environment.

When you look at the methods of a class or the functions in a module, you often see a gradient from public/primary to private/secondary. Similarly, when you read the tests for a module, you see a gradient from error cases to edge cases to central cases. These gradients exist because of another gradient: human attention, as a function of the position of the scrollbar. We tend to start reading at the top of the file and scan downward. If we can't find what we're looking for, our attention is likely to drift. Good code acknowledges this by putting the stuff people look for at the top.

Gradients will follow as the natural response to any changing circumstance in space, as centers become adapted correctly to the changes which move across space.

The Phenomenon of Life p. 206

Gradients of activity occur over the life of a software project. At the beginning of a project, much of the work is user research, UX design, and planning. As development ramps up, design gradually ramps down. Eventually, the project becomes less exploratory, and settles down into a rhythm of feature development. Finally, as the software product matures, the pace of development cools further, and the codebase stabilizes. These gradients form naturally when we respond to the forces on the project in the simplest way possible: by doing the most valuable thing at every moment.