Skip to main content

Posts

Showing posts from February, 2011

Too Many Moving Parts

A common, if somewhat informal, observation about a large code base is that there are "too many moving parts" in it. In my experience, this is especially true for large Java systems but is probably universally true.
What do we mean by ‘too many moving parts’?
Simply put, there is always a significant semantic gap between a programming language and the program. The larger this gap, the more that has to be expressed in the language, as opposed to simply using it.
For example, consider the problem of traversing a recursive tree structure. In Java, we can iterate over an Iterable; structure using a loop, for example, to count elements:

int count = 0;
for(E el:tree)
{
  count++;
}

If the Tree class did not implement Iterable we would be forced to construct an explicit iterator (or worse, write a recursive one-off function):

int count = 0;
for(Iterator<E> it=tree.iterator(); it.hasNext();)
{
  E el = it.next();
  count++;
}

This version illustrates what happens when a programming language d…