RE: Error and Exception Handling: When to use
RE: Error and Exception Handling: When to use
- Subject: RE: Error and Exception Handling: When to use
- From: "Nelson Santos" <email@hidden>
- Date: Tue, 12 Jun 2007 09:38:24 -0400
- Importance: Normal
Hi Ali,
Thanks for the links. I was aware and read the contents at the first link
before, but I haven't read the second one. Maybe it'll give me some ideas.
Nelson
-----Original Message-----
From: Ali Ozer [mailto:email@hidden]
Sent: Monday, June 11, 2007 4:27 PM
To: Nelson Santos
Cc: Cocoa-dev
Subject: Re: Error and Exception Handling: When to use
Just some quick pointers.
One reference is this; it answers some of your questions but not all:
http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa
/ErrorHandling/chapter_1_section_1.html
This other document describes the recommended way to implement input
validation when you're using key value coding, which works best when
you're using bindings to hook up your UI:
http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Con
cepts/Validation.html
Ali
On Jun 11, 2007, at 9:49 , Nelson Santos wrote:
> Hi everyone,
>
> Does anyone know (or know of any books or articles) about the proper
> way to implement error handling, particularly in Cocoa development?
> Development in general is fine too.
>
> I am looking for information about:
>
> 1) The proper/standard techniques in developing classes that are
> bulletproof.
> 2) When to properly use logging vs. assertions vs exceptions, or
> combinations of the three.
> 3) At what layer should exceptions be caught.
> 4) Which error levels should be reported to the user.
> 5) General strategies and limits of defensive programming.
>
> This came to mind as I was developing my classes. Say, for example,
> I have a method that receives an int parameter with an allowed range
> from 1 to 1000. How do I make sure I don't mistakingly send it a
> value of 5000? Well, I could implement an assert to warn me.
> Great! Well, what if I miss something during my development and
> testing and an incorrect value gets sent to the method? Then I
> should probably implement an IF statement or something to prevent
> the method from running. Or maybe raise an exception? Well, that
> means catching the exception somewhere to handle it. Should the
> user be notified of it? Do I have to do this for every method that
> I write that receives parameters? There could be many. Is that
> efficient? If so, does every method call now need to be in between
> try/catch?
>
> These questions and more pop up in my head and I'm not sure how to
> answer them. There must be a general recipe that most developers
> use when implementing good error handling. Thanks in advance for
> any help.
>
> Nelson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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