O'Reilly logo

Start Here!™ Fundamentals of Microsoft® .NET Programming by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required