Re: Cocoa and messages to nil, revisited
Re: Cocoa and messages to nil, revisited
- Subject: Re: Cocoa and messages to nil, revisited
- From: "Shawn Erickson" <email@hidden>
- Date: Wed, 8 Aug 2007 16:14:12 -0700
On 8/8/07, Jeff Laing <email@hidden> wrote:
> Writing robust code is not compatible with writing insanely long chains of
>
> [this uses:[that which:[calls this:[who needs:theother]]]];
>
> and yet thats *exactly* what you see being used in all the samples. I have
> exactly *zero* confidence that the authors of that code have really
> considered that 'this', 'that', 'calls' and 'who' may well be nil through
> some *unexpected* bug.
So place asserts in your code that ensure that this, that, calls, and
who are as you expect in the code block, etc. Also place asserts in
the methods called to validate they are getting what they expect.
IMHO unless you plan to do something to recover from the error why
make you code harder to read then it needs to be. Test to shake out
the sources of unexpected bugs and keep your code simple and
maintainable.
In my experience issues with messages to nil seldom live long in a
product because you find those issue as well as develop a
coding/thinking/debugging style that helps you avoid making mistakes
like that.
Of course how robust something needs to be greatly depends on the
usage context, etc.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden