[jdom-interest] TODO clone [eg]
Dennis Sosnoski
dms at sosnoski.com
Sat Apr 14 13:11:37 PDT 2001
Joseph Bowbeer wrote:
> The question for JDOM is whether clone is a requirement for subclasses or
> not. By declaring the CloneNotSupportedException in the superclass, we're
> saying it's not a requirement and programmers should beware. Another step
> back would be to only provide a "protected" clone method in the superclass
> and leave it up to subclasses to make it public if they want.
This seems to assume that subclassing will be the normal usage. I don't think
that's true - I'm sure there'll be many cases where people subclass, but
there'll probably be even more where they use the classes as is. Why force
everyone to check the exception just in case someone at some point wants to
implement a non-cloneable subclass?
I'd suggest the onus is on the developer implementing a non-clonable subclass to
make sure it's not used by anything that expects to clone it, and if it is it's
a program logic error - hence the UnsupportedOperationException recommendation.
- Dennis
More information about the jdom-interest
mailing list