At 07:54 AM 8/5/01 , Dave Thomas wrote:
>Again, though, I'd question the usefulness of this.  What is the
>benefit of having an application die with an assertion failure at the
>top of a routine, when it will fail anyway with a NameError a few
>lines down?

Error messages, sometimes.

Checking an assertion on entry to part of a published API lets you produce
better error messages. That's a help to a new user of the API. Were I such
a person, I'd rather see this:

    > dest = Trace::BufferDestination.new('bufferr')
    > conn.replace_destination(dest)
    ....: You can't replace 'bufferr'. It was never created. (Trace::Exception)

than this:
    NameError: undefined method `[]' for nil

The latter would make me wonder, at least for a moment, whether I wasn't
using some buggy package. I don't want new users of my package wondering
that.  By trying to explain what they did wrong, I hope to give the
impression I'm on their side.

It's a different matter if the calling code and the called code belong to
the same package. 



--
Brian Marick, marick / testing.com
www.testing.com - Software testing services and resources
www.testingcraft.com - Where software testers exchange techniques
www.visibleworkings.com - Adequate understanding of system internals