Re: Should I use "if" or "try" (as a matter of speed)?



Edvard Majakari wrote:
"first make it work, then make it right, then make it fast"

Shouldn't one avoid doing it the wrong way from the very beginning? If you
make it "just work" the first time, you'll probably use the old code later on
because "functionality is already there" and temptatation to build on probably
relatively bad architecture can be too strong.

The expression describes (most recently, if not originally) the practice in Test-Driven Development (TDD) of making your code pass the test as quickly as possible, without worrying about how nice it is.


The "right" part doesn't refer to correctness, but to structure, style, readability, and all those other nice things that an automated test can't check. You aren't doing it "wrong" at first, just expediently.

And it really does make sense, because at that early stage, you aren't even absolutely certain that your test is entirely correct, so making your code a paragon of elegance is a potential waste of time, and distracting. Once you've been able to pass that test (and all the others, since you have to make sure all previous tests still pass as well), then and only then is it sensible -- and required! -- to refactor the code to make it elegant, concise, clean, etc.

Of course, your point about temptation is sound. Extreme Programming tries to avoid that problem partly by pairing programmers together, and it is the responsibility of both partners to encourage^H^H^H^H^H insist that the refactor "make it right" stage must occur _now_, before we check the code in. If you skip this step, you're failing to be an agile programmer, and your code base will become a tar pit even more quickly than it would in a traditional (non-agile) project...

-Peter
.



Relevant Pages

  • Re: Which book is better for a begainer to study C language?
    ... *_The C Programming Language_, 2nd edition, by Kernighan and Ritchie ... Avoid the book "Practical C Programming" from O'Reilly. ... Avoid any book by Herbert Schildt. ... Schildt and provides an errata, but the errata is very incomplete and ...
    (comp.lang.c)
  • Re: Series 5 Ratings
    ... hardly the first time I've made the point that Dr Who has never breen ... I don't even know what you mean by "a bust". ... and the ratings are just hyped up ... programming should consist of programmes with mass appeal, ...
    (rec.arts.drwho)
  • Re: an old geezer running visual studio for the first time
    ... closing rapidly the connetion again) and only change data by way of SQL ... > oriented design and programming. ... >> But when I ran VS.NET for the first time, I simply didn't know where to ... My reusable code (subs and functions) is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: mythomania is the opposite of what?
    ... dude is "stalking" you are quite off the deep end. ... It was not the first time, ... without even the benefit of increasing his discipline to avoid looking ... killfile is just a filter that locks out some of the boredom or ...
    (misc.writing)
  • Re: give me some tips
    ... avoid the use casts, except to ensure the type and precision of numerical ... avoid the use of type qualifiers, except ... because they can hide programming errors ... typedef structs and give them file scope, it can simply ...
    (comp.lang.c)