search
Get Started
search
Extract Superclass - Jetbrains Native Refactoring
zoom_in Click to enlarge

Extract Superclass

language

description Extract Superclass Overview

Extract Superclass is a software refactoring technique available in JetBrains integrated development environments like IntelliJ IDEA. The feature automates the process of creating a new parent class by pulling selected methods and fields up from an existing child class. This allows developers to establish shared behavior and restructure object-oriented inheritance hierarchies without manually cutting and pasting code. It is primarily utilized by software engineers to reduce code duplication and improve architectural organization.

help Extract Superclass FAQ

What code does JetBrains Extract Superclass create?

The refactoring creates a new parent class and makes the original class inherit from it. Selected fields and methods can move into the parent, while selected method declarations can be made abstract and left implemented in the child.

Where is Extract Superclass in IntelliJ IDEA?

Open the source class and choose Refactor, Extract, Superclass from the main menu. The dialog lets you name the parent, choose its package and select the members that will form it.

When should I use Extract Superclass instead of Extract Delegate?

Use Extract Superclass when the extracted behavior represents a genuine parent type that other classes may share. Use Extract Delegate when composition is more appropriate and the original class should contain a helper rather than enter a new inheritance hierarchy.

Will Extract Superclass update existing usages automatically?

IntelliJ IDEA can extract the superclass and propose replacing compatible references to the original class with the new parent type. Preview the changes first because APIs, dependency injection and serialization code may rely on the concrete class.

Reviews & Comments

Write a Review

rate_review

Be the first to review

Share your thoughts with the community and help others make better decisions.

Save to your list

Save your favorites and follow how their scores change over time.

Save favorites
Track changes
Compare scores

Already have an account? Sign in

Compare Items

See how they stack up against each other

Comparing
VS
Select 1 more item to compare