From: Conal T. <con...@vu...> - 2008-03-10 05:23:42
|
I have an old topicmap provider implementation which no longer links against recent builds of TM4j because of the addition of the equalsByID method to the TopicMapObject interface. It is certainly an easy method to implement, but I'm concerned because I don't even understand why the method has been added to TopicMapObject. It appears it may have been a "rough idea" that never really developed? In any case, it seems like a needless complication to me, and I am inclined to remove it. First I thought I would ask about it here. The point of the method appears to be to hide the data type of the object's id, presumably so that it could potentially be something other than a String. But this seems pointless to me, since actually these id properties are constrained to be strings (actually, XML names) by the XML Topic Maps specification. There's no way they could be anything other than strings! When I looked at each provider's implementation of the TopicMapObject interface in the TM4j source tree, they were all exactly the same: public boolean equalsByID(TopicMapObject o) { return getID().equals(o.getID()); } That fact in itself is a good indicator that the method doesn't properly belong in the TopicMapProvider interface. If there is no need for different providers to implement the method differently (and indeed the JavaDoc for the interface actually specifies the implementation!), then it belongs in a helper class, or as a protected helper method, but not as a public API. Each of the tm4j topic map providers had an implementation of TopicMapObject which included this method. These methods were used in at most a few places within that provider's package (e.g. org.tm4j.topicmap.hibernate.TopicImpl calls the method as a helper within isOfType(Topic)). In all of those cases the method could just as well have been protected - it didn't need to be part of the public API. Even if it were just a protected method of TopicMapObjectImpl (and not required by the TopicMapObject interface) it would seem hardly justifiable because it is just a single line of code, and used only a few times (not used at all in the unified provider!). Incidentally, I'm not sure if the implementation in the "unified" provider is correct - it's subtly inconsistent with equals(). The only use I could see of the method outside of provider classes was in org.tm4j.topicmap.utils.TopicMapWalker, where it was used just once, and could I think have just as well used equals() or at least getID().equals(o.getID()) So I propose to remove the equalsByID method from the interface, and replace its use in TopicMapWalker with equivalent code comparing id values. Any objections? Con -- Conal Tuohy New Zealand Electronic Text Centre www.nzetc.org |