Martin,
The question wasn't "which is better?".  The question was "are the two
functionally the same?" which as you've pointed out, they're not.

Steffen,
Looking at the (longer) code example that you posted, I can see that in
both cases there is logic to stop the iteration if there is a problem.
So, in this case, you may be correct.  

I think the larger point that Yoav and Remmy were both trying to make is
that evaluating a newcomer's re-factored code is as time consuming as
refactoring it themselves. If it means getting a bug fixed or a MAJOR
performance gain, then it's worth it but to risk overlooking something
subtle and breaking a core component for a small gain in efficiency or
just to neaten the code is not worth the risk.






On Tue, 2004-10-12 at 16:08, Martin Gainty wrote:
> Ben
> In the first case the while contains the logic and doesnt allow the program
> to exit until until the while condition goes false..
> In the second case the try/catch allows the exception to propagate up to the
> caller as soon as the exception is caught
> Personally I would use the 2nd approach..
> Good Catch!!!
> Martin-
> ----- Original Message -----
> From: "Ben Souther" <[EMAIL PROTECTED]>
> To: "Tomcat Developers List" <[EMAIL PROTECTED]>
> Sent: Tuesday, October 12, 2004 3:42 PM
> Subject: Re: AW: AW: DefaultServlet and getOutputStream() / getWriter()
> 
> 
> > This is the code that I saw (from the beginning of this discussion on
> > the user's list).
> >
> >
> > begin quote----------------------------------------------------------
> > PS: Since I am already sending another mail, let me append a pending
> > question:
> >
> > I often see code like this in the servlet:
> >
> > while (...) {
> >   try {
> >     ...
> >   } catch ( ... ) {
> >     ...
> >   }
> > }
> >
> > which could be replaced with
> >
> > try {
> >   while (...) {
> >     ...
> >   }
> > } catch ( ... ) {
> >   ...
> > }
> >
> > which is faster in my imagination.
> > Is there a reason or is my imagination false?
> > end quote----------------------------------------------------------
> >
> >
> > If the discussion has moved on to something else, then I apologize for
> > wasting your time.
> >
> > -Ben
> >
> >
> >
> >
> >
> > On Tue, 2004-10-12 at 15:31, Steffen Heil wrote:
> > > Hi
> > >
> > > > Compile, run, and view the output from this program.
> > > > I think you'll see the difference :o)
> > >
> > > Sorry, but did you actually read the code it posted?
> > > I KNOW that there CAN be a difference in semantics.
> > > YOUR code has different semantics.
> > >
> > > BUT in the code I POSTED there is NONE !
> > >
> > > So, please read it first.
> > >
> > > Regards,
> > >   Steffen
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to