On Wed, Sep 28, 2011 at 8:30 PM, Chris White <cwprogram / live.com> wrote:

>
> > I'm working on a tree data structure at the moment and I'm having
> > trouble with the recursive print function. It seems that the function
> > simply restarts every time it finishes... Even though it is not a
> > infinite loop. Hope that you guy's can help me figure out what the
> > problem is.
>
> Instead of answering the answer directly I'm going to take a "teach a man
> to fish" approach. The Ruby community has many proponents of what is known
> as TDD or Test Driven Development. In essence the approach is to write a
> test that will fail (missing class, missing file, incorrect functionality),
> then make that test pass. Then you write another test which will fail and
> make that pass as well. Each test should focus on a specific piece of
> functionality.
>
> Why is this important? Consider your situation now. You've written a giant
> test which attempts to look at the entire class as a whole instead of the
> individual components. Now you're stuck trying to figure out which of these
> components has an issue. If the TDD approach had been taken first, you could
> have easily narrowed down the problematic piece of code and potentially
> figured out what went wrong on your own.
>
> I recommend taking a look at how TDD works. Here is a basic screencast to
> get you started:
>
>
> http://kanemar.com/2006/03/04/screencast-of-test-driven-development-with-ruby-part-1-a-simple-example/
>
> Write some tests for each piece of functionality in your class and see
> what's not working out.
>
> Regards,
> Chris White
> Twitter: http://www.twitter.com/cwgem
>


Are you teaching a man to fish if you tell him "you should stop asking for
fish and start catching fish"?

how about showing him what that looks like?