[Tutor] Contents of Tutor digest Vol 86 Issue 57

Steven D'Aprano steve at pearwood.info
Sun Apr 17 04:09:24 CEST 2011


Lea Parker wrote:
> Hi  Michael Scott
> 
> Thank you and yes I agree there is room for user error. I am going to add a
> validator but I wanted to get the first part right. I appreciate your
> comment on the white space too.
> 
> Being a beginner I find it easier to write the main thing I want the code to
> do and then add extra to make it work efficiently. Perhaps not what a
> programmer does but it helps me this way.

No, that's a perfectly acceptable way of programming. In fact, it's the 
best way:

Make it work. Make it correct. Then make it fast.

http://en.wikipedia.org/wiki/Program_optimization#Quotes


You can't imagine how much time and effort has been wasted by people 
trying to optimize broken code, so that code that does the wrong thing 
does it really, really quickly. It's a macho thing (no offense to 
Michael): many programmers like to think of themselves as "top guns" 
writing the fastest, tightest code imaginable, but writing *correct* 
code is tedious, hard work. It's *easy* to time how fast code runs 
(although very tricky to *accurately* time how fast it runs), but quite 
difficult to test code for correctness. In one of my projects, I have 
approximately three lines of test code checking correctness for every 
line of code to do the work, and I consider that barely adequate to be 
confident that my code contains no *obvious* errors.

(By the way, when replying to a Digest, could you please change the 
subject line to something more sensible?)



-- 
Steven


More information about the Tutor mailing list