Extract Class


Extract Class replaces a set of fields with a new container object. All references to the fields are updated to access the new container object. This refactoring helps to group fields which logically belong together.

The following example demonstrates how to extract the fields x,y,z to a new class Position:

The refactoring results in the creation of a new Position class which is used in the original class:

This refactoring has been introduced in Eclipse 3.4. To execute the Extract Class refactoring, select a type and invoke Refactor > Extract Class.