Whither Modularity?

|

I've been thinking a lot about modularity lately. Specifically: what can you do to ensure that a large, evolving Java codebase is written and maintained in a modular way? Despite having just turned 10 years old, Java still hasn't provided a good answer.

There certainly are many tools and techniques for identifying poorly-modularized Java code, but precious few that help you write modular code in the first place. By the time you have to bust out JDepend and Refactoring, you're already pretty much screwed. What I want are some practical guidelines on how to get modularity from the outset.

The key word in that sentence, of course, is 'practical'. For me, this means that modularity

  • is achieved using only standard tools
  • requires little or no special effort to maintain
  • does not unduly inconvenience developers
  • is easily understood

These things are important because the kinds of projects where modularity is most needed (i.e., big ones) are also the projects where complicated rules are most difficult to enforce. If you need to get 300 people to each do something exactly right, it had better be pretty simple.

This simplicity is elusive because Java has no builtin constructs for describing modularity. As soon as you need to define a modular unit that is broader than an individual class or package, you're on your own as far as the JLS is concerned.

A well-designed build system can pick up some of the slack here by ensuring that modules get compiled independently. Unfortunately, there currently are no standard patterns here - the design of modular Java code is better-understood than the design of modular Java builds. Similarly, jar files can help enforce modularity at runtime, but they still fall short a few places, mainly in that they provide no way to restrict afferent (inbound) dependencies.

So, the question I'm wrestling with is how to take a set of imperfect tools and achieve some useful level of modular separation. I really don't think this issue gets enough attention. It's fairly easy to find abstract theories that use a lot of UML to describe the ideals of modularity; however, there are very few practical ideas floating around on how to achieve it in a large Java codebase in the real world.

I have a few thoughts about this that I'm going to blog about soon, but I'd love to hear of any other ideas in the meantime.

About

My name is Patrick Calahan.

I live in San Francisco.

I do product development and consulting on Java and Business Intelligence.

This is my blog.

Contact

About this Entry

This page contains a single entry by published on April 3, 2005 4:37 PM.

Stop! Holub Time was the previous entry in this blog.

Just say no to perfume is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01