[jdom-interest] Factories for builders.

Richard Cook rpc at prismtechnologies.com
Wed Mar 14 11:01:47 PST 2001

> >3. You could save a possible redundant creation of DefaultJDOMFactory by
> >putting it in a lazy initialiser
> Is this some java fuctionality im not aware of, or do you mean
> checking
> if(factory == null) factory = new DefaultJDOMFactory()
> in the beginning of the build metod?

almost & debatable in this case anyway, just have an accessor method:

private JDOMFactory factory;
protected JDOMFactory getFactory()
   if (factory == null) {
      factory = new DefaultJDOMFactory();
   return factory;

and use the getFactory() rather than factory direct. That way you don't
create until needed and you get the default created only if a specific one
hasn't been set

(ps i think you had tabs in your code

More information about the jdom-interest mailing list