-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2005.12.22 14:06, Steve Litt <slitt@earthlink.net> wrote:
> On Wednesday 21 December 2005 07:20 pm, Eero Saynatkari wrote:
> > Joe Van Dyk wrote:
> > > I've found that when I write the tests first, and then write
> > > the code, I'm not very concerned about what the code looks
> > > like. When the code passes the test, I drink a beer and party,
> > > then move on to the next test.
> > >
> > > In practice, this means that I'm using a lot of ugly regex's,
> > > poorly named variables, and so on. I'd be more concerned about
> > > the readability of the code if there wasn't unit tests behind
> > > it. I'm generally in a rush to finish whatever I'm doing, and
> > > figure that since I have a bunch of tests, refactoring stuff
> > > later won't be a big deal.
> > >
> > > Anyone else out there like me? Or should I be anal about
> > > writing good code even with the tests? I guess that would be
> > > ideal, but I'd rather get the functionality done first.
> >
> > This is the whole 'design after' or 'refactoring' paradigm:
> > make it work, then implement a proper design and prettify.
> > Passing unit tests prove that nothing was broken :)
>
> I cannot in a million years imagine coding without design. I've
> never coded tests first (I test each class after coding it), but I
> can't imagine why writing the tests first would make one not
> design. If it did make me not design, I wouldn't code test first --
> I'd make test jigs after.
Heh, of course you need to have *some* idea of what you are
doing (and, in fact, the better you design intuitively, the
easier the refactoring). If you are coding strictly by the
"write a test...implement the method...write another test..."
method, you are likely to end up with slightly less elegant
code, occasionally with repetition and all-in-all less-than
ideal organization. Refactoring is the phase of fixing this,
shuffling functionality around, extracting common code etc.
> SteveT
E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDqlnsxvA1l6h+MUMRApzAAJ9S9+REQ4qvVCvWA9d5RJrpIsFtAwCfR3AO
VCrLbVeshFlcBgmU9c30mzw=
=bCPh
-----END PGP SIGNATURE-----