Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In this chapter, we’ll start by looking at the three kinds of relationships that can exist between types, and then back up a bit to examine the fundamental principles of object-oriented programming. Finally, we’ll examine the C# modifiers that allow you to control how the types in your application interact.
We’ll begin by exploring the four types of relationships that can exist between types, IsA, HasA, CanDo and CanBe, and how they’re represented in the .NET Framework.
There are four basic principles that are fundamental to object-oriented programming: ABSTRACTION, the elimination of unnecessary or irrelevant detail; INHERITANCE, the ability of types to inherit behavior from a base; ENCAPSULATION, the hiding of implementation details; and POLYMORPHISM, the ability of derived classes to be substituted for their ancestors. We’ve already seen examples of all of these principles, but in the second section of this chapter, we’ll examine the principles themselves, and how to implement them in your class hierarchies.