> Message: 2
> Date: Tue, 3 May 2005 21:28:02 -0400
> From: "Brian L."
<zorander-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Subject: Re: [Rails] Good Reading Suggestions?
> To: Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> Message-ID:
<6ee4c8380505031828769ffe9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1
>
> (snip)
> What I still don''t get is TDD. I''ve tried, but I
can''t bring myself to
> write enough tests. I''ve read about it enough times, but I just
never
> make it there, and once the application crosses a thousand lines of
> code, it''s even harder to convince myself to go back and write
tests
> for a day or two.
Brian,
Once your app development gets to a certain number of LOC and has a
sizeable chunk of operating stuff, it''s very valuable to be able to
kick off a bunch of regression tests at those times when you need to
take a break.
Before you get up for a coffee,
- check in your code
- kick off a bunch of your test cases
- enjoy your break
When you come back, either your test cases have all passed or you''ve
got some remediation to do. Either way, you avoid the problem of
trying to debug code that you haven''t looked at for a while, which is
a big productivity killer as well as a pain.
If your new code/test cases break old code, then you either need to
extend your old code to cope with new input, or rejig your new code so
it uses tried-and-tested interfaces to the old code. Either way, the
interfaces should still be fresh in your mind, so that''s the time to
fix any problems - not e.g. 2 weeks later when you''ve forgotten all
about what these two code chunks are supposed to do.
There''s definitely a certain satisfaction in getting a piece of code
written, then test cases done that exercise all parts of it, then
watching all those test cases work with your sample data, then adding
these test cases to an overall regression script that you can run
whenever you feel the urge (to have coffee, go home, have lunch,
etc.). In particular, you can move away from a piece of code in the
knowledge that it works and is solid, rather than taking on a new
coding task while there''s still niggling doubts in your mind about
whether the old code has been adequately tested.
Finally, if you''re working with others, there''s nothing more
infuriating than having someone tell you your code doesn''t work,
spending hours looking for a bug in your code that isn''t there only to
find that the fault is actually in the other person''s code. On the
other hand, if you''ve got test cases written for your code
that''s
being questioned, you can kick off your test cases, head off for a
chat with the other person for a few minutes, then come back to see
whether your test cases have worked or not. Much less stressful for
both of you.
Just my 0.02c worth
Dave M.