OOP Principles

11. OOP Principles#

Classes alone do not make a program object-oriented. This chapter names and illustrates the core object-oriented principles: encapsulation, inheritance, polymorphism, and abstraction, with concrete C# examples.

  • Encapsulation: Objects protect their internal state and expose a controlled public surface.

  • Inheritance: A derived class can reuse and specialize behavior from a base class.

  • Polymorphism: Code can work with a general type while runtime objects provide specific behavior.

  • Abstraction: Interfaces and abstract classes describe capabilities without committing to one implementation.

  • Composition: Modern C# often favors combining small objects over building deep inheritance trees.

The goal is conceptual clarity and practical design judgment, especially knowing when interfaces and composition are cleaner than deep hierarchies.

Video

C# for Beginners – Lesson 15: Inheritance, Polymorphism & Abstraction by Mike’s Code.

This video remains hosted on YouTube and is the property of its original creator or rightsholder; it is embedded here via YouTube’s official player for educational reference only.

Learning Objectives

By the end of this chapter, you will be able to:

  1. Explain the four major object-oriented principles with concrete examples

  2. Relate encapsulation to the class design practiced in the Classes chapter

  3. Create a small inheritance hierarchy with base and derived classes

  4. Use overriding or interfaces to support polymorphic behavior

  5. Explain why composition and interfaces are often preferred over deep inheritance

Chapter Flow