[jdom-interest] attributes

Jason Hunter jhunter at servlets.com
Wed Jan 30 15:44:10 PST 2002


> > Reason one:
> >
> > Why should setAttribute(Attribute) be different than
> > setAttribute(String, String)?  I personally would think
> > Element.setAttribute(String, String) would be a wrapper around
> > Element.setAttribute(Attribute).
> 
> My intuition is different. There's two less personal reasons to use "my"
> logic. You avoid creating more objects than needed, and you avoid creating
> objects outside a factory. The last is perhaps most important, since the
> main usage of a factory is to control object creation.
> 
> > Reason two:
> >
> > Maybe someone else has a reference to the original Attribute and
> > changing that object's state indirectly (by a call to its parent) is not
> > desirable if it can be avoided.
> 
> We'll, he who brought up the question had the opposite problem: That of
> keeping the Attribute reference. I would guess that is just as relevant a
> problem.

Like I said originally, "One could argue it shouldn't, and one can argue
it should."  :-)  You can easily achieve both behaviors, so all we're
talking about is default behavior.  I don't really care between the two,
although I lean toward having all the Element setAttribute() methods
have the same behavior, which is what we have now.

> BTW, do we have a poll mechanism for helping to decide such things?

Classic open source.  Those doing the largest amounts of work get to
decide, since they're the lifeblood of the project.

-jh-



More information about the jdom-interest mailing list