Not long ago I went with a couple of friends to a bar in lower Manhattan. While we were sipping Coronas, Jerry, our system architect friend, told us he had just inherited a high-profile J2EE system, along with one of the top Java teams in his company. "Now we know who's buying the beers tonight," we cheered.
Instead of a round of beers, Jerry decided to surprise us: "My first J2EE project might very well be my last." Apparently, Jerry had overestimated the flexibility of the project's code base, and for a guy obsessed with time lines, it cost him dearly - he missed his first deadline by weeks. What bothered him more was the fact that the team seemed to be giving up. "There are bandages everywhere," one developer told him before taking off. "But I thought the team was very good," I said. "They still are, but they just can't seem to keep up with the changes. The next thing you know, broken structures have mushroomed everywhere....And now I'm working late every day."
As we were trying to raise Jerry's spirits, Ben, our project manager friend, pointed to a nearby TV and said cheerfully, "He can help you." It was a news clip about Time's man of the year - Mayor Rudolph Giuliani.
Mayor Giuliani and Broken Windows
Turns out that Ben wasn't joking. If there is one tip Mayor Giuliani can share with Java developers, it's the power and simplicity of the "Broken Windows" theory. In a speech he gave at Lincoln Center in 1998, Giuliani pointed out that New York City had turned around, with overall crime dropping 44% over the last four years, and the "Broken Windows" theory, "an integral part of our law enforcement strategy," made this possible.
First written about in 1982 by political science professor James Q. Wilson and criminologist George Kelling, the "Broken Windows" theory states that "If a factory or office window is broken, passersby observing it will conclude that no one cares or no one is in charge. In time, a few will begin throwing rocks to break more windows. Soon all the windows will be broken, and now passersby will think that not only is no one in charge of the building, no one is in charge of the street onto which it faces. So more and more citizens will abandon the street to those they assume prowl it. Small disorders lead to larger ones, and perhaps even to crime." The net result of this strategy, Giuliani observed, was a transformation "that's improving the lives of millions of New Yorkers."
The State of Many Java Neighborhoods
Broken windows exist not only in the real world (possibly in a neighborhood near you), but also in the Java world, taking on various forms under the cover of functional code. Some broken Java windows are easy to spot and are better known in the industry as spaghetti code: massive nested if-else, code duplications across modules, and dead code, to name a few. On more than one occasion I've run across component instantiation routines with over 200 if-else, which can easily be replaced with one line of Class.forName().






