Well, we both agree that creating a score of -1 makes no sense.  It's  
an interesting debate, because you can take a "business" view or a  
technical view.  What I mean by that is in the business sense, asking  
for the score on a day where the Red Sox aren't playing is a  
perfectly normal condition.  As a real world example, I have a Widget  
on my MacOS X Dashboard for baseball scores, and it's configured to  
only show me the score of the St. Louis Cardinals game.  On days when  
they aren't playing, it displays "No games scheduled" instead of the  
score.   Behind the scenes, it's making a call to some XML over HTTP  
service for this information.  It's not using SOAP, so there's no  
formal definition of a fault, but I'm sure that the HTTP call it is  
making is still returning something with a 200 response code, not a  
50x code.

 From the technical sense, there's a risk of using exceptions as a  
return mechanism where the information being returned doesn't match  
the signature of the method.  Exceptions provide a convenient way of  
getting around it.  Just because you can, doesn't mean you should.   
Instead, you could  augment the definition of return type to properly  
reflect the normal usage of the operation.  Augmenting it by having  
"special" values with undocumented interpretation like score=-1 is  
bad.  Augmenting by allowing the specification of optional or  
conditional values makes more sense, although not all languages allow  
this to be made explicit as can be done with XML Schema which does  
leave the debate open.  You could argue that the use of an exception  
does make things more explicit than augmenting the return type.   
Interesting debate and one where there will only be opinions, and no  
right or wrong answer.

-tb

On Mar 14, 2007, at 11:03 AM, Gregg Wonderly wrote:

> Todd Biske wrote:
>> I tend to agree with the popular opinion, although I wouldn't use the
>> terms system exception and application exception.  An exception,
>> regardless of the adjective before it, should represent something
>> abnormal (not necessarily unexpected though).  In your example, as
>> you rightly point out, there are days off during the baseball
>> season.  Therefore, a request for the score on a day when there is no
>> game should not be considered abnormal.  Interestingly, however, a
>> request for the score in January would be.
>
> I disagree.  For uniformity of API response, out of season and day  
> off should be
> the same return type.  Creating more variations for the client to  
> deal with is
> not always a good thing.  And, I would throw an exception to signal  
> that it is
> not proper to make that request/call at that time.  A score is a  
> score!  If you
> can't return a score that is meaningful, then throw an exception.   
> Demanding
> that the application treat a score of 0 or -1 special is silly.
>
> Gregg Wonderly
>
>
> ------------------------ Yahoo! Groups Sponsor -------------------- 
> ~-->
> See what's inside the new Yahoo! Groups email.
> http://us.click.yahoo.com/0It09A/bOaOAA/yQLSAA/NhFolB/TM
> -------------------------------------------------------------------- 
> ~->
>
>
> Yahoo! Groups Links
>
>
> [EMAIL PROTECTED]
>

Reply via email to