liveBook · Manning

Chapter 9: Stratified design: Part 2

What you will learn in chapter 9 of Grokking Simplicity

The chapter introduces the next part of stratified design, previewing patterns and their relevance to maintenance, testing, and reuse.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces the next part of stratified design, previewing patterns and their relevance to maintenance, testing, and reuse.

9.1 Patterns of stratified design

This section summarizes four patterns of stratified design and the purpose of each.

Key terms: straightforward implementation, code smell, abstraction barrier, interface, implementation detail, minimal interface, business concepts, operations, comfortable layers, stratified design

9.2 Pattern 2: Abstraction barrier

Introduces abstraction barriers as the second stratified-design pattern and previews their role in delegating responsibilities between teams.

9.3 Abstraction barriers hide implementations

An abstraction barrier hides implementation details behind functions so programmers can work at a higher level.

Key terms: abstraction barrier, implementation, higher level

9.4 Ignoring details is symmetrical

This section explains how an abstraction barrier lets the teams on either side ignore each other’s implementation details and work largely independently.

Key terms: abstraction barrier, implementation, shopping cart

9.5 Swapping the shopping cart’s data structure

The section shows how an abstraction barrier confines a shopping cart data-structure change to one layer.

Key terms: linear search, JavaScript object, hash map, abstraction barrier

9.6 Re-implementing the shopping cart as an object

Replacing the shopping cart’s array with a JavaScript object makes additions and removals more appropriate and the code cleaner without changing marketing’s code.

Key terms: JavaScript object, array, random additions and removals, straightforward, marketing department’s code, Cart as array, Cart as object

9.7 The abstraction barrier lets us ignore details

The section explains how an abstraction barrier lets code use shopping carts without depending on their underlying data structure.

Key terms: abstraction barrier, layer, data structure, incomplete abstraction barrier, splice()

9.8 When to use (and when not to use!) abstraction barriers

Explains when abstraction barriers help and why adding them for hypothetical future changes can be wasteful.

Key terms: abstraction barrier, layer of indirection, implementation, details, problem at hand, coordination, development team, marketing

9.9 Pattern 2 Review: Abstraction barrier

Reviews how an abstraction barrier lets code on each side ignore different details and why it should be used strategically.

Key terms: abstraction barrier, code above the barrier, code at or below the barrier, abstraction barriers, ignoring details, inter-team communication

9.10 Our code is more straightforward

The section revisits straightforward implementation, using the shopping-cart refactor to show why one-line functions can signal a well-chosen level of abstraction.

Key terms: straightforward implementation, level of generality and detail, one-liners

9.11 Pattern 3: Minimal interface

This section uses two shopping-cart features to show why minimal interface favors adding new behavior above a clean lower-level interface.

Key terms: minimal interface, abstraction barrier, contract, higher levels, logAddToCart(), add_item(), action, calculation, spreading rule, update_shipping_icons()

9.12 Pattern 3 Review: Minimal interface

Reviews the minimal interface pattern by explaining why layers should expose only the functions they need and where new functions should go.

Key terms: abstraction barrier, interface, minimal interface, layer, implementation, low-level code, complete, minimal, and timeless, layers, call graph

9.13 Pattern 4: Comfortable layers

Introduces comfortable layers as a practical way to decide when to stop refining a design and when to improve it again.

Key terms: comfortable layers, comfort pattern, stratified design, abstraction barrier, layers of abstraction, robust layers

9.14 Patterns of stratified design

This section recaps the four patterns of stratified design and what each contributes to a useful layer structure.

Key terms: straightforward implementation, right level of detail, code smell, abstraction barrier, interface, implementation detail, minimal interface, business concepts, operations, comfort

9.15 What does the graph show us about our code?

This section explains that the structure of a call graph, even without function names, can reveal important qualities of code beyond whether it works correctly.

Key terms: call graph, functional requirements, nonfunctional requirements, NFRs, maintainability, testability

9.16 Code at the top of the graph is easier to change

The section explains why code near the top of a call graph is easier to change and how that guides the placement of frequently changing code.

Key terms: call graph, layers of change, business rules, copy-on-write functions

9.17 Testing code at the bottom is more important

Explains why tests for stable code in lower layers tend to pay off more over time than tests for frequently changing code in higher layers.

Key terms: stratified design, layers of testability, code at the bottom

9.18 Code at the bottom is more reusable

This section explains why lower layers in stratified design offer more opportunities for code reuse.

Key terms: stratified design, lower layers, reuse

9.19 Summary: What the graph shows us about our code

Summarizes three rules of thumb for using a call graph to judge where code is easiest to change, most valuable to test, and most reusable.

Key terms: call graph, maintainability, top of the graph, testability, bottom of the graph, reusability, lower layers

9.20 Conclusion

The conclusion recaps how stratified design organizes functions into layers and helps reveal where code is easier to test, change, and reuse.

Key terms: stratified design, layers of abstraction, layer structure, testable, changeable, reusable

9.21 Summary

9.22 Up next…

Closes the first part of the book and previews the next chapter’s move toward using code like data.

Where this is used later

Concepts explained in this chapter

← Chapter 8: Stratified design: Part 1 Chapter 10: First-class functions: Part 1 →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.