Click here to Skip to main content
13,301,100 members (82,238 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 1 Dec 2010

Maintenance and Updating of Legacy Code

, 9 Mar 2011
Rate this:
Please Sign up or sign in to vote.
A collection of tips to help you maintain your legacy code more efficiently


Most developers get saddled with maintaining or updating legacy source code at some point in their career. This is a list of tips that may help you out in such situations.


This compilation is based on advice received from several CodeProject members, as well as my own experiences. Those interested may view the original thread here.
(Note: I accept no responsibility for changes that may occur there after this tip is published.)


  • Have the original code checked into source control. If you've just received say, a zip file containing everything, create a repository yourself and check it in. Even if your organization provides no such facility, there are plenty of free version control systems available.
  • Read the documentation if available.
  • Make sure you are clear on how much functionality can be changed, and how much should remain as is. This is especially important if your changes will affect other developers or tech writers.
  • Find out how many resources may be put into the code, and how long it is planned to be maintained. The effort worth putting into it will depend on these factors.

Preliminary Testing

  • This may not be feasible in some cases, but execute the code and make sure you get a general idea of how it operates. This will help you notice whether you broke anything.
  • Test functionality that you plan to change before making any changes.
  • If possible, write unit tests for the parts that you plan to change.


  • Make sure you know what the code does before you attempt any modifications, don't just jump in.
  • Read existing comments and any other documentation / help files.
  • Identify the core problems, isolate and study them before replacing the code.


  • Do the actual changes. Check changes into source control regularly.
  • Do not modify legacy code more than necessary to implement new features.
  • Cleaning up and optimizing are dangerous, you will break things in unexpected places (believe me, I've been there many times).
  • Do clean up parts that will make further future updates simpler, the caveat being that you shouldn't put more effort into the cleaning up itself than expected time savings in future.


  • Comment all your changes, making sure future developers can figure out what you modified.
  • Set up a wiki if you think that will help, with links to the source code.

Final Testing

  • Test your modifications. Make sure existing functionality is not broken by your changes.
  • If you created unit tests in the previous step, run them now and confirm that they pass.

Points to Consider

  • Perform regular check-ins, you will be thankful if you break something and have to backtrack. If your company policy forbids checking in of non-working source code, consider setting up your own private repository or branch.
  • Do not mix coding conventions, use the same style used within each file (unless specifically instructed not to).
  • Split any enormous classes, making them partial and moving the new code to a new file.
  • Like with any coding, follow good coding practices, even if the existing source is messed up.
  • Do not make any derogatory comments about the existing code or the previous coder.


I hope this has helped you at least a little in your code maintenance tasks. This is by no means an exhaustive list, please feel free to add comments and suggestions at the bottom, and point out any mistakes I may have made.


Thanks to everyone who contributed their wisdom in response to my question in the Lounge (Apologies for not mentioning everyone by name directly).

Revision History

  • 2010-12-01 First edition


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Japan Japan
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralRe: Yeah, you can use headings like <h3> BTW you welcome Pin
thatraja2-Mar-11 17:34
mvpthatraja2-Mar-11 17:34 
GeneralReason for my vote of 5 Good one Indi. Pin
thatraja2-Mar-11 13:01
mvpthatraja2-Mar-11 13:01 
GeneralRe: Hey, thanks! You made me notice that the formatting has go... Pin
Indivara2-Mar-11 17:22
subeditorIndivara2-Mar-11 17:22 
GeneralThanks for the comment. I'll incorporate this into the tip l... Pin
Indivara6-Dec-10 18:49
subeditorIndivara6-Dec-10 18:49 
GeneralThanks for the nice article. Some additional thoughts :- One... Pin
NirdeshSaini6-Dec-10 17:46
memberNirdeshSaini6-Dec-10 17:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 9 Mar 2011
Article Copyright 2010 by Indivara
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid