[jdom-interest] About the Text class
bob at werken.com
Fri Jan 11 14:05:57 PST 2002
> Now that this class seems to be adopted, why not leveraging its capabilities.
> First, the JDOM code is full of instanceof operator, checking for
> particular content. Why not creating a base class
> that will be the root of the other? Then, a "int getType()" method
> will be easier and faster than the use of instanceof.
> a sanity check method can then be written like "return
Yeahbut, that's also a sign of non-OO practices. Let polymorphism
work to your advantage. Don't check the type, cast, and call
a method that has the same name in both classes (ie, "getParent()"),
instead, define the method-in-question in the base class, and
work with instance of the base class (ie, Node::getParent()).
Else, we're looking at a hideous DOMish API. Let's leverage
our truly polymorphic types and abstract types/interfaces to
promote clean programming practices both within the JDOM
sources and the sources of those using JDOM.
More information about the jdom-interest