tags:

views:

157

answers:

3

Robert C. Martin in one of his book mention about viscosity as a symptom of rotting design. I don't fully understand idea of viscosity in software development. Could you give me some examples?

+10  A: 

As code gets older, it gets more full of hacks, and more full of dependencies, and consequently gets harder to change without breaking something.

So it gets less "fluid" and more "solid", hence the analogy to viscosity.

RichieHindle
+7  A: 

He has two uses, viscosity of design and viscosity of environment.

First, fluids with high viscosity, like toothpaste and peanut butter, don't flow as smoothly as low-viscosity fluids like water.

High-viscosity design makes it easier to make a hack than to preserve the design. The hack makes the code even more rigid, increasing the viscosity even further.

Viscosity of environment refers to work flow. If compile times are long, or it's a pain to build the system or run the tests, programmers will take shortcuts to ease the pain.

Bill the Lizard
+2  A: 

Viscosity is the ability of a liquid to resist changes from external forces. Water is the basis for the measure and has a very low viscosity (i.e. it will flow freely from one place to another given a path), while, say, yogurt which has such a high viscosity when chilled that it is almost a solid and pretty much stays where you put it (unless you are wearing light colored pants in which case it finds its way there every time...).

In software, this translates to how much your code resists changes. If you have a lot of dependencies, then it can be difficult to alter a major class, thus leading to less-than-ideal workarounds which in turn increase the code's resistance (increasing its viscosity). Well designed code (low viscosity) can be updated and added to without having a major impact on applications or other classes which depend on it.

Rob Allen