Extract Class refactoring

Last modified: 21 March 2024

This refactoring allows you to move members of an existing class to a new class. It will be helpful when you need to replace a single class that is responsible for multiple tasks with several classes each having a single responsibility.

JetBrains Rider will automatically create a reference field that will provide access to the newly created class. If necessary, you can also leave the extracted members in the original class as copies or so that the implementation is delegated to the same members in the new class.

In the example below, we extract the LogError method into the new Logger class

JetBrains Rider. Extract class refactoring