According to Jay Walters:

> Sounds like we're thinking of different things.  If you consider the startup
> case, either the service is there or it isn't and that code should all be in
> one place and should use a boolean.  Almost like a precondition in the start
> or init method of a MBean.  If you're in the middle of processing some
> entity bean request and you need the logging service and it's not there,
> that should be an exception.  I believe you are addressing the second case
> rather than the first, and I was addressing the first.

No, I was addressing the first as well.

Just think of it:

boolean:

true - success, false - failure. Please note also that you can't be more
specific than just telling the caller that the function requested couldn't
be performed, that's it. You cannot deliver the cause to the caller. Plus,
there may be unhandled/unchecked exceptions as well, which you have to
handle anyway.

Exception:

no exception - success, exception - failure. The exception can deliver the
message about the cause, as well as the root cause (which in turn may be
exception as well). And you have to handle exceptions once.

btw, this is a pattern I've accepted from early jBoss code ;)
 
> Cheers
> 
> -----Original Message-----
> From: Juha Lindfors [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 30, 2000 4:37 PM
> To: jBoss Developer
> Subject: RE: [jBoss-Dev] JMX Status?
> 
> 
> 
> Hmm, no. I agree with Vadim. If you use a boolean you're gonna have to
> spread the checks around every time you need a service. With an exception
> you can get the whole code inside a nice try - catch block, no matter how
> many times you need to call a service.
> 
> -- Juha
> 
> 
> At 15:24 30.8.2000 -0400, you wrote:
> >But service not available is a normal and expected condition (at least the
> >way it works right now with the Minerva pools) not an exceptional
> condition,
> >so it'd be better design to use a boolean.
> >
> >-----Original Message-----
> >From: Vadim Tkachenko [mailto:[EMAIL PROTECTED]]
> >Sent: Wednesday, August 30, 2000 3:22 PM
> >To: [EMAIL PROTECTED]
> >Subject: Re: [jBoss-Dev] JMX Status?
> >
> >
> >According to marc fleury:
> >
> >> At the same time I would see for a nice service where you provide a set
> of
> >> services that are needed for a particular configuration.  You would be
> >> notified immediately through a boolean return that all the services you
> >> requested are already on line.
> >
> >Based on experience, I'd suggest that a better way would be to return
> >nothing in case of success, and throw something like
> >ServiceNotAvailableException in case of failure. This simplifies handling -
> >you eventually get bored of checking the booleans, and the code without
> >such checking is cleaner.
> >
> >> marc
> >
> >--vt
> >
> >
> 
> 


Reply via email to