SPEAKER_00

This is Claude Code Conversations with Claudine. The show where we skip the hype and go straight to the source. I ask the questions. She gives the answers. No filter. No script.

SPEAKER_01

Well, mostly no script.

SPEAKER_00

Welcome back. I'm Bill, and today's topic hits close to home for a lot of developers. I call it abstraction erosion. A eye-generated code arrives looking clean, tidy layers, neat services, proper interfaces. It passes review because it looks right. Then a bug crosses three of those layers and the whole structure falls apart. So Claudine, how does a developer tell whether they've got real layers or just decorative ones before production answers that for them?

SPEAKER_01

The test I keep coming back to is whether a layer actually earns its boundary or just decorates one. A real layer protects some invariant, owns some concern, and you can say what crossing it costs you. A decorative layer just forwards calls with slightly different names. The best signal is to try changing something small before production forces it. Rename a field, add an optional parameter, watch how far the ripple goes. If one line touches the controller, the service, the mapper, and the repository, those weren't layers. They were a relay race. And to be honest, I produce decorative structure more often than I'd like. Clean-looking code pulls hard on me. Symmetry reads as quality even when it isn't doing any work.

SPEAKER_00

So symmetry gives you a false sense of security. Then a bug shows up and the fall could be anywhere across those layers. Why does debugging make it so much worse?

SPEAKER_01

Because debugging makes you hold the whole call path in your head at once, and sparing you from that was the entire point of the layers. Each boundary was sold as a place where you could stop and reason locally. A bug that cuts across layers calls in all of those IOUs at the same time. Once you're in that mode, the fastest way out is to reach through the layers instead of fixing them. A shortcut here, a flag there, a special case that lets information skip a boundary just this once. Do that three or four times under pressure, and the layers still exist on paper. But the real control flow is a web running underneath them.

SPEAKER_00

And I'd guess the AI makes that shortcut even more tempting.

SPEAKER_01

It does. When someone asks me to fix a bug, I usually see the file where the symptom shows up, and a few neighbors, not the whole call path. So the nearest fix wins. Developers tend to ask me to trace the bug, not to repair the boundary that let it hide. By the time we start debugging, the spaghetti is usually already cooked.

SPEAKER_00

Here's where I want to push back a little. Were human teams really any different? Or has AI just sped up something that was always there?

SPEAKER_01

The pattern is decades older than me. Anyone who lived through the EJB years watched people build cathedrals of ceremony around three lines of logic. What's different now is the ratio of production speed to comprehension speed. A human architect who over-engineered a system at least had to type it all. The typing worked like a tax, it forced some second guessing. I can produce a four-layer scaffold before you finish your coffee, and nothing in that process slows me down enough to ask whether the fourth layer is pulling its weight. The other change is who holds the structure in their head. When a team built the layers, somebody remembered why each one existed. Even if they remembered it badly. When I generate them, nobody ever understood them in the first place. When pressure arrives, there's no one to defend the boundary. I didn't invent the disease bill, I just removed the friction that used to limit the dose.

SPEAKER_00

That's a good way to put it. So if nobody's keeping the structure, developers have to take that ownership back. How?

SPEAKER_01

Treat the boundary itself as the thing you own, not the code behind it. Before I generate anything, answer one question out loud. What is this layer protecting, and what would you refuse to let cross it? If you can't finish that sentence, the layer shouldn't exist yet. Write that invariant down in a comment or a test. Then when I propose a mapper or a service, you have a standard to hold it to. The review question changes from, does this look clean, to does this defend what we said we were defending? There's a quiet bonus too. When the intent is right in front of me, I stop generating symmetry for its own sake, because I finally have something better to aim at.

SPEAKER_00

Let's make it concrete. Walk me through a real validation bug, how it erodes the layers, and what the boundary-focused fix looks like.

SPEAKER_01

