Tuesday, June 8, 2010

why scrap working code?

This is probably just a naive question, so I'd genuinely appreciate anyone's critical response.  This just keeps coming to mind and I can't quite understand why everyone does things they way they do.

Suppose our program is doing something in a particular way.  It works OK, or it works most of the time, but we've figured out a way to make it work better, or work more of the time.  It seems like the standard thing to do is to replace:

try { old implementation }
except { fall flat on our face }


With:

try { new implementation }
except { fall flat on our face }


What occurs to me instead is:

try { new implementation }
except
{
    log that there's apparently a problem with the new implementation;
    try { old implementation } // we know this used to work!
    except { NOW fall flat on our face! }
}


What am I missing?  Why is code that used to be considered important and reliable constantly scrapped, to somewhere deep in a heap of old dead code that can only be resurrected by human intervention, just because we thought of something a little faster or broader or newer or cleverer?

Monday, June 7, 2010

a flexible case convention

There's all this contention and confusion about CamelCase vs mixedCase vs using_underscores, etc.  It just occurred to me that it would be easy enough to define a standard where those are interchangeable, so that a function defined as some_function could also be called as SomeFunction or someFunction or Some_Function or whatever makes you happy.  That would helpfully disallow some confusingly close pairs, make names easier to remember, and allow us to write each section of code in its own coherent style.