Skip to Content
Refactoring: Improving the Design of Existing Code
book

Refactoring: Improving the Design of Existing Code

by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts
June 1999
Intermediate to advanced
464 pages
10h 55m
English
Addison-Wesley Professional
Content preview from Refactoring: Improving the Design of Existing Code

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, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Refactoring: Improving the Design of Existing Code

Refactoring: Improving the Design of Existing Code

Martin Fowler
Design Patterns: Elements of Reusable Object-Oriented Software

Design Patterns: Elements of Reusable Object-Oriented Software

Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Publisher Resources

ISBN: 0201485672Purchase book