[jdom-interest] Re: Fast or Safe?

Simon Harris Haruki_Zaemon at hotmail.com
Fri Sep 1 14:48:21 PDT 2000


I love JDOM!!!! The major problems that I see JDOM solves over regular DOM
are:

    Support for collections, etc which most java programmers are used to and
not some shonky NodeList invented by a commitee with method names like
getNextSibling(), etc.

    Distinction between Elements, Attributes, etc.

    Text value of Elements as a single string and not some shonky TextNode

    Speed!!!

Unless I'm missing something, I don't see the problem with factories. As its
stands now I go through hoops to essentially extend Element and Attribute
and have JDOM use these in any useful way. If JDOM had a few interfaces and
factories and a default implementation of all these, I (and I suspect many
others) would never look back.

For example:

    Have two new interfaces IElement and IAttribute that return IElements
and IAttributes instead of Elements and Attributes

    Leave the existing classes (Element, Attribute, etc) as default
implementations of two new interfaces. This way I can still use Element foo
= new Element("foo") or still better IElement foo = new Element("foo").

    Have the Builder and Outputter accept a factory on construction. Or use
a default factory from the default constructor.

To address your concerns over existing code, its a simple as:

    Globally replace new Element with new XXXXElementXXX

    Globally replace Element (whole word only) to IElement

    Globally replace new XXXXElementXXXX to new Element

and voila we now use the new interfaces AND factories.

Even if we named the interfaces Element and Attribute and renamed the
existing classes Element and Attribute to DefaultElement and
DefaultAttribute respectively, I don't see the big deal WRT existing code.
These kind of code changes can be done all at once with very little effort.

Simon.

----- Original Message -----
From: "Brett McLaughlin" <brett.mclaughlin at lutris.com>
Cc: <jdom-interest at jdom.org>
Sent: Saturday, September 02, 2000 1:46 AM
Subject: Re: [jdom-interest] Re: Fast or Safe?


>
>
> "Trebor A. Rude" wrote:
> >
> > On Thu, 31 Aug 2000, Gerardo Horvilleur wrote:
> > >"Trebor A. Rude" wrote:
> > >>         Hmm, if we do that, we could create a sigleton factory class
> > >> to return you the proper implementation of the interface based on
some
> > >> settings it's got stored. At the very least, the programmer would be
> > >> forced to manually create objects of the correct implementation. Of
> > >> course, either way would probably break every existing JDOM program
out
> > >> there, as the "Element foo = new Element("foo");" idiom would break.
> > >> Even though we could, with the claim "the API is pre-1.0", I'm not
sure
> > >> many people would be very happy if we did that. Design wise, it
sounds
> > >> fine though.
> > >
> > >It would be something like: Element foo = factory.newElement("foo")
> > >which seems reasonable enough to me. It is not too different from
> > >what we have right now and it makes it possible to have multiple
> > >implementations.
> >
> >         It's quite reasonable, my only concern is that it probably
breaks all
> > existing code, which we may not want to do. Fortunately we're in the
> > pre-1.0 stage, and it's easier to justify the large change. Brett?
Jason?
> > What do you think?
>
> I continue to be against factories. It's unnecessary, I'm still
> convinced. Because it is the first option apparant to perform this task
> does not mean it is the best. It also makes implementation very messy,
> breaks all existing code in a /fundamental way/, causes many of the JDOM
> newbies to be totally lost, and AFAIK still doesn't add significant
> functionality.
>
> We went through this once every month or so, so I'd refer you to the
> archives for more details... I'm so far from being convinced this is
> even a good idea, though...
>
> -Brett
>
> >
> > --
> > Trebor A. Rude
> > trebor at bwn.net
> > Registered Linux User #89308
> > http://counter.li.org/
> > _______________________________________________
> > To control your jdom-interest membership:
> >
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>
> --
> Brett McLaughlin, Enhydra Strategist
> Lutris Technologies, Inc.
> 1200 Pacific Avenue, Suite 300
> Santa Cruz, CA 95060 USA
> http://www.lutris.com
> http://www.enhydra.org
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>



More information about the jdom-interest mailing list