Hi, this might not be stricly related,

Hi, this might not be stricly related, but I’m sure we’ve all experienced failure at the result of legacy code. My colleague and I are soon to do a short presentation on living with and dealing with legacy code. We’d really appreciate it if you might give you opinion on the questions in the linked article. Please answer even on Google+ comments or the comments in the article (Disqus). Thanks Dan and Leon

There are some thoughts and some links on c2, the original wiki:

Thanks great link. what do you consider to be legacy code? Can you consider code with tests legacy code.

For me, legacy means some form of abandonment: whether the original team is gone, the language is dead or the original platform survives only in emulation - maybe several layers of emulation:

Adding tests after abandonment is placing a ladder into the hole: is the ladder long enough to get you out? If writing the tests causes you to rebuild a team which understands the code, you are perhaps out of the hole. If the code remains a black box, not so much.

Legacy code = “I didn’t write it and I therefore don’t want to accept the blame” :wink:

Amazing story on the link. Would you say code therefore is about communication and understanding?

What do you think we can do to help convey understanding to those who next have to maintain the code we write.

Are tests enough? Is a “if it ain’t broke don’t fix it” emulation approach sensible when no-one knows the language or the OS is dead?

@Peter_Olson that sounds like not invented here syndrome. What can we do to make it so others don’t instantly want to through our code away? Write more tests, or if it’s simple enough will people more understanding?

Certainly source code is about communication! Comments, and design documents, are both valuable when done well. The code itself could also be more or less obscure, depending on whether it was written to be understood. “Literate Programming” is one approach. See also http://stackoverflow.com/questions/2545136/is-literate-programming-dead

Just seen this on LWN: “Comments in XFS, especially weird scary ones, are rarely wrong. Some of them might have been there for close on 20 years, but they are our documentation for all the weird, scary stuff that XFS does. I rely on them being correct, so it’s something I always pay attention to during code review. IOWs, When we add, modify or remove something weird and scary, the comments are updated appropriately so we’ll know why the code is doing something weird and scary in another 20 years time.”

@EdS and @Peter_Olson just thought I’d say thanks for all your input, we featured you in our little talk on legacy code :slight_smile: http://youtu.be/oUsrN-3AyI8