Skip to content
Core CSbeginner · 45 min

OOP Concepts

Object-oriented design: encapsulation, inheritance, polymorphism, and abstraction — plus the SOLID principles and when composition beats inheritance.

The four pillars

Encapsulation hides internal state behind a public interface. Abstraction exposes only the essential behaviour. Inheritance lets a subclass reuse/extend a base class (an 'is-a' relationship). Polymorphism lets different types respond to the same interface, so callers don't branch on concrete type.

SOLID & composition

SOLID: Single responsibility, Open/closed, Liskov substitution, Interface segregation, Dependency inversion — guidelines for maintainable OO design. 'Favour composition over inheritance' avoids fragile deep hierarchies: build behaviour by combining objects ('has-a') rather than inheriting it.

Resources

Practice & test yourself

Take the quiz →