Skip to main content

Structure of J2SE: Modularity

Posted by eitan on July 6, 2004 at 12:19 PM PDT

With 2604 classes in J2SE v1.4.2_05, one could say that J2SE is a large API. I mean, compared to other APIs, such as dom4j (153 classes) and hibernate (466 classes), J2SE is large. Of course, you'll argue: "this is not a fair comparison: J2SE is an aglomeration of multiple APIs, packaged together as one large bundle." One should instead compare dom4j and hibernate with APIs such as jdbc, swing, awt, jndi, jta, rmi, security, util, xml, etc..

My point exactly! I'm glad you brought this up. [AFAIK] Java was the first language to introduce an official, structured, and coherent namespace mechanism to separate my code from yours, code that does X from code that does Y: packages. And packages are terrific! Over the years, and with the growth of the Java platform, I've come to believe that yet another level is missing: some kind of uber-package. Maybe we should simply call it an API. We need something to bridge the gap from "package" to J2SE. This idea reminds me very much of what the folks at W3C do with their specs: with time, new revisions of specifications grow to a point where spec authors decide to modularize them. For example the CSS3 spec is comprised of a few dozen modules (fonts, lists, borders, text, print, media, etc..). The latest DOM and HTML specs are also modularized.

Back to Java, I'd like to see J2SE more formally modularized. I mean, I know that all packages that begin with javax.swing a part of the Swing API. I'd still argue for a more formal modularization mechanism. As I browse J2SE javadocs, I'd like to see a first-level hierarchy of APIs, not packages. I see this as a natural "cleavage point" (so to speak). And in fact, somewhere under the web site, you'll actually find home pages for each of these J2SE "sub-APIs." I'd like to go as far as select what J2SE APIs to include in my javadocs to begin with (perhaps because I may not need to use them all on a specific project I'm on).

This reminds me of something else (here I go on yet another tangent): there's this informal rule that average humans have difficulty remembering lists longer than seven (7) items. J2SE contains 114 packages. That's definitely more than 7. If we were to introduce this extra level, we could nominally bring things back, closer to that rule of seven: J2SE could be comprised of maybe a dozen sub-APIs, each containing maybe 8-10 packages. That'd work for me!

As far software packaging/download purposes are concerned, I'm actually happy as a clam with the current state of affairs.

Related Topics >>