Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Programming "style" question.
Programming "style" question. [message #191260] Tue, 10 April 2007 12:44 Go to next message
Eclipse UserFriend
Originally posted by: ns_dkerber.ns_WarrenRogersAssociates.com

When I use the Eclipse "New servlet" wizard to create a new servlet
template, and end up not using some of the methods (Delete and Put,
mostly), is it considered good form to delete those stubs from my code,
or leave them stubbed, as they were originally created in the file?

Dave

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Re: Programming "style" question. [message #191268 is a reply to message #191260] Tue, 10 April 2007 22:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

David Kerber wrote:
> When I use the Eclipse "New servlet" wizard to create a new servlet
> template, and end up not using some of the methods (Delete and Put,
> mostly), is it considered good form to delete those stubs from my code,
> or leave them stubbed, as they were originally created in the file?

I don't have WTP active at the moment so I can't try, but I'm assuming
the generated class extends HttpServlet. If you look a the
implementations of doDelete() and doPut() in HttpServlet, you'll see
that they just return HTTP error codes in response. So if you remove the
stubs from your servlet class, those implementations will be used
instead. If you leave the stubs empty, clients that attempt DELETE or
PUT will get no response at all. It's up to you, but I never have any
implementation of those methods (ie, let the default impl in HttpServlet
handle them).

Hope this helps,
Eric
Re: Programming "style" question. [message #191303 is a reply to message #191268] Wed, 11 April 2007 12:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ns_dkerber.ns_WarrenRogersAssociates.com

The code for these methods just calls super.doWhatever, like:

protected void doDelete(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
super.doDelete(request, response);
}


So I'm guessing it's safe to delete them, but I was just wondering what
most people do. I'm all for minimizing the code in my apps, if for no
other reason than reducing the attack surface, and reducing class size
and memory usage.

In article <evh2ra$8bl$3@build.eclipse.org>, eclipse5@rizzoweb.com
says...
> David Kerber wrote:
> > When I use the Eclipse "New servlet" wizard to create a new servlet
> > template, and end up not using some of the methods (Delete and Put,
> > mostly), is it considered good form to delete those stubs from my code,
> > or leave them stubbed, as they were originally created in the file?
>
> I don't have WTP active at the moment so I can't try, but I'm assuming
> the generated class extends HttpServlet. If you look a the
> implementations of doDelete() and doPut() in HttpServlet, you'll see
> that they just return HTTP error codes in response. So if you remove the
> stubs from your servlet class, those implementations will be used
> instead. If you leave the stubs empty, clients that attempt DELETE or
> PUT will get no response at all. It's up to you, but I never have any
> implementation of those methods (ie, let the default impl in HttpServlet
> handle them).
>
> Hope this helps,
> Eric
>

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Re: Programming "style" question. [message #191351 is a reply to message #191303] Wed, 11 April 2007 17:53 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

David Kerber wrote:
> The code for these methods just calls super.doWhatever, like:
>
> protected void doDelete(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> // TODO Auto-generated method stub
> super.doDelete(request, response);
> }
>
>
> So I'm guessing it's safe to delete them, but I was just wondering what
> most people do. I'm all for minimizing the code in my apps, if for no
> other reason than reducing the attack surface, and reducing class size
> and memory usage.

Yes, it is safe and advisable (useless code in a class just clutters it
and makes it harder to read) to remove them.
By the way, having the stubs will increase the .class file size
(although insignificantly, perhaps a few bytes) but has no affect on the
"attack surface" or memory usage of the code.

Hope this helps,
Eric
Previous Topic:Web Services Tools Webinar
Next Topic:Deployment of Web Service Functionality
Goto Forum:
  


Current Time: Tue Apr 23 13:59:26 GMT 2024

Powered by FUDForum. Page generated in 0.02794 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top