polaris wrote:
> i was arguing with my manager about whether it's better to throw
> exception from a service that im developing or to give the user
> returned value. My supporting points are:
> 1-thowing exception is much mostly than returned value in term of
> performance.
> 2-in returned value way the user can customize the behavior of the
> system as he like and he would have clear view of the service result.
> 3-with respect to the user requirement he doesn't really need a
> returned value or exception from
> the service.
> my manager supporting points:
> 1-the service should be general so in future if somebody want to be
> informed by the result of
> the service we don't have to modify it.
> but infact if we consider all the assumption we will delf into hunders
> of assumptions and if this is nessary the returned value is better way
> than throwing exception.
I think exceptions has a couple of advantages over return value
error indication:
1) You can force the programmer to deal with it by making
the exception checked.
2) If the exception is not to be handled by the calling method,
then exceptions is much easier to get bubbling up through the
call stack than return values.
And performance should not be a problem. Exceptions should be
an exception !
Arne