Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: [joist-dev] UnsecureServlet method use unclear

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

Re: [joist-dev] UnsecureServlet method use unclear

Author Ed Korthof <edk at laswell dot collab dot net>
Full name Ed Korthof <edk at laswell dot collab dot net>
Date 2000-10-09 17:26:28 PDT
Message On Mon, Oct 09, 2000 at 04:58:19PM -0700, Jon Stevens wrote:
> on 10/9/2000 9:46 AM, "Daniel L. Rall" <dlr at finemaltcoding dot com> wrote:
>
> > Why is an Exception even thrown if you just want a redirect? To quote
> > Brian Kernighan, "exceptions should be used only in exceptional
> > circumstances." This doesn't qualify. Additionally, this method means
> > nothing on its own, which makes its purpose indecipherable without
> > looking at how it's called. Just today you mentioned that Exceptions
> > are not cheap to create, so why bother when what you actually want is a
> > redirect?
> >
> > Daniel Rall
>
> I agree. This is a bad design decision.

I don't like it (I agree that it's a bad design decision), but I don't
think it's so obvious that this is a misuse of exceptions. If we assume
that you might realize you want to issue a redirect in a function other
than processRequest -- in fact, in a function far down the stack from
processRequest -- then exceptions are the right approach : without them,
you have to complicate the code significantly to deal with early return
after (or before) doing the redirect.

(Redirects themselves happen infrequently (once per request == infrequent)
-- so the cost of creating an exception isn't all that big a deal. This
is another situation where I'd say that if we want to optimize, we should
start with operations which are costing us *a lot*. I don't think this
is one of them. If you want, I can do some tests to figure out the time
it takes to throw & catch an exception; I suspect it'll be somewhat less
than 1ms, which puts it beneath the threshold I'd call relevant, given
that our servlets are taking ~250ms or more total time.)

OTOH -- IMO, servlets should be very simple, and the logic required for
an early return shouldn't be too complicated. I don't think the code
involved in choosing to make an early return should be in the servlet
itself -- I think it should be in the next level down. If the code is
well organized, exceptions could be avoided without excessive
complication. Right now, I think the code may be organized in such a way
that switching to a system which doesn't work by exceptions would be
painful and would create far too much complication. :-(

The way I see it, the basic question is more how we should encourage
people to organize their servlets/logic. This looks like a valid use of
exceptions, but it leads to code which is more complicated (at each
level).

cheers --

Ed
--
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=
   | Ed Korthof | edk at collab dot net | 415-247-1690 |
   +=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=+=-=​+=-=+=-=+=-=+=-=

« Previous message in topic | 5 of 9 | Next message in topic »

Messages

Show all messages in topic

UnsecureServlet method use unclear dlr Daniel Rall 2000-10-09 15:14:30 PDT
     Re: [joist-dev] UnsecureServlet method use unclear David Pellegrini <davidp at collab dot net> David Pellegrini <davidp at collab dot net> 2000-10-09 09:28:22 PDT
         Re: [joist-dev] UnsecureServlet method use unclear dlr Daniel Rall 2000-10-09 09:46:36 PDT
             Re: [joist-dev] UnsecureServlet method use unclear Jon Stevens <jon at latchkey dot com> Jon Stevens <jon at latchkey dot com> 2000-10-09 16:58:19 PDT
                 Re: [joist-dev] UnsecureServlet method use unclear Ed Korthof <edk at laswell dot collab dot net> Ed Korthof <edk at laswell dot collab dot net> 2000-10-09 17:26:28 PDT
                 Re: [joist-dev] UnsecureServlet method use unclear David Pellegrini <davidp at collab dot net> David Pellegrini <davidp at collab dot net> 2000-10-09 20:41:44 PDT
                     Re: [joist-dev] UnsecureServlet method use unclear "Daniel L dot Rall" <dlr at collab dot net> "Daniel L dot Rall" <dlr at collab dot net> 2000-10-09 20:47:10 PDT
                     Re: [joist-dev] UnsecureServlet method use unclear Jon Stevens <jon at latchkey dot com> Jon Stevens <jon at latchkey dot com> 2000-10-10 09:47:54 PDT
                         Re: [joist-dev] UnsecureServlet method use unclear dlr Daniel Rall 2000-10-10 09:53:41 PDT
Messages per page: