The system you inherited and cannot stop
Almost everything in this course has been written as though you get to design the system. Most of your career will be spent on one that already exists, that nobody currently on the team designed, that has no documentation and no tests worth the name, and that is processing revenue while you read the code. It is the most common senior situation and the least taught, so here is how to be effective in it.
Start by discarding the instinct. The first honest feeling on reading an inherited system is that it is bad and should be rewritten. That feeling is not evidence. You are comparing a real system — carrying five years of requirements, bug fixes, regulatory patches and edge cases that cost somebody a weekend — against an imagined one that has met no users yet. That comparison is unfair by construction, and it is why rewrites are attempted so often and completed so rarely.
Read the system, not the code
Code tells you what happens. It does not tell you what matters, and reading it front to back is the slowest possible way in. Better sources, roughly in order of value per hour:
- Production traffic. Which endpoints actually get called, and how often? A surprisingly large fraction of any mature codebase is dead, and knowing which parts are is the highest-leverage fact you can hold. Instrument before you assume.
- The incident history. Postmortems and old pages tell you where the system is genuinely fragile — which is almost never where it is ugliest. Lesson 9.09 called this the densest onboarding material a team has, and it meant it.
- The schema. The data model is the most honest description of the domain that exists, because unlike the code and the diagrams it could not drift without breaking something.
- Version control archaeology. The commit that added the strange condition usually names a ticket, and the ticket usually names an outage. That is Chesterton's fence, answered.
Write down what you learn as you go, publicly. An inherited system has no map, and the person best placed to draw one is whoever is confused most recently.
Build the safety net before you touch anything
You cannot refactor what you cannot verify, and the tests you wish existed do not. The move is not to write unit tests for code you do not yet understand — it is to pin the behaviour from outside:
- Characterisation tests. Record what the system currently does for real inputs and assert that it keeps doing exactly that, including the parts that look wrong. You are not encoding correctness, you are encoding current behaviour, because current behaviour is what your users depend on and what someone downstream has already worked around.
- Shadow comparison. Lesson 14.03's tool, and it is even more valuable here: run the new path alongside the old on live traffic, log every disagreement, change nothing. The diffs teach you the requirements nobody wrote down, at production fidelity, at zero risk.
- Observability first. Adding metrics and traces to an unfamiliar system is the cheapest change you can make, it is nearly risk-free, and it converts "I think this is the slow part" into a fact. Do it before the first refactor, not after.
Change it without stopping it
The rewrite is almost always the wrong shape, for a reason worth naming precisely: it demands that you freeze the old system's requirements for as long as the rewrite takes, and the business will not do that. So you spend eighteen months chasing a moving target with two systems to maintain and nothing shipped.
The pattern that works is the strangler, and you already have all its parts. Put a seam in front of the system — a facade, a proxy, a routing layer. Move one capability at a time behind it, chosen by value rather than by ugliness. Route a fraction of traffic, compare, then increase. Delete the old path as soon as the new one is trusted, because two live implementations is the state you are trying to leave, not arrive at. Each step ships, each step is reversible, and if the programme is cancelled after four months you keep everything you have done. Lesson 5.05 argued this for splitting monoliths; it is the same machine pointed at inherited code.
And keep a real ledger of what you are not fixing. Not a backlog of "clean this up" tickets that will never be prioritised — a short, honest list of the specific risks, each with the failure it would cause, so that when someone asks for a date on a feature that touches the worst part of the system, the conversation is about a named risk rather than a vague sense that this area is scary.
The system is a social artifact too
Somebody wrote this, and they may still be in the building. How you talk about inherited code in your first month determines how much help you get for the rest of the year, and the person who can explain why the reconciliation job runs at 4am is worth more than a week of reading. Conway's law (14.05) also runs backwards: the shape you inherited was produced by an org chart that may or may not still exist, and boundaries that look arbitrary are frequently the fossil of a team that was reorganised away.
Proposing the rewrite in your first month. It is the moment you have maximum confidence and minimum information, which is precisely the wrong combination, and it costs you credibility with the people who have been keeping the thing alive. The strong version of this move is inverted: spend the first month making the existing system observable and shipping two small visible improvements. You will have earned the standing to propose something large, and — this is the part that surprises people — you will usually no longer want to, because by then you will know which twenty percent of the system is actually causing the pain, and it is never the twenty percent you would have guessed.