Monday, July 23, 2007

What's Wrong With Java Part 2b

To give an idea why I needed 5KLoC for such a simple model, here is a detailed analysis of Keyword.java:

LoCUsed by
43 Getters and setter
40XML Import/Export
27Model
27equals()/hashCode()
21Hibernate mapping with annotations
14Imports
2Logging
174Total

As you can see, boiler plate code like getter/setters and equals() need 70LoC or 40% (48% if you add imports). Mapping the model to XML is more expensive than mapping it to a database. In the next installment, we'll see that this can be reduced considerably.

Note: This is not a series of articles about flaws in Hibernate or the Java VM, this is about the Java language (ie. what you type into your IDE and then compile with javac).

No comments: