Object-Oriented Programming
Learn how to model users, orders, payments and products as objects, and when plain functions are the better answer.
Lessons in order
- 01Beginner 11 min
Class — The Blueprint
A class describes what a kind of thing knows and what it can do. Learn what belongs in one and what does not.
- 02Beginner 11 min
Object — One Real Instance
What actually happens when you create an object, how identity differs from equality, and why two objects with the same data are not the same object.
- 03Beginner 11 min
Constructor — Starting in a Valid State
Why the constructor is the best place to enforce rules, how to keep it small, and when to use alternative constructors instead.
- 04Beginner 12 min
Encapsulation — Protecting What Matters
Expose a small, stable surface and keep internals private, so you can change how something works without breaking everyone who uses it.
- 05Beginner 13 min
Inheritance — Sharing Behaviour
Build specialised classes from a general one, use super() correctly, and recognise the point where inheritance becomes a liability.
- 06Beginner 12 min
Polymorphism — One Call, Many Behaviours
Let each type handle itself so calling code stops branching. Learn duck typing, dispatch, and why this makes adding features cheap.
- 07Intermediate 12 min
Abstraction — Showing Only What Matters
Describe what something does without saying how, so the how can change. Learn interfaces, abstract classes and the right level of detail.
- 08Intermediate 12 min
Composition — Building From Parts
Assemble behaviour by holding other objects instead of inheriting from them, and keep each part small, focused and replaceable.
- 09Intermediate 13 min
Composition vs Inheritance — Choosing
A clear rule for deciding between the two, the combinatorial explosion that kills inheritance, and how to refactor when you chose wrong.