Healthy codebases are always in motion. Legacy code eventually goes down with the ship, and recognizing that my code is transient lets me be more practical about what I write and why.

Two forces behind every code change

Code changes tend to stem from one of two causes: code decay or website relevance.

Code decay

Our code follows specifications from authorities like web browsers or frameworks, and sometimes requirements from the business the site serves. All of these rules shift as sites and their contexts evolve. When browsers adopt an HTML spec, our markup can become more semantic; when we use a framework, we may want to move to its latest major version. A business may change payment providers, or a new security requirement may land. Sometimes old code survives untouched for long stretches, but eventually it must be changed or disposed of.

Website relevance

Our site is not as cool as it used to be. The design has aged, or what it does matters less to people than before. Maybe a new feature is required, or maybe we are just tired of looking at it. Redesign, rebrand, iterate. Most websites cannot stay relevant without significant changes to content or code over time, and we should expect the same of the code itself — especially on the front end.

Assume the stay is brief

Acknowledging change sounds obvious, but it is a useful reminder for anyone inclined to code as if building the Great Pyramid of Giza. Coding is more often like setting up camp, not knowing whether we will stay for a few days or a year. I try to start from the assumption that it will be brief and settle in over time — buy some overpriced water at the store before digging an entire well. Code I wrote a few months ago already needs to change, not because it was done badly the first time, but because it is simply time. A few practices follow from that.

Write transient code

Knowing the code may change soon keeps me focused on its current purpose and on isolating its footprint, instead of being distracted by possible future timelines. For large projects, apply the principle to pieces of the codebase: a component used in a library for a full year has often seen its requirements change. Clearing out the cruft of the past gives it purpose for the near future. Writing a replacement component is frequently faster than updating an old one, and the result is easier to use and understand. Where applicable, replace instead of rehabilitate. New work prioritizes the present, trusting that future problems get solved later — when you are closer to the problem, you tend to have more facts and fewer assumptions.

Avoid dependencies where you can

I increasingly gravitate toward built-in browser functionality and set a high bar for justifying a framework. At certain scales dependencies are unavoidable and often more efficient in collaborative settings. When I do use them, I isolate or wrap their functionality so it is easier to untangle later. If writing your own code is worth the effort, you become more familiar with web specifications and learn how robust they are on their own. The result can also be easier to maintain long term, because it sits closest to the core evolutionary path of the web — there is no dependency upgrade between your code and ever-evolving browser functionality.

Let the code die

This only works where nothing important — usability, say — requires change, but it is my favorite outcome when it fits. Let things get old and do not plan to update them; creative projects and demos suit this well. Letting an old project die acknowledges that its value was tied to the moment it existed in. Not everything needs to last forever — nothing we make will. If something is important enough to preserve, capture its meaningfulness through screen recordings and documentation, then move on. That frees me to proceed to the next thing.

Lower the stakes

Reflecting on the transience of code is the most meditative and rejuvenating thing I do as someone who writes code. Discussions of tooling, best practices and the new hot thing so often turn combative. The urgency to adopt the "best" approach puts immense pressure on project planning; we speak in absolutes with an air of permanence and overlook how dated our opinions will sound soon. The stakes are ultimately never as high as they feel when you are deciding on tooling.

I prefer to keep recognizing that the code I write is temporary, that technology grows faster than I can match pace, and that I will never need expertise in all things. There I find comfort: the best code I write is in front of me, and the best website I can make right now is the next one.