On 15 Oct 2010, at 21:42, Tito Ciuro wrote:

Hello,

I'm implementing a method and I'm not sure what the behavior should be when detecting an anomaly.

Case in point: I have a method that iterates through an array of objects. As I traverse the array, I'm, checking whether the object in the array conforms to a custom protocol. If it does, everything is fine and I process it. However, if at some point I detect that the array contains a non-conforming object, what should the method do?:

a) skip the non-conforming object and continue processing and return a BOOL or fill an NSError?
b) stop processing and return a BOOL or fill an NSError?
c) throw an exception?

Since the method would end up processing less objects that the developer intended, I wonder what Cocoa developers would expect in this case...

Based on this last sentence "... processing less objects that " [i.e. "than"] "the developer intended ...", what you describe would count as a programmer error, because of which throwing an exception would be most appropriate for a Cocoa application.

Klaus

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to