• 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
Design Option: Exception handling vs Code Testing....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Design Option: Exception handling vs Code Testing....


  • Subject: Design Option: Exception handling vs Code Testing....
  • From: Frederick C.Lee <email@hidden>
  • Date: Thu, 10 Jun 2010 13:58:13 -0700

Greetings:
    I have a situation where I need to access a member of a mutable array (max 4 members).
Sometimes I could get an out-of-bounds exception, if for example, I try to access member #3 out of a 2-member array.
It's not serious, I could just ignore it and continue.

Question:

Is it acceptable to merely trap for the out-of-bound exception within the method() and continue my way?
... or should I test EVERY TIME I access a member, to see if the member exist?

The amount of code is less for the @catch() exception route.

This could happen quite frequently.

Thoughts?

Ric.

_______________________________________________

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

  • Follow-Ups:
    • Re: Design Option: Exception handling vs Code Testing....
      • From: Jens Alfke <email@hidden>
    • Re: Design Option: Exception handling vs Code Testing....
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: NSOutlineView drag and drop problem
  • Next by Date: Re: Design Option: Exception handling vs Code Testing....
  • Previous by thread: Re: dataWithPDFInsideRect and NSPrintOperation
  • Next by thread: Re: Design Option: Exception handling vs Code Testing....
  • Index(es):
    • Date
    • Thread