← All concepts

A tiny picture book

What is OOP?

It's just toy robots. Really.

The Class

First, a blueprint.

Before you build a toy robot, you draw the plan. Every robot arm, every eye, goes here. The plan itself is not a toy — you can't play with it.

The Object

Now build real toys.

You can make as many robots from one plan as you want. Each one is a real, separate toy — you can pick it up. These are called objects.

color: purple height: tall battery: full
Properties

Every toy has details.

Its color. Its size. How much battery is left. These little facts about one robot are its properties — and each robot keeps its own.

beep!
Methods

And every toy can do things.

Wave. Walk. Say "beep!" These actions are built into the robot too. In code, we call them methods — the things an object can do.

+ a hat!
Inheritance

Some robots are family.

A "Racer Robot" plan can start from the regular robot plan, keep everything it already does, then add something new — like a hat, or extra speed.

The four big ideas

Grown-ups gave these four toy-robot habits fancy names. Here's what they actually mean.

Pillar 1

Encapsulation

The wires and gears are sealed inside the case. You just press the one button on the outside.

GO
Pillar 2

Abstraction

The remote just has a "GO" button. You don't need to know how the motor inside actually works.

Pillar 3

Inheritance

A new robot plan borrows an old plan's tricks, then tapes on something extra of its own.

beep
Pillar 4

Polymorphism

Press the same "GO" button on three different robots — one waves, one spins, one beeps.

The whole book, in four toys

Class
the plan
→
Object
the toy
→
Property
what it has
→
Method
what it does

That's it. That's object-oriented programming.