Yay Java, boo java DOM
I had to spend some time porting some C++ code to Java. Whenever I do something like this, I remember the reasons why I hate C++. It's really not the language itself so much as everything around the language when compared to Java. Having a large, consistent set of collections class libraries in Java is a huge time saver.
One of the problems with C++ is that developers have too much flexibility. Flexibility is good, but it leads to inconsistency. Inconsistency is bad because it means it doesn't do what you expect which of course leads to bugs and requires documentation. Integrating several different pieces of C++ code is particularly troublesome. Different standards for different projects really hurts productivity. C++ works fine if you have a single large code base that was well designed and has good standards which everyone abides by.
I've heard a couple of different good things about C# lately. It is actually supposed to be pretty good, I am just so anti-Microsoft that I can't bring myself to use it.
The one thing I had forgotten was how annoying java DOM implementations are. You'd think they would make it easier to just build a DOM object and print it out. But in fact you need code like this:
Maybe there's a shorter way to do this and I just don't know it, but that's a lot of code for something that should be really simple.
One of the problems with C++ is that developers have too much flexibility. Flexibility is good, but it leads to inconsistency. Inconsistency is bad because it means it doesn't do what you expect which of course leads to bugs and requires documentation. Integrating several different pieces of C++ code is particularly troublesome. Different standards for different projects really hurts productivity. C++ works fine if you have a single large code base that was well designed and has good standards which everyone abides by.
I've heard a couple of different good things about C# lately. It is actually supposed to be pretty good, I am just so anti-Microsoft that I can't bring myself to use it.
The one thing I had forgotten was how annoying java DOM implementations are. You'd think they would make it easier to just build a DOM object and print it out. But in fact you need code like this:
TransformerFactory tFactory = TransformerFactory.newInstance();
DocumentFactory dFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
Document xmlDoc = dBuilder.newDocument();
Element element = xmlDoc.createElement("rootElementName");
... // add more document manipulation
Transformer transformer = tFactory.newTransformer();
transformer.transform(new DOMSource(xmlDoc),new StreamResult(System.out));
Maybe there's a shorter way to do this and I just don't know it, but that's a lot of code for something that should be really simple.
Labels: software



0 Comments: Post a Comment
<< Home