Cover page by Don Roberts, William Opdyke, Kent Beck, Martin Fowler, John Brant

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Chapter 7. Moving Features Between Objects

One of the most fundamental, if not the fundamental, decision in object design is deciding where to put responsibilities. I’ve been working with objects for more than a decade, but I still never get it right the first time. That used to bother me, but now I realize that I can use refactoring to change my mind in these cases.

Often I can resolve these problems simply by using Move Method (142) and Move Field (146) to move the behavior around. If I need to use both, I prefer to use Move Field (146) first and then Move Method (142).

Often classes become bloated with too many responsibilities. In this case I use Extract Class (149) to separate some of these responsibilities. If a class becomes too irresponsible, ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required