# Generalization vs Specialization

Generalization moves what classes share into one parent class, and specialization keeps what makes each child class different.

Apprentice · Java · OOP · Updated November 16, 2026

By Gregor Dzierzon

## Generalization

Generalization is the process of finding all variables and methods that each class has in common. We generalize these variables by extracting them into their own class.

The black variables and methods are what all classes have in common. They should be put into one “general” class from which the others can inherit. Since the `Character` class contains all of the common attributes, it is the ideal candidate to be the general class.

![similar classes should extract common variables and methods](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/09/5cd0913206fd4e7d87d333febd239848.png "similar classes should extract common variables and methods")

## Specialization

Specialization is the process of finding the variables and methods that make a class different from all other classes.

For instance, an `archer` has `arrows`, a `wizard` has `mana`, and a `knight` has `armor`. These attributes differentiate the archer, the wizard, and the knight from each other and from all other characters.

![Wizard and Knight as specialized classes](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/09/850cf30099b14a4a950a948e4a3b28ab.png "Wizard and Knight as specialized classes")

## Cheat sheets

- [Introduction to Inheritance and Generalization vs Specialization](https://www.ask-codey.com/cheat-sheets/introduction-to-inheritance-an-overview-cheat-sheet)

Source: https://www.ask-codey.com/lessons/introduction-to-inheritance-generalization-vs-specialization
