Your Legacy Is Not Mine

When I say "legacy code" what year do you think of?  Is there a specific pattern or practice that you remember and hate?  Is there a specific version of a language, framework or server that you can't stand?  Perhaps "legacy" just means other people's code.  Perhaps you have been lucky enough to only do greenfield development in your career so far.

Is "legacy" not bad word to you? Perhaps you work on a system that has "good bones". Each day you start work and find useful refactors that make things better but don't break all the tests.  You have good test coverage and a database that is performing well. 

That is not always the case. How would you handle working on a platform that needs patched, is complicated, obfuscated, horrible to maintain, has been around since the 80's or 90's?

It's not easy. You want to quit every day. You can't code good enough or fast enough to make anyone happy. Any success only lasts a few days. You might make one thing better one day only to find it broke something else.

Static code analysis will show hundreds or thousands of bugs, duplications and code smells. Your refactoring of the code might be limited by the framework or tools so you can't get rid of them all, so you don't try. You can't go changing that much code anyway because there isn't automated regression testing.  

Legacy code often comes with documentation, it's what we did back then. The problem with that is... we never tested documentation back then.  So the documentation is probably wrong or incomplete.

So how do you deal with legacy code?

Don't make it your legacy. Your legacy can be to replace it. Look deep for the good ideas. Steer clear of all the bad ideas and learn from it.  You have 10, 20, 30 years of knowledge at your finger tips right now.  If you have only been a developer at the company for 3 months, the code gives you a huge head start.

It will be rough.  You might not be given the time or budget to replace it.  You might have other developers fighting you because they don't want to do better.  You don't have their job security, define your own legacy.

This crappy code base is their legacy not mine.



Popular posts from this blog

Special Characters are Truly Special

JavaScript should be your favorite language

.NET Maui and VS Code