[jdom-interest] Re: [jdom-commits] CVS update: jdom/src/java/org/jdom

guru at stinky.com guru at stinky.com
Mon Jun 18 10:54:12 PDT 2001


On Mon, Jun 18, 2001 at 10:04:15AM -0700, Jason Hunter wrote:
> elt.setAttribute("name", "value");
> vs
> elt.setAttribute(new Attribute("name", "value"));

Personally, I prefer parsimony.  The latter accomplishes the same as
the former, plus it's more self-documenting: it makes clear that
you're creating a new Attribute object, rather than (perhaps) changing
the value of an existing attribute.  (Which is how a recent poster
thought it should work, so there's room for confusion.)

This also fits in with the whole 
new Document().addContent(new Element("foo").addContent(new Element("bar") ...
idiom.  

OTOH, it wouldn't hurt much, but a public method is a public method.

-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/



More information about the jdom-interest mailing list