5 ms·
On a similar note, the code parse an XML document in Java: Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("test.xml"); Tha
by EliAndrewC 18y ago
On a similar note, the code parse an XML document in Java:
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("test.xml");
That's not even a framework; it's just what's in the standard library for parsing XML.
- ynd 18y agoI bet they were looking for extensibility. I wonder if they ever thought of providing two interfaces. 1. The first is the common case. Document doc = new DocumentBuilder().parse("test.xml"); 2. The second is more cumbersome but provides options. Document doc = DocumentBuilderFactory.newInstance(opts).newDocumentBuilder(opts2).parse("test.xml");
- ntoshev 18y agoThis is the facade pattern :) If you need it, this means you are overengineering. Applying it is even more overengineering.
- EliAndrewC 18y agoI think the common case could be even simpler Document doc = DocumentBuilder.parse("test.xml"); no need to manually create an instance of the builder.
- michaelneale 18y agoYou can lay for that in the gang of four book which recommended things like "abstract factory" - the odd thing was, I thought most of those authors were ex smalltalkers?