[Tutor] Here's something to talk about

Ricardo Aráoz ricaraoz at gmail.com
Fri Apr 17 01:32:01 CEST 2009

Weidner, Ronald wrote:
> One of your points represents a great opportunity to make mine.  Suppose
> this code is several years old.  Now we have a new requirement that 
> states we need to work with the data as you described above. How
> much of the existing code would you have to change to make that change 
> happen?  The answer is exactly one line.  And here is the line...
> exporter = SQLExporter("itemTable")
> And you would change the line to something like...
> exporter = SQLTupleExporter("itemTable")
> or perhaps...
> exporter = ExportItemToDatabase('', 'user', 'pass', 'schema')
> Of course, you would need to define a class to go along with your change
> but all of that will be NEW code.  Not a change to existing code.  So,
> all of your existing code should still be valid and tested.  The only
> thing you'll need to do validate and test your new code.
The question I usually make to myself is not how many lines of code do I
have to change. I'd rather think of how much of the code do I have to
read and understand before I know which lines to change, and how hard
will it be to understand it.
If I read just a few lines and then know I have to replace """exporter =
SQLExporter("itemTable")""" with """exporter =
SQLTupleExporter("itemTable")""" in a thousand places, that's ok with
me, the editor can handle this flawlessly in a few seconds. I'd rather
have simpler code that I can understand easily and modular enough that I
can find what to change without reading and understanding the whole thing.

More information about the Tutor mailing list