list/tuple to dict...

Roy Smith roy at panix.com
Thu Sep 16 15:30:11 CEST 2004


aleaxit at yahoo.com (Alex Martelli) wrote:
> Copy and paste is a BAD way to reuse software.  Very, very bad.  Anybody
> with the least experience maintaining big programs will confirm.

Absolutely agree.

A while ago, I was working on a piece of code written by somebody who 
didn't believe in this.  I found a bug and fixed it.  Sometime later, we 
realized the fix was wrong and I went back to make an additional change.

I was surprised when the file I was looking at appeared to be the 
original code.  Where had my first change gone?  We spent an afternoon 
looking through CVS logs, getting ourselves more and more convinced that 
CVS had somehow messed up.

It turns out, the fix I made was in a huge function (100's of lines) 
which somebody had cut-and-pasted to make three versions which did 
almost identical things.  And then they gave the functions almost 
identical names, along the lines of:

sendMessageToServerWithAlertCondition ()
sendMessageToServerWithErrorCondition ()
sendMessageToServerWithOtherCondition ()

So, yeah, Alex is right.  Don't do that.



More information about the Python-list mailing list