Leaving a Legacy
What are your first five results when you Google "Legacy Code" ^1 ^2 ^3 ^4 ^5? For me, my results are surprisingly gentle: code that was developed using old methods, tools, or systems. Most talk about how hard legacy code is to work with. A few of them do mention how the blame falls on the developers writing bad code. I guess that is partially the effect of time, but I don't want that to be my legacy.
Legacy: "something transmitted by or received from an ancestor or predecessor or from the past" ^6
As I get older, I think more and more about what I'm going to leave behind. I'm so proud of my family and how I was able to build it with an amazing partner. I'm looking forward to giving my kids all of the prosperity I've built. But professionally, the majority of what I'm leaving behind is the code that I write.
You should read "We, Programmers" by Robert C. Martin because, guess what? Presumably, since you're reading this, you are part of the same lineage of computer scientists that are in that book. As a computer scientist, I'm part of it too. As with any legacy, there are good parts and bad parts. But one thing which shouldn't change is our investment in creating a Legacy that our successors will be proud to inherit.
Imagine the the nicest code you've seen. Now imagine the worst code you've seen. The visceral reaction I have when I think of the two extremes makes me need to sit a moment. I know exactly what I want to leave behind.
Some of the best and worst code I've seen was written by me. To be clear- code written by young computer scientists is not the same thing as "legacy code". Coming to view things you did previously as inferior is, in fact, the way it should be. Learning is vital to your success as a computer scientist (we have other problems if you never think of your old code as bad). Be gentle with your younger self, you're worth it.
The negative connotations of Legacy Code as garbage that no one cares about nor cared about while building is damaging. Is there really no room for leaving a good legacy? And why should I be "stuck" with a Legacy when I should be proud to continue it? I think it's high time we add to the story and reclaim our legacy as computer scientists.
"It is the single greatest indictment of the software industry, the most obvious evidence of our failure as professionals, that we make things worse with time. The fact that we developers expect our systems to get messier, cruftier, and more brittle and fragile with time is, perhaps, the most irresponsible attitude possible."
Uncle Bob [1]
Legacy code can be code that we're proud of. It can be clean and beautiful. It can be performant and useful. It can be powerful and transformative. From now on, that's what I mean when I say legacy code. And from now on, I'm going to always keep in mind that everything I write is, in fact, Legacy Code.
[1] R. C. Martin, Clean Agile : back to basics. Boston: Pearson, 2020.
Message
