All Posts
Problem SolvingJudgementCareerHow Senior Engineers Think · Part 1 of 1

Pattern Matching Is an Index You Build

Share

I asked a senior engineer a question I'd been slightly embarrassed to ask: how do you always seem to know which pattern applies to a problem you've never seen before? I expected "experience," or "read more books." Instead he reframed the whole thing — and it's stuck with me since.

His answer: pattern matching isn't a talent you either have or don't. It's an index you build. And most engineers build the wrong index, which is exactly why they can't recall prior art at the moment it would help. Here's the distinction, and how to fix it.

The core insight: index by shape, not by technology

There's a classic study — Chi, Feltovich and Glaser, on physics problems — where novices sorted problems by surface features ("this one has a pulley, this one has an inclined plane") while experts sorted by deep structure ("these are both conservation-of-energy problems"). Same knowledge, different filing system. The expert's index is keyed on the underlying shape, so the right tool surfaces even when the surface looks unfamiliar.

Most engineers store memories like "I used MDC once." That's filed under technology — it only fires when you see MDC again. The expert stores "I once needed to carry request-scoped context into a shared component without threading it through every call — MDC was one answer." That's filed under problem shape, so it fires for a Jackson serializer, an OpenTelemetry span, a React context, a coroutine's CoroutineContext — none of which look like MDC on the surface.

So the entire skill reduces to one habit: whenever you learn or use a tool, force yourself to name the abstract problem it solves, and file it under that name.

Watch how a handful of unrelated-looking things collapse to a single shape:

Surface (what it's called)Deep structure (the shape)
Logging MDCcall-scoped context → shared component, without explicit passing
Spring SecurityContextHolderthe same shape
@Transactional propagationthe same shape (the "ambient" transaction)
OpenTelemetry baggage / spansthe same shape
Passing the principal into a Jackson serializerthe same shape — which is why it was instantly recognizable

Once you've filed even two of those under "ambient / call-scoped context propagation," the fifth one announces itself. That last row is exactly what happened to me in the ThreadLocal Trap: the problem felt novel until I named its shape, and then it was just that problem again, wearing a Jackson costume.

The highest-leverage habit: reverse-engineer the tools you already use

Here's the part that felt almost unfair, it's so cheap. You already use @Transactional, a security context, maybe MDC — every week. You use them as black boxes. The cheapest pattern knowledge available to you is to crack open the three or four tools you touch most and ask:

  • What problem class does this belong to?
  • Mechanically, how does it work? (A ThreadLocal? A stack? An interceptor?)
  • What's its failure mode — when does it break, and how badly?

You don't need new exposure; you need to abstract the exposure you already have. This is far more effective than reading a patterns book cold, because it attaches the abstract shape to something you already have muscle memory for. (In that same ThreadLocal work, I'd reached for a caching wrapper and a pluggable policy resolver without noticing they were textbook Decorator and Strategy — patterns I'd "used" for years without ever filing them by name.)

Failure modes are the strongest memory hooks

Notice why ThreadLocal stuck in my head from that project: the scar. "Leaks on pooled threads → confidentiality breach." Patterns indexed by their war stories are far stickier than patterns indexed by their happy path.

So when you study any pattern, collect its failure mode too. "Circuit breaker — prevents cascading failure, but a misconfigured timeout makes it flap." That pairing — what it's for + how it bites — is what makes a pattern recallable under pressure, which is the only time recall actually matters.

Deliberate practice, cheap and daily

The senior engineer's framing turned this from "be more experienced" into a set of small, repeatable reps:

  1. The "what else is this?" reflex. Every time you solve something non-trivial, force one analogy: "this is an instance of ___." Even a wrong analogy trains the muscle. A post-mortem that ends in "this is a case of [shape]" is this exercise written down.
  2. Cross-domain spotting. The same shapes recur everywhere: caching = memoization = CDN = materialized view = a lazy {} property. Context propagation spans backend and frontend (React Context is the same shape as MDC). When you spot a shape in a second domain, it locks in.
  3. Read library internals and design RFCs. Kotlin KEEPs, Java JEPs, big OSS design discussions, the "motivation" section of any good framework doc. These are pattern-dense, and they explain the why — the part that carries the shape.
  4. Keep a tiny pattern catalog indexed by shape. One line each: shape → instances I've seen → failure mode. Over a year this quietly becomes your personal index.

A short, high-yield reading list

These are, in effect, catalogs of shapes — which is exactly what you're trying to build:

  • Design Patterns (Gang of Four) — the classic 23 object-level shapes (Decorator and Strategy live here).
  • Patterns of Enterprise Application Architecture (Fowler) — Unit of Work, Identity Map, Repository, and friends.
  • Release It! (Nygard) — stability and failure patterns (Circuit Breaker, Bulkhead, Timeout). The best book for the failure-mode habit.
  • Designing Data-Intensive Applications (Kleppmann) — the distributed-systems shapes.
  • Enterprise Integration Patterns (Hohpe & Woolf) — messaging and integration shapes.

Don't read them to memorize. Read them to collect names for shapes you've already half-seen, so they become recallable.

The one guardrail

The failure mode of this skill is over-pattern-matching — forcing a known shape onto a problem that doesn't fit, and cargo-culting a microservice, a circuit breaker, or a Kubernetes cluster you didn't need. The senior version of this skill isn't "I know lots of patterns." It's "I know the shape and its trade-offs, so I can tell when it doesn't apply." Always pair the pattern with the question: what does this cost, and is that cost worth it here? — the same worst-case lens that, in the ThreadLocal story, was the whole point.

Why it compounds

Here's the part that made the whole thing click for me. The more shapes you file, the faster you file the next one — because new things are just "X, but with Y." That's why senior engineers seem to "just know": they're not smarter, they've got a denser index. It compounds, quietly, every time you name a shape instead of memorizing a tool.

You don't get there by waiting for experience to accumulate. You get there by abstracting the experience you already have. So next time you solve something that mattered, before you close the ticket, finish the sentence: this was an instance of ___. Keep naming shapes — that's the whole game.

Share

References

  1. Categorization and Representation of Physics Problems by Experts and NovicesChi, Feltovich & Glaser (1981) — the study on how experts sort by deep structure
  2. Design Patterns: Elements of Reusable Object-Oriented SoftwareGamma, Helm, Johnson & Vlissides (the 'Gang of Four')
  3. Patterns of Enterprise Application ArchitectureMartin Fowler
  4. Release It!Michael Nygard — stability and failure patterns; the best book for the failure-mode habit
  5. Designing Data-Intensive ApplicationsMartin Kleppmann
  6. Enterprise Integration PatternsGregor Hohpe & Bobby Woolf
Back to all posts