Why I Stopped Writing Clever Code

We rolled the change out behind a feature flag to five percent of traffic first. Nothing exploded, the error rate stayed flat, and the response times improved by roughly a third. After a week we turned it on for everyone and deleted the old code path.

What I would do differently

Accessibility is easiest when it is part of the design from the start rather than something you bolt on before launch. Semantic HTML does most of the heavy lifting for free, and the remaining work is usually about focus management and clear labels.

Most performance problems are not mysterious. They come from doing work you do not need to do, doing it more often than necessary, or doing it at the wrong moment. Once you start looking for those three patterns, you find them everywhere.

Documentation does not have to be long to be useful. A short note explaining why a decision was made is worth more than pages describing what the code already says. Future readers can work out the what; the why is the part that gets lost.

  • Measure the current state
  • Find the single biggest cost
  • Fix it and measure again
  • Stop when the result is good enough

A better approach

A good rule of thumb is to measure before you change anything. It is remarkable how often the part of the system you are sure is slow turns out to be fine, while something you never thought about is quietly eating half your budget.

The tempting fix was to add another condition and move on. We had done that before, and the code was already a thicket of special cases that nobody fully understood. This time we decided to step back and ask why the problem was possible in the first place.

  • A short summary of what changed
  • Why the change was needed
  • How it was tested
  • Anything the reviewer should look at closely

A quick checklist

Code is read far more often than it is written. Every shortcut that saves you five minutes today costs the next person who touches the file a little more time, and that next person is very often you, six months later, with no memory of why you did it.

Trade-offs worth knowing

The first version of anything you build will be wrong in ways you cannot predict. That is not a failure of planning; it is how learning works. The goal is to make those mistakes cheap to discover and cheap to fix.

It is worth remembering that every dependency you add is code you did not write but are now responsible for. Some are absolutely worth it. Others save an afternoon of work and cost a weekend of upgrades later.

None of this needs fancy tooling. A browser's developer tools, a terminal and a notebook to write down what you tried will get you surprisingly far. The discipline of recording each experiment matters more than the instruments you use.

  • Measure the current state
  • Find the single biggest cost
  • Fix it and measure again
  • Stop when the result is good enough
Notes from a pairing session
Benchmark results before and after the change

If you take only one thing from this post, let it be this: make the problem visible first. Logs, metrics, a simple counter on a dashboard. You cannot fix what you cannot see, and you will be amazed how many problems disappear once someone is watching them.

Posted in

jamie

Leave a Reply

Your email address will not be published. Required fields are marked *