liveBook · Manning

Premature optimization

As explained in Grokking Software Architecture

Premature optimization is optimizing software before a measured performance bottleneck justifies the change.

Premature optimization means changing software for speed before measurements show a real bottleneck. It’s like rearranging the kitchen for a dinner rush that hasn’t happened: the extra work may make the layout harder to use without solving a real problem. section 5.8.3

For example, keeping database entities, domain models, and API DTOs separate means writing repetitive mappers. Avoid collapsing those boundaries just to dodge a theoretical performance hit: the separation protects the domain when the database changes, while the mapping adds early-development effort. section 5.8.3

A cache you may not need

A distributed cache can be simpler and more predictable than adding a local L1 cache. Add that extra layer only when metrics show network latency or cloud costs are hurting the business. Local caching can make sense for practically immutable data, microsecond latency needs, or substantial network costs. section 10.6

Figure 10.8 Multi-Level Caching: The Local Cache (L1) is like a personal sticky note for blistering speed, while the Distributed Cache (L2) is a shared whiteboard for the entire system.

The sticky-note and shared-whiteboard comparison helps distinguish a local cache from a distributed cache—and makes the extra layer’s appeal easy to see. section 10.6

How Grokking Software Architecture covers it

How deep it goes
Defines the principle and gives design and caching examples, but does not lay out a measurement procedure.
Examples
Uses repetitive entity-to-model mapping and adding a local L1 cache before metrics justify it.
What you can do after
Evaluate whether a performance-driven design change is justified by a measured bottleneck or business cost.
How it connects
Connects the principle to hexagonal architecture, domain separation, distributed caching, and local caching.

Also explained in

Compare how 5 books explain premature optimization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.