Abstraction and Refinement

Abstraction and refinement are two ways to think about building inheritance hierarchies. Abstraction lets you build a hierarchy from the bottom up, using concrete classes to build parent classes. Refinement lets you build a hierarchy from the top down, using more general classes to build more specific classes.

Abstraction

In abstraction, or generalization, you analyze two or more related classes and extract their common features into a parent class.

For example, suppose that you are writing a role-playing game and you know you want a Dragon class and a Goblin class. You want the Dragon class to have properties HitsToKill and Speed, and you want it to have methods Bite and BreathFire. You want the Goblin class to have

Get Start Here!™ Fundamentals of Microsoft® .NET Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.