[Biojava-dev] bjv2 alpha 3
mark.schreiber at group.novartis.com
mark.schreiber at group.novartis.com
Sun May 23 21:21:54 EDT 2004
>> @Utility annotation
>> This flags a class as being a utility class. This means that it
must
>> expose only static fields and methods, and must not be instantiable.
>> More coding-style validators will follow.
>
>While this pattern is good coding style, it causes problems in certian
>environments that require no-arg constructors.
>
>Most (if not all) of the apache projects now include a constructor like
>
> /**
> * <code>XxxUtils</code> should not normally be instantiated. This
> * constructor is public to permit tools that require a JavaBean
> * instance to operate.
> */
> public XxxUtils()
> {
> // empty
> }
>
>in utility classes. See e.g.
>
> http://jakarta.apache.org/commons/lang/apidocs/org/apache/commons/lang/ArrayUtils.html
>
> michael
This is not a bad idea. If you ever try to make a GUI application based on
BioJava using an IDE you pretty quickly come unstuck on the more non-bean
like elements, the *Tools being the biggest problems. A public constructor
on a utility class is not really a problem other than possibly creating
more than one copy in the VM and adding a bit of cruft.
It would be nice if more of BioJava could be made into valid beans.
Unfortunately this does render all of the elegant singletons invalid. If
only java had a keyword for a constructor that could be called only by the
VM to create a bean. I suspect such a thing would cause all kinds of
security problems though.
- Mark
More information about the biojava-dev
mailing list