[jdom-interest] re: Stirring up Trouble

Robin Meade rmeade at outreach.hawaii.edu
Wed Jul 19 17:00:56 PDT 2000


Clarification of my earlier post:

I was stating my preference of having these two methods:

  String getContent();      // returns untrimmed content
  String getContentTrimmed();
  
over having these two:

  String getContent();      // returns untrimmed content
  String getContent(boolean preserveWhitespace);

on basis of improved readibility of client code.

Brett McLaughlin wrote:
> 
> Robin Meade wrote:
> >
> > Brett McLaughlin wrote:
> > snip
> > >
> > > getContent(boolean preserveWhitespace);
> > >
> > > is perfectly intuitive.
> > >
> > > But what does
> > >
> > > getContent()
> > >
> > > do?
> > snip
> >
> > Wouldn't
> >
> >   getContentTrimmed();
> >
> > be more readable than
> >
> >   getContent(true);
> 
> No - because you would then have two methods doing essentially the same
> thing. If users are really unwilling to read the Javadoc, then they can
> use trim().
> 
> >
> > For the latter, I need to consult the JavaDoc to know what's going on.
> 
> No offense, but you shouldn't be using an API if you aren't willing to
> read the instructions ;-)
> 

I was suggesting a method name that I thought would make client code 
more readable and self-documenting.

Some tips on naming methods that I found interesting is at
http://www.gebit.de/GebitHomePage/forum/JavaStandards.html#_Toc409482299
(Particularly the topic: Include "parameter hints")

> -Brett
> 
> >
> > As for
> >
> >   getContent();
> >
> > I would assume it returned the untrimmed content.
> >
> > Robin Meade
> 
> --
> Brett McLaughlin, Enhydra Strategist
> Lutris Technologies, Inc.

-Robin
Robin Meade



More information about the jdom-interest mailing list