Generalization
noun
say it: “jen-er-ul-ih-ZAY-shun” /ˌdʒɛnərəlɪˈzeɪʃən/
Moving the properties and methods that several classes share up into one base class.
What is Generalization?
Generalization — Spotting what several classes have in common and moving it up into one base class. Book and Magazine both have a title and a price, so those move into LibraryItem, written once.
class LibraryItem { public string Title { get; set; } = ""; public decimal Price { get; set; } }
class Book : LibraryItem { public string Author { get; set; } = ""; }
class Magazine : LibraryItem { public int Issue { get; set; } }
In a sentence
- “Through generalization, Book and Magazine now share Title and Price from LibraryItem.”
Level: Journeyman · More OOP terms at this level
Updated