views:

577

answers:

6

What causes a computer program to turn into a Big Ball of Mud? Is it possible to recover from this anti-pattern? Are there proven refactoring methods that can be applied?

+1  A: 

The only time I had to deal with a "BBOM" scenario, we basically had to revisit the requirements with the users and infer what we could from the horrendous code. As with all BBOMs, the issue doesn't usually make itself apparent until there's some maintenance/enhancement needed. (No luxury of code review at this shop, the criteria was sadly "does it do what they want?") And the "author" is long gone.

Refactoring wasn't even possible in this case.

curtisk
A: 

This might shed some light on the original question.

http://en.wikipedia.org/wiki/Big_ball_of_mud

Coxy
thanks, coxy :-) what i've heard of is not always what everyone else have heard of, of couse! The "big ball of mud" anti-pattern is really something to learn from, so thanks for linking!
comichael
+11  A: 

A Big Ball Of Mud normally occurs because of one of the following:

  • Change of Requirements - You architect a solution with one set of requirements, which over time change and now, you are probably catering to a different audience who wants to use the same product with slightly different requirements. You bake those requirements into the same product and you end up with a BBOM.

  • Change of Developers - The original product has been created by one set of developers with certain design and architectural assumptions which are not entirely evident to a whole new set of developers who 'take over' the product for maintainence or further development. The new developers make their own assumptions and over time, the product degrades into a pile of unmaintainable junk.

  • Incompetency - of the developers (they are unaware of anti-patterns), the management (too demanding, lack of knowledge of the product) or the users (they don't really know what they need). This is hard to solve.

Sometimes, the best solution is simply to rewrite the application catering to the new requirements. But this is normally the worst case scenario. The cumbersome solution is to stop all new development, start by writing a set of tests and then redesign and rearchitect the whole solution. This could take years, depending on the size of the product, though.

Anirudh
Kudos... well formulated answer.
ojblass
anirudth - sounds like you got some experience to share"the product degrades into a pile of unmaintainable junk." -yep that's the BBOM's i got in my company :9
comichael
comicheal - to be frank it is hard to deal with such code. Two approaches come to mind depending on the amount of time you have - rewrite or refactor as you go along. We did both - refactored a current version and built a new release from scratch.
Anirudh
+1  A: 

The pertinent quote from the wikipedia article that answers yours is:

Programmers in control of a big ball of mud project are strongly encouraged to study it and to understand what it accomplishes, and to use this as a loose basis for a formal set of requirements for a well-designed system that could replace it.

Vladiat0r
Usually is not an option to replace it, so redesign and rearchitect the whole solution as Anirudh said is the solution
JuanZe
+2  A: 

BBOMs I have encountered were usually created organically, in a Darwinian process. It goes something like this:

  1. Initally, a system is created (not designed) and poorly documented.

  2. Original resources go on to create more havok elsewhere, so there isn't even an oral history for this "legacy" system.

  3. Fresh blood is brought in. These developers try to uncover workings of various system parts, but it's like several blind men trying to understand the elephant when one has grabbed the tail, one a leg, and one the trunk. They make changes but never really feel confident about them.

  4. In this way, a system "evolves" by blind natural selection, but parallel to this is an evolution of the most intractable, unreproducible bugs that persist precisely because they remain under the radar screen, until of course they surface at a customer installation.

Buggieboy
+2  A: 

I always attributed the term (BBOM) to a code-base in which "everything depends on everything" and it is hard to find the code you want to change, and when you do make a change you end up having to change stuff all over the place to make it work again. You need the whole code-base in order to test a single changed class/file. Uncle Bob calls this the Morning After Syndrome (here under Acyclic Dependencies Principle).

It's pretty much inevitable that a code base will (ahem) devolve into a BBOM in the absence of basic dependency control because it can't be done by developers that see no more than the code they are currently editing.

Chris Chedgey