DEV Community

Cover image for AI Writes What You Ask. Architecture Survives What You Didn’t Expect
Asmaa Almadhoun
Asmaa Almadhoun

Posted on

AI Writes What You Ask. Architecture Survives What You Didn’t Expect

Why Human Judgment Still Matters in the Age of AI‑Assisted Development

AI‑assisted coding tools have transformed modern software development. They can generate boilerplate, suggest patterns, and accelerate delivery.

Yet, as powerful as these tools are, they often fail in one critical dimension: design judgment. Being “smarter than AI” as a developer does not mean writing more complex code, it means designing systems that are resilient to ambiguity, change, and imperfect inputs.

One of the most common and painful examples of this gap appears in how systems handle unexpected variations, such as null, undefined, empty values, or missing parameters.

The Illusion of Correctness in AI‑Generated Code

AI tools typically optimize for expected behavior. They assume ideal inputs, clear contracts, and happy paths. This makes their output appear correct; until reality intervenes.

Consider your example:

If I do not send exactly null, the system crashes.

From a machine’s perspective, this may be “technically correct” code. From a human architect’s perspective, it is a design failure.

A well‑designed system should not collapse because:

  • null was replaced with undefined
  • a field was omitted
  • an empty string was passed
  • a client behaved slightly differently than expected

AI‑assisted implementations often miss these nuances because they replicate patterns rather than challenge assumptions.

Clean Architecture: Designing for Reality, Not Perfection

Robert C. Martin’s Clean Architecture: A Craftsman’s Guide to Software Structure and Design emphasizes an essential truth:

Software must be designed to survive change.

Clean Architecture teaches that systems should be:

  • Independent of frameworks
  • Independent of UI
  • Independent of databases
  • Independent of external agencies

Most importantly for your case, they should be independent of volatile input behaviour.

Why This Matters for Input Validation

In Clean Architecture, use cases define the rules of the application. That means they are responsible for deciding what is valid, acceptable, or recoverable, not controllers, not frameworks, and certainly not AI‑generated glue code.

If your system crashes because a parameter is missing or slightly different, that logic is living in the wrong place, or not living anywhere at all.

The Core Problem: Treating Inputs as Objects, Not Concepts

AI tends to treat input values literally:

null ≠ undefined ≠ empty ≠ missing

Humans, however, think conceptually:

“This value means ‘no data provided.’”

Clean Architecture encourages us to elevate that intent into the core of the system. Instead of spreading defensive checks everywhere, we define semantic boundaries:

  • What does “absence” mean?
  • Is this field required, optional, or conditional?
  • What is the default behavior if it’s missing?

If those questions are not answered explicitly, AI has no chance of answering them correctly.

Being Smarter Than AI: Design Principles That Matter

1. Normalize at the Boundaries

AI often mirrors whatever structure it sees. A human architect knows better.
At system boundaries (APIs, controllers, adapters), normalize inputs into a single internal representation. By the time data reaches your business rules, there should be one concept of “no value,” not five.

This aligns directly with Clean Architecture’s rule of keeping frameworks and details at the edges.

2. Move Validation into Use Cases

AI‑generated code frequently validates inputs close to the framework layer. This is convenient and wrong.
Clean Architecture insists that:

  • Business rules own validation
  • Use cases decide what is acceptable
  • Frameworks merely pass data along

When validation lives in use cases, handling null, missing, or empty values becomes a business decision, not a technical accident.

3. Define Explicit Contracts, Not Implicit Expectations

AI excels at following patterns, but struggles with unstated intent.
Clean Architecture favors:

  • Explicit input models
  • Clear invariants
  • Defined failure modes

If your system crashes when a value is not exactly null, it means the contract was never truly defined, only assumed.
Humans write contracts. AI follows them.

4. Design for Change, Not Compliance

AI optimizes for compliance with existing code. Humans optimize for change.
Your API may work today because clients send perfect inputs. Tomorrow:

  • a mobile app changes
  • a third‑party integration behaves differently
  • a serialization library updates its defaults

Clean Architecture prepares systems for that variability by isolating change and enforcing rules at the core.

Conclusion: Intelligence Is in the Architecture, being smarter than AI is not about rejecting AI tools, it’s about using them responsibly.
Let AI:

  • write repetitive code
  • scaffold structures
  • speed up implementation

Let humans:

  • efine boundaries
  • clarify intent
  • design for ambiguity
  • enforce architectural discipline

Clean Architecture provides the mental model that AI lacks: a focus on meaning, responsibility, and change. When your system gracefully handles null, undefined, empty, and missing values, not because of defensive hacks, but because of intentional design you are operating at a level AI has not yet reached.
And that is what real software craftsmanship looks like.

Reference

Robert C. Martin, Clean Architecture: A Craftsman’s Guide to Software Structure and Design, 2017.

Top comments (0)