Move Method

Definition:

This refactoring implies moving a method to a different class (or other classification system, depending on the language). It implies updating all references to the old method location to the new one and making sure all parameters follow accordingly. This refactoring is crucial to maintaining cohesion and to properly migrate responsibilities when the need arises.

Triggers:

Multiple accesses to the internal data of a class (foo.getA(); foo.getB(); foo.getC()) often mean that the method accessing the data (or part of it) should be moved to the class containing the data itself.

Methods with many parameters are also interesting candidates : if all or most parameters belong to the same entity, then the method itself might need relocation to the entity.

Forces:

Law of Demeter

Tell Don't Ask

Responsibility Driven Development

Single Responsibility Principle

High Cohesion/Low Coupling

Encapsulation