|go ahead... be a heretic|
Re: My number 1 tip for developers.by adrianh (Chancellor)
|on Sep 12, 2003 at 07:21 UTC||Need Help??|
Start1 by typing as much as code as you know will work
In my opinion an even better option is to start by writing a test for what you want to happen, then write the code to make that test pass. Repeat until code done.
Test Driven Development takes a little getting used to, but works very well in my experience. Advantages include:
So code a "caller" that uses that interface. In perl modules I tend to code this as a "main' program within the same file.
You can also do this sort of thing with Test::More and friends - and have the advantage of having something you can move to a test script later on. So instead of:
do something like:
Then you don't have to think about whether what's being printed out is correct.