Chapter 10. Responsibility

It's hard to get the right balance of responsibility between objects. One of the beauties of refactoring is that it lets us experiment with different ideas in a way that safely lets us change our minds.

There are tools we can use to help us decide how our objects should work together, namely, design patterns and CRC cards (see www.c2.com/cgi/wiki?CrcCards).

Refactorings are often reversible, and they may trade off between two good things. A nice example of this is Message Chains versus Middle Man. Sometimes there's a way to improve both smells at the same time, but many times it's a balancing act between them.

Smells Covered

  • Feature Envy

  • Inappropriate Intimacy (General Form)

  • Message Chains

  • Middle Man

Feature Envy

Symptoms

  • A method ...

Get Refactoring Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.