O'Reilly logo

Refactoring Workbook by William C. Wake

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Accommodating Change

Some problems become most apparent when you try to change your code. (Most of the other smells we've discussed can be detected by looking at the code statically.)

Ideally, one changed decision affects only one place in the code. When it doesn't work out that way, it's a sign of duplication in the code.

Addressing these smells often has a side benefit: Many times it makes the code easier to test.

Smells Covered

  • Divergent Change

  • Shotgun Surgery

  • Parallel Inheritance Hierarchies

  • Combinatorial Explosion

Divergent Change

Symptoms

  • You find yourself changing the same class for different reasons. (For contrast, see Shotgun Surgery, the next smell we look at.)

Causes

The class picks up more responsibilities as it evolves, with no one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required