Stratified design organizes software into layers of abstraction. Each layer defines functions in terms of functions below it, creating foundations that change slowly and higher layers that change more often. A common arrangement separates business rules, domain rules, and the technology stack. section 2.9 section 8.2
Use these patterns to shape and review the layers:
- Build straightforward implementations that solve a function’s problem at one level of detail; treat excess detail as a design smell. section 8.8
- Create abstraction barriers that hide important implementation details behind interfaces, allowing higher-level code to remain focused. section 9.1
- Converge important business concepts on a minimal interface whose operations support the rest of the system. section 9.1
- Keep layers comfortable and purposeful; invest in abstractions that improve delivery and quality rather than adding layers for sport. section 9.14
To improve a design, inspect function names, signatures, bodies, language features, and the call graph. Extract more general functions when a function mixes levels of detail. General functions usually become easier to test, clearer to read, and more reusable. section 8.3 section 8.10
Pizza restaurant software
Separate JavaScript foundations such as arrays and objects from pizza-making rules, then place changing business specifics such as the current menu above them. This arrangement keeps menu changes from affecting much of the underlying code. section 2.9 section 2.19
Use the layer diagram to visualize stable foundations, domain logic, and more changeable business-specific code. section 2.9