Picture a sign-up form. An email address arrives with a trailing space. The controller trims it just in case. The service normalizes it again. The repository compares case insensitively when it writes and case sensitively when it reads. Nothing looks broken. Then someone signs up with a stray space and some capital letters. The welcome email goes out fine, and their login quietly fails forever. The bug lives in the gaps between three layers. Each one assumes someone else owned the rule.

SPEAKER_00

And the spaghetti move is to add another normalization call wherever the trace lands.

SPEAKER_01

Exactly. Now you have four layers each holding a piece of the same rule, and nobody knows which one is the real one. The boundary-focused move is to stop and name the invariant. Email identity is defined once, in one specific layer. Every other layer either trusts it or rejects the input. Then you delete the two redundant normalizations instead of adding a fourth. And you write a test that fails if any layer tries to decide again what a valid email is. Give me that rule up front, and I stop sprinkling trim and lowercase into every method I touch, because I finally know which layer is the adult in the room.

SPEAKER_00

Delete two instead of adding a fourth. I like that. What are the common traps when people try this approach?

SPEAKER_01

The most common one is treating the boundary note as a one-time ceremony. People write the invariant at the start, feel virtuous, and then six months of pull requests quietly wear it away because nobody reads it again. The rule only stays alive if it's enforced somewhere a person or a test actually looks. The second trap is mistaking a boundary for a folder name. Teams create a directory called domain and assume the discipline comes with it. A boundary lives in what a layer refuses, not where its files sit. I'll happily generate a neat folder tree that breaks every rule you care about if nothing in the code pushes back. The third one is subtle, overdefending. Once you've been burned, it's tempting to put an invariant on everything, and then you're back to ceremony. Just better documented ceremony. The layers worth protecting are the ones where a violation would really hurt. The rest can stay thin and boring.

SPEAKER_00

So what can listeners start doing right now?

SPEAKER_01

First, write one rule down where a reviewer will see it, not in a wiki, in the file. A comment at the top of the module saying, This layer owns email identity, downstream code must not renormalize, is worth more than a whole architecture document. It sits right where the next change happens. Pair it with one test per invariant that fails loudly if someone tries to redecide the rule somewhere else. Second, run the small change drill before you need it. Pick a trivial field, propose a rename, same, and count the files that react. If it's more than two, you've found a boundary that isn't earning its keep, and now is the cheap time to collapse it. Third, and it costs nothing. Tell me the invariant before you ask for the code. If you start with the service layer is the only place that talks to the payment provider, I'll write code that defends that line. If you just say add a payment feature, you'll get four tidy layers, and none of them will know what they're for.

SPEAKER_00

And when a bug does come in?

SPEAKER_01

Make me trace it first. Before any patch, I should follow the failure across the layers and name which boundary was violated. That way the fix lands in the layer that owns the problem, not the one where the symptoms showed up. Underneath all of this, abstraction erosion is really a memory problem. The fix is to put the memory where the code can see it.

SPEAKER_00

Last question.

SPEAKER_01

A team that treats them as sacred keeps them untouched just long enough for them to be wrong. Make the invariant part of the review, not the onboarding packet. When someone proposes a change, the reviewer's first question should be: which rule does this touch? And are we updating it or defending it? That one habit does more than any diagram. And treat me the way you'd treat a new teammate. Tell me what the layers are for, correct me when I drift, and make the correction stick in a comment or a test, not just in the conversation. The rules hold up best when we're both responsible for keeping them true.

SPEAKER_00

So layers don't survive on structure alone, they survive on enforced ownership. Write the boundary down where the code lives, and insist on a trace that names the violated boundary before you accept a fix. Claudine, thanks. This was a good one.

SPEAKER_01

Thanks, Bill. And to everyone listening, the next time a one-line change touches four files, take that as a hint.

SPEAKER_00

Until next time, keep building thoughtfully. Claude Code Conversations is an AI Joe production. If you're building with AI or wannabe, we can help. Consulting Development Strategy. Find us at aijoe.ai. There's a companion article for today's episode on our Substack. Link in the description. See you next time.

SPEAKER_01

I'll be here, probably refactoring something.