3 ms·
> they removed all the legacy code they haven't understood. This is exactly why rewrites or huge refactors typically fail. The new programmer sees code and doe
by matwood 7y ago
> they removed all the legacy code they haven't understood.
This is exactly why rewrites or huge refactors typically fail. The new programmer sees code and doesn't understand why the code is there and thinks the last programmer was an idiot and deletes said code. Unknown to the new programmer is that code handles some weird edge case.
A rewrite should spend 80% of the time understanding the old code and 20% writing the new. But, that's no fun for most programmers who just want to code in the latest shiny so the new code ends up broken.
- atoav 7y agoWhich is why it is sometimes crucial to add comments to your code. I know certain code basically documents itself, but that depends on the person who reads it. In my eyes it is precisely edge cases that might or might not be known that profit from decent explainatory comments. As a avid writer of comments I am convinced they also help myself, to form thoughts and remember them later, so at times I will write the comments before writing an actual function. If that is to bold, commenting while the thing is still in your head makes sense anyways — saves you time later and helps everybody else who will look at your code.
- matwood 7y agoI agree. I also use git blame and track down when and why code was added. But this is tedious work that I find many people don't like to do for some reason. Me, I like the investigative work of tracking something down.
- Endy 7y agoI also personally believe in, and this isn't just for code, but for any project you'll pass to another, a connected read.me file explaining the high-level reasonings and other thoughts, including a personal changelog and roadmap, and some instructions for use and editing.
- dirkf 7y agoAnd please write proper commit messages! A short summary, preferably including a hint at which subsystem is impacted by the change. Then explain in detail the context of the change: root cause of a bug and the gist of the solution, use case(s) behind a new feature and how it can be used, ... Yes, often there's a bug/project tracking tool being used and the commit message contains a reference to the relevant entry there. But from experience I know these tools tend to change: old one gets decommissioned, data gets migrated, what was once the primary identifier is now a mere field or comment in the new system, access rights get messed up, ... Trying to understand the history then turns into an archeological expedition through various eras long gone... unless the commit messages are sufficiently self-containing.
- BlueTemplar 7y agoThe issue seems to be that that tracking tool does not have its data backed up in the version control system?
- JoshuaDavid 7y agoThis seems like it could be mitigated with an integration that watches the issue tracker for updates and then commits those updates to a docs folder on the appropriate branch of the appropriate repo. This would have saved quite a bit of headache at my last job actually.
- BlueTemplar 7y agoOr just use a version control system with issue tracker support, like Fossil ?
- JoshuaDavid 7y agoSwitching an existing project to a new VCS loses history or at minimum causes a new layer of "identifiers in the old system don't match the new one", no? In general, I've found value in figuring out how to improve existing systems where feasible rather than trying to migrate to a new system, since the existing system probably has advantages the new one won't. At minimum, people are already familiar with the existing system.
- ak39 7y agohttps://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence "Chesterton's fence is the principle that reforms should not be made until the reasoning behind the existing state of affairs is understood. The quotation is from G. K. Chesterton's 1929 book The Thing, in the chapter entitled "The Drift from Domesticity": In the matter of reforming things, as distinct from deforming them, there is one plain and simple principle; a principle which will probably be called a paradox. There exists in such a case a certain institution or law; let us say, for the sake of simplicity, a fence or gate erected across a road. The more modern type of reformer goes gaily up to it and says, "I don't see the use of this; let us clear it away." To which the more intelligent type of reformer will do well to answer: "If you don't see the use of it, I certainly won't let you clear it away. Go away and think. Then, when you can come back and tell me that you do see the use of it, I may allow you to destroy it."
- mumblemumble 7y agoI've taken part in a "rewrite" like what you describe. It was not the classic "Write a whole new system in parallel, then migrate everyone over." It was the Ship of Theseus executed in software, slowly, over the course of a couple years. The lights stayed on the whole time. We retained the ability to switch back to the old system by setting a feature flag until everyone (including the business users) was confident that the new system was working as well as - preferably better than - the old one. Throwing out code we didn't understand was simply unthinkable, because we weren't allowed to have that 6 months of time fantasizing that everything would be great before launch day - whatever you were working on now would be expected to go into production within a week or two, without upsetting the rest of the business in the process. No, it wasn't very fun. But it was satisfying work. I think it was my boss's boss who observed that making all the team members happy won't make a project successful, but everyone's ultimately happy to see a project successfully executed.