Code Safari

Chapter 99·Beginner·8 min read

What Is Object-Oriented Programming? Objects, Classes, and the Big Idea

A plain-English, language-agnostic introduction to object-oriented programming — what an object is, how a class differs from an object, why bundling state with behaviour matters, and a map of the four pillars to come. Concepts, not syntax.

July 15, 2026

Most code you'll read and write in a career is organised around one idea: objects. Object-oriented programming (OOP) is a way of structuring a program as a collection of self-contained units that each hold some data and expose some behaviour. It isn't a language — Java, Python, C#, Ruby, TypeScript and many others all support it — so it's worth learning as a concept, independent of any one syntax. Everything in this guide uses plain pseudocode.

Before objects: scattered data and functions

In purely procedural code, data and the functions that act on it are separate. You have variables holding a balance somewhere, and functions like deposit(balance, amount) elsewhere. Nothing stops any part of the program from changing that balance directly, and nothing keeps the rules ("you can't go below zero") in one place. As a program grows, that separation gets hard to reason about: to understand one value, you may have to trace every function that touches it.

OOP's answer is to put the data and the code that's allowed to touch it in the same place.

What an object is

An object bundles two things procedural code keeps apart:

  • State — the data it owns (an account's balance).
  • Behaviour — the operations on that data (deposit, withdraw).

A bank account object holds a balance and knows how to deposit and withdraw. Crucially, the behaviour is the only sanctioned way to change the state — so the account's rules live right next to the data they protect.

Object: Account
State: balance = 100
Behaviour: deposit(), withdraw()
An object keeps state and behaviour together

Class vs object

People mix these up, so it's worth nailing down:

  • A class is the blueprint. It says "an account has a balance and can deposit and withdraw."
  • An object is one thing built from that blueprint — an instance. Each object has its own copy of the state.
class Account:
    balance = 0
 
    method deposit(amount):
        balance = balance + amount
 
    method withdraw(amount):
        if amount <= balance:
            balance = balance - amount
 
alice = new Account()   # one object
bob   = new Account()   # a separate object, its own balance
alice.deposit(100)      # alice's balance is 100; bob's is still 0

One class, many objects — each with independent state. alice and bob follow the same blueprint but never share a balance.

The four pillars, at a glance

OOP is usually summarised as four pillars — principles for building objects that stay correct and easy to change. This guide gives each its own chapter:

PillarOne-line idea
EncapsulationKeep data private; expose a small set of methods.
AbstractionShow what an object does, hide how.
InheritanceDefine a type in terms of another ("is-a").
PolymorphismOne call, many behaviours.

And once you know the four, there's a fifth idea you'll hear constantly — composition over inheritance — which gets the final chapter.

Recap

  • OOP structures a program as objects that bundle state (data) with the behaviour that acts on it.
  • An object is one self-contained unit; a class is the blueprint it's built from. One class, many objects, each with its own state.
  • Keeping data and behaviour together buys local reasoning — you understand one object at a time.
  • The four pillars (encapsulation, abstraction, inheritance, polymorphism) are principles for doing this well.

Now to the first and most fundamental pillar — protecting an object's data behind a small interface. Continue to Encapsulation.

What Is Object-Oriented Programming? Objects, Classes, and the Big Idea | Code Safari