Deprecated Methods in Code Base

Posted by Jamie Taylor on Programmers See other posts from Programmers or by Jamie Taylor
Published on 2012-04-03T15:09:01Z Indexed on 2012/04/03 17:41 UTC
Read the original article Hit count: 319

A lot of the code I've been working on recently, both professionally (read: at work) and in other spheres (read: at home, for friends/family/etc, or NOT FOR WORK), has been worked on, redesigned and re-implemented several times - where possible/required. This has been in an effort to make things smaller, faster more efficient, better and closer to spec (when requirements have changed).

A down side to this is that I now have several code bases that have deprecated method blocks (and in some places small objects). I'm looking at making this code maintainable and easy to roll back on changes. I'm already using version control software in both instances, but I'm left wondering if there are any specific techniques that have been used by others for keeping the superseded methods without increasing the size of compiled outputs?

At the minute, I'm simply wrapping the old code in C style multi line comments.

Here's an example of what I mean (C style, psuedo-code):

void main ()
{
  //Do some work
  //Foo();  //Deprecated method call
  Bar();    //New method
}

/***** Deprecated code *****
/// Summary of Method
void Foo()
{
  //Do some work
}
***** Deprecated Code *****/

/// Summary of method
void Bar()
{
  //Do some work
}

I've added a C style example, simply because I'm more confident with the C style languages. I'm trying to put this question across as language agnostic (hence the tag), and would prefer language agnostic answers, if possible - since I see this question as more of a techniques and design question.

I'd like to keep the old methods and blocks for a bunch of reasons, chief amongst them being the ability to quickly restore an older working method in the case of some tests failing, or some unforeseen circumstance.

Is there a better way to do this (that multi line comments)? Are there any tools that will allow me to store these old methods in separate files? Is that even a good idea?

© Programmers or respective owner

Related posts about language-agnostic

Related posts about legacy