The Best Code Is the Code You Did Not Have to Write

by Eric Hanson, Backend Developer at Clean Systems Consulting

The Counter-Intuitive Optimization

Engineers are evaluated, rewarded, and promoted largely based on what they build. Pull requests merged. Features shipped. Services deployed. The incentive structure creates a strong association between "doing good work" and "writing code." This is mostly harmless and sometimes actively wrong.

The code you write has a cost that persists long after you've moved on to the next ticket: it has to be tested when it changes, debugged when it fails, understood by every developer who reads it, and maintained when dependencies shift. These costs are real and ongoing. The best possible outcome for any problem is solving it without incurring these costs at all.

This is not an argument for laziness. It is an argument for treating "no code" as a serious design option that gets evaluated first.

The Categories of Not Writing Code

Using what already exists: Before building a solution, audit what the codebase already provides. The most common form of unnecessary code is re-implementing something that already exists elsewhere in the project, in a dependency, or in the standard library. This sounds obvious and is surprisingly common. New engineers often don't know what the codebase provides. Senior engineers sometimes forget, or discount existing solutions because building feels more satisfying.

Buying instead of building: A third-party service or library that solves your problem is not a compromise — it's a trade of money or dependency risk for engineering time and ongoing maintenance cost. This calculation often favors the third-party option significantly. Building your own authentication system, payment processing, PDF generation, or email delivery is rarely the right choice. These are solved problems with mature solutions; the only thing custom code adds is surface area for bugs and maintenance burden.

Changing the requirement: Sometimes a requirement can be modified in a way that is acceptable to the product and eliminates a significant implementation. This requires asking questions instead of accepting requirements as fixed. "What if we made this weekly instead of real-time? What if users could opt in instead of opting out? What if we used a simpler approximation instead of an exact calculation?" Engineers who treat requirements as constraints to optimize against find these openings. Engineers who treat them as specifications to implement do not.

Deleting code that isn't needed: Unused features, deprecated endpoints still being maintained, dead code paths that haven't been triggered in a year — these are negative assets. They consume test suite time, cognitive load, and potential maintenance. Deleting code is one of the highest-leverage activities in a mature codebase and is systematically undervalued.

The Opportunity Cost of Every Line

Jeff Atwood's formulation is still useful: the best code is no code at all. Every line you write is a potential source of bugs, a maintenance burden, a cognitive tax on every reader. This doesn't mean don't write code. It means ask whether the code is necessary before writing it.

The question to ask before implementing anything: is there a way to solve this problem that doesn't require me to write and maintain new code? If yes, explore it. If no, proceed.

When This Principle Gets Misapplied

The failure mode is using "avoid writing code" as cover for cutting corners on things that genuinely need to be built. A proper authentication system, error handling that actually recovers from failures, data validation at API boundaries — these cannot be skipped. Skipping them produces a different category of problem: not unnecessary complexity, but missing correctness.

The principle applies to scope, not to quality. Don't write more than you need. But what you do write, write well.

The Practical Takeaway

Before starting any new feature or service, spend fifteen minutes asking: what is the minimum surface area of code that could solve this problem? Are there parts of this that an existing library, service, or simpler design could handle? Is there a modified version of the requirement that requires significantly less code and is still acceptable? The answer will sometimes be "no, we need to build it" — and that's fine. But the habit of asking prevents the slow accumulation of code that didn't need to exist.

Scale Your Backend - Need an Experienced Backend Developer?

We provide backend engineers who join your team as contractors to help build, improve, and scale your backend systems.

We focus on clean backend design, clear documentation, and systems that remain reliable as products grow. Our goal is to strengthen your team and deliver backend systems that are easy to operate and maintain.

We work from our own development environments and support teams across US, EU, and APAC timezones. Our workflow emphasizes documentation and asynchronous collaboration to keep development efficient and focused.

  • Production Backend Experience. Experience building and maintaining backend systems, APIs, and databases used in production.
  • Scalable Architecture. Design backend systems that stay reliable as your product and traffic grow.
  • Contractor Friendly. Flexible engagement for short projects, long-term support, or extra help during releases.
  • Focus on Backend Reliability. Improve API performance, database stability, and overall backend reliability.
  • Documentation-Driven Development. Development guided by clear documentation so teams stay aligned and work efficiently.
  • Domain-Driven Design. Design backend systems around real business processes and product needs.

Tell us about your project

Our offices

  • Copenhagen
    1 Carlsberg Gate
    1260, København, Denmark
  • Magelang
    12 Jalan Bligo
    56485, Magelang, Indonesia

More articles

From CRUD to Domain Logic: Why Backend Systems Need Better Architecture

CRUD operations are easy to understand, but real backend systems do much more. Handling business rules, events, and integrations requires thoughtful architecture.

Read more

Monitoring Is Not Optional. It Is How You Know Your App Is Alive.

A service without meaningful monitoring is a service you're flying blind on. You don't know if it's working, degrading, or failing — until a user tells you. That is not an acceptable operational posture.

Read more

Spring Boot API Security Hardening — Headers, Input Validation, and the Vulnerabilities That Slip Through

Authentication and authorization are necessary but not sufficient for API security. Mass assignment, excessive data exposure, injection vulnerabilities, and missing security headers are the gaps that survive code review and appear in penetration tests.

Read more

The Danger of Sending Code Straight to Production Without Oversight

Pushing code directly to production might seem fast, but it’s a ticking time bomb. Without proper oversight, even small changes can cause massive headaches.

Read more