DevPinoy.org
A Filipino Developers Community

>>> First two to make 3 wins! <<<

Legacy Code

Our boss asked us developers for our preferred developer books and we submitted our wishlists, weeks later they ordered all 20+ of them, whoa! all the books that we wished for, nice!  I'm currently browsing through Michael Feathers' Working Effectively with Legacy Code.

So what is legacy code?  I overheard an officemate that one of our biggest projects was the best legacy code that he was assigned to, I thought to myself, is it really considered legacy code?  I've been a part of it in it's early stages so it kind of hurt me too since the adjective has a negative connotation.

Quoting the Preface from the book:

If you are at all like me, you think of tangled, unintelligible structure, code that you have to change but don't really understand. You think of sleepless nights trying to add in features that should be easy to add, and you think of demoralization, the sense that everyone on the team is so sick of a code base that it seems beyond care, the sort of code that you just wish would die. Part of you feels bad for even thinking about making it better. It seems unworthy of your efforts.

Ouch! Been there done that, cursed all the way (ako pa!).  But he later gave his own definition of legacy code as simply code without tests

Code without tests is bad code. It doesn't matter how well written it is; it doesn't matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don't know if our code is getting better or worse.

Truly agree!  But i disagree when my officemate said that "the project" is a legacy code.  It is the only .NET project here with enough unit/integration tests compared to all the others.  Maybe some are not well written tests but it's better than nothing.


Posted 05-23-2007 1:10 PM by jokiz
Filed under: ,

Comments

cruizer wrote re: Legacy Code
on 05-23-2007 1:37 AM

wow sarap! sayang di ko inabot... :)

jokiz wrote re: Legacy Code
on 05-23-2007 1:42 AM

alin boss?  inabot mo yung project na un ahhh

cruizer wrote re: Legacy Code
on 05-23-2007 1:59 AM

i mean yun books.

seriously yun project na yun was one of the most enjoyable i've had, thanks to TDD and CI :) namimiss ko na yun dito...hindi CI dito, at hindi rin TDD (here, "unit testing" means you test the code yourself, ha ha)

jokiz wrote re: Legacy Code
on 05-23-2007 2:34 AM

awww, ang slow ko grabeh... i agree, once you've worked in a tdd-ci environment, you wouldn't turn your back and do it the old way again (given the chances, meaning if you're not working in a bank, hehehe)

Jon Limjap wrote re: Legacy Code
on 05-24-2007 7:24 PM

Ako pala yung nagsabi ng best "legacy code" :P

As I explained, maybe the difference is in how I define legacy code. My definition goes like:

a) Code that was made by me more than 6 months ago (yes, that fast). Sometimes even code made by me more than a week ago because I easily forget things! :p

b) Code that was made by others, no matter how new.

The operative concept being intent: once you forget or don't know or understand or is confused by the intent of the code, it's legacy code.

However I would agree that, because the tests document the intent of the existing code, code that is covered by *good* tests can't really be considered legacy.


Copyright DevPinoy 2005-2008