Visualize a Modular Design
The locate function that we created during spiking does everything. That’s perfect for its intended purpose—to gain insight into the problem at hand. However, the production code we write should not resemble the spike. A function that does a lot generally fails the single responsibility principle,[13] lacks cohesion, and has high coupling. Such code is often expensive and difficult to maintain; also, its behavior is hard to verify quickly.
There are multiple little functions waiting to spring out of that spike to make the design modular and code testable. Let’s visualize those little functions, each with a single responsibility and minimum dependencies.
The dotted boxes are the external dependencies and the solid boxes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access