• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa and messages to nil, revisited
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >RE: Cocoa and messages to nil, revisited (From: Jeff Laing <email@hidden>)

  • Prev by Date: Re: Loading data in a background thread and displaying it with Bindings
  • Next by Date: RE: [OT] Re: Cocoa and messages to nil, revisited
  • Previous by thread: RE: Cocoa and messages to nil, revisited
  • Next by thread: Re: Cocoa and messages to nil, revisited
  • Index(es):
    • Date
    • Thread