jcabi/jcabi-xml

org.jcabi.xml.XML::node method should be deprecated/removed

skapral opened this issue · 2 comments

Originally, idea came from discussion raised in #131

Arguments for its removal:

  • It exposes the details of how the framework operates inside - the DOM. It makes extending the framework harder: DOM is not the only way to process the XML document, but every implementation must deal with it until the method exist.
  • It makes proper encapsulation harder for the implementors of org.jcabi.xml.XML and provokes to break it. Implementation can't just return the org.w3c.dom.Node instance wrapped inside it, because client may mutate the implementation by mutating the node received,
  • Taking into account the previous argument, it is impossible to implement this method so it strictly follows the contract defined in its javadoc, because following it literally would mean breaking encapsulation:
  • Retrieve DOM node, represented by this wrapper.
  • Removing it will significantly simplify XMLDocument implementation, because there will be no need in hiding original Node from client code anymore.
0crat commented

@yegor256 please, pay attention to this issue

@skapral well, I can understand your logic, but there are many projects that use this method. A few of mine too. And I don't really think that it's a problem, since node() always return a new Node. Remember, XMLDocument is immutable.