"Why did you write that in 250 lines of hard to follow C++?"
"Because I know it'll be too slow if I write it in language X."
I had a conversation along these lines recently. Even if you are
guaranteed to eventually do a rewrite in ugly C++, rewriting in ugly C++ is a
lot faster than writing ugly C++. Throwing away a program does not
mean you've wasted your time.
This is hardly a revolutionary insight. Yet I constantly run into folks who think the primary goal is to get a first draft of the program with the minimum number of keystrokes. If that's the goal, don't bother writing anything, because an empty text file is the minimum number of keystrokes when incorrect output is okay. Your initial goal has to be writing something and being confident - for your own personal definition of that term - that it does what it is supposed to do. The only question that is relevant while writing your program is, "If I gave my program and tests to someone else, would he be confident that my program is doing what I claim?"
Not only is it faster to rewrite in ugly C++ than to write ugly C++, maintenance and changes are also much less costly when you have an elegant version that does the same thing as the ugly version. Testing amounts to little more than checking that the elegant and the ugly versions both give the same output.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment