Code for Humans and Machines

Code for Humans and Machines

AI-Readable Code

Reveal Intent in Complex Conditions

Extraction in itself is useless. Naming makes the difference. Here we refactor complex conditions to improve agentic coding.

Adam Tornhill's avatar
Adam Tornhill
May 14, 2026
∙ Paid

Complex conditions are cheap to write and expensive to read.

They usually start small: one &&, a few ||,then one more clause to patch an edge case. Soon they have grown into little puzzles, but not for our amusement.

Every time someone reads such code, they have to reconstruct the intent from raw logic instead of seeing the business rule directly. What should be obvious becomes something you have to figure out.

Take this condition:

String tail = originalName.substring(i).toLowerCase();
if (tail.startsWith("admin") || tail.startsWith("owner") || tail.startsWith("root")) {
    return true;
}

Looking at that code, we can of course derive its meaning. But only after mentally parsing each clause, hold the alternatives in working memory, and then reconstruct the intent. We probably did not read it and think:

so simple — this checks for reserved role names

That reconstruction friction is exactly what good refactoring should remove. Starting from code like:

User's avatar

Continue reading this post for free, courtesy of Adam Tornhill.

Or purchase a paid subscription.
© 2026 Adam Tornhill · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture