"Legacy code" is often code that you want to replace because you don't understand it. The problem is, before you can replace it, you need to understand it, and, once you understand it, replacing it is rarely the cheapest option any more.
"Legacy code" is often code that you want to replace because you don't understand it. The problem is, before you can replace it, you need to understand it, and, once you understand it, replacing it is rarely the cheapest option any more.
On occasion, you open up legacy code and discover the backdoor that an overseas contractor buried in some obscure corner.
Foiling a hack, ransomware, & a lawsuit settlement rarely gets the public acknowledgement that it should.
Most senior managers slap an NDA on it and memory hole it as quickly as possible.
Then stick you with the task of shadowing all code commits as punishment. Lol.
@n_dimension @jbqueru There's an excellent bit of wisdom in “Do not remove a fence until you know why it was put up in the first place.”
It's so apt for fences, legacy code, and regulations. None of these things spring up just for fun, yet too often there is a rush to discount the blood, sweat, and tears that went into them because the problem that they're alleviating is no longer apparent.
Kinda obliquely related.
But it's such a sweet story, and it was well conveyed by Peter Jurasik, that I retell it whenever the slightest excuse arises.
Lando Mollari, an imperial Ambassador of the ancient and failing star Centari empire in "Babylon 5", tells a parable.
Of a child princess, who saw a tiny, pretty flower spring from between the stones of the parade ground.
Fearing it would get trampled by the troops, she placed a soldier to stand guard over the flower.
Years have passed.
The flower is long gone.
The princess is long gone.
The guard still stands there, in what seems to be a random spot on this huge parade square.
You can choose to look at it as a tale of bloody mindedness.
I, like Lando, think it's a beautiful tale of how purpose and order still prevails long after the need had gone.
@n_dimension @dotjayne @jbqueru lovely.
Of course in IT we have a workaround as such. it's not pretty. I've generally heard it called "see who screams".
That is, in a working system, if the gate (or the guard) is of use, someone will probably notice if it is removed and tell you why it was needed; if so, you can put it back.
In my experience this works well about 70% of the time. The other 30% of the time it's a ticking timebomb…
@fishidwardrobe @dotjayne @jbqueru
Counterpoint:
I think it was Knuth who said "If houses were built the way programmers code, the first woodpecker would collapse the civilisation"
A case in point to reinforce the non-destructive approach the Chestertons Gate...
...maybe just rename to OLD_ChestertonsGate.Production 😁
@jbqueru @fishidwardrobe @dotjayne
...and you get to look like a hero for "restoring" the service.
😁
@fishidwardrobe @n_dimension @dotjayne As a leader, I've internalized that my job mostly involves making choices between options I don't like, in situations where there's not enough information. I don't get to say that we shouldn't have ended up in such a bad situation.
A scream test is a great way to clarify how much I should dislike deleting that code, to gather information that allows me to move forward. So, I love them.
@jbqueru @fishidwardrobe @dotjayne
"Scream Tests, a more exciting alternative to boring documentation"
~ Wulfy
@jbqueru @ireneista sometimes, though, understanding can only harden your determination that the legacy code must die.
like a custom build "system" for a java project written in a clusterfuck of perl scripts. porting to java required understanding, but the result was a couple of orders of magnitude faster. then replacing the whole damn thing with gradle
@jbqueru @ireneista of course the person who perpetrated the original went on to make a custom build “system" for the next big java project in a clusterfuck of python scripts instead.
replaced that with gradle too, then retired early, a crumbling cinder of my former self.
@sleepyfox @jbqueru @flyingsaceur I also have fond memories of that workshop. 😁
And I agree that “code without tests” is an interesting category of legacy code, but not even close to all of it. I have seen so much code with comprehensive test suites that was full of bugs and completely unmaintainable.
@jbqueru I find Claude does a pretty good job of code explaining
Problem ofc is that most employers' code is NDA & not OK to paste into an AI
@womble I don't think you've designed many neural networks in your life.
From Papert to Hinton to Krizhevsky to Lecun, not one of their (breathtaking and brilliant) papers have to do with "bullshit".
@lerxst Exactly. It fought a battle, and it survived. Even if some of those fixes are now unnecessary and you have no way to determine that, maintaining those fixes is less costly than having to re-build all the non-obvious fixes that are still necessary.
Worse, if you rush a re-implementation, you're at risk of having something worse than what you're replacing.
@squads
It's more subtle than that usually. Typically, the clients are convinced they do understand the legacy code, but in fact they don't.
Usually a new generation of devs doesn't want to touch the legacy, and a prior generation is too overworked to explain all the intricate workarounds and existing processes that keep the whole mess (sort of) functional.
Almost always there are no clear repeatable regression tests (anymore).
Solving that first surfaces the real challenges.
@squads
Diving into a legacy code base of a company above a certain size and age is one of the most painful things we as developers have to endure regularly. The easy way out (for us) is to just start from scratch, but this is almost never the best option for the shareholders of said company.
That's why we charge so much money to do this dirty job: it's actually worth it.
And some very lucky few of us, the menders of our trade, we actually enjoy the pain of working with legacy 🤣
@jbqueru Read it, understand it, model it, implement it.
Hope your modeling method can withstand the test of time.
Attached: 1 image Did you know that there is plenty of UML in the low-code world? (even if it's never acknowledged, I guess due to the bad press UML has and to better justify the "innovation" of the low-code tool by selling it comes with its own languages) 👇👇 https://modeling-languages.com/there-is-a-lot-of-uml-in-low-code/ #uml #dsl #lowcode #language #codegeneration #modeldriven
@jbqueru I often do a thing where I mentally replace the word "legacy" with "successful" in these instances.
Because even if the code is old and gross, the bottom line is that it's apparently been around long enough to do whatever it was asked to do.
@jbqueru When I've replaced legacy code, half the time I should have fixed it instead; and when I've fixed legacy code, half the time I should have replaced it. (In both cases, adding tests of course).
If I had made the opposite decisions, I probably would have concluded that I was mistaken the same 50-50.
Bad code is like a cancer - all remedies are bad and it's a matter of guessing the least bad cure. (And the author of the bad code probably got promoted before the effects of that code manifested.)
PS: bad design is even more problematic.