EMZETT.
Login

OOP (Object-Oriented Programming)

In short: A programming paradigm that bundles data and the functions that operate on that data together into classes, instead of keeping data and logic strictly separate.

In more detail: The four central principles of OOP are encapsulation (protecting data from direct access), inheritance (classes build on each other), polymorphism (same call, different behaviour depending on the concrete object), and abstraction (hiding complexity behind a simple interface). The counterpart is procedural or functional programming, where data and functions stay separate.

In Depth

The basic idea of OOP arose from the observation that real systems can often be naturally modelled as a collection of interacting “things” with their own state and their own behaviour — a bank account, a car, a user profile. Instead of managing data (the account balance) and logic (depositing/withdrawing) in separate structures, OOP bundles both in a class:

// Procedural: data and logic separate
struct Account { double balance; }
void deposit(Account a, double amount) { a.balance += amount; }
 
// Object-oriented: data and logic together in a class
class Account {
    private double balance;
    void deposit(double amount) { this.balance += amount; }
}

The four core principles at a glance, with their respective key question:

  • Encapsulation: who’s allowed to access the data?
  • Inheritance: how do related classes share common code?
  • Polymorphism: how can the same call react differently depending on the concrete object?
  • Abstraction: what does a user of the class need to know — and what not?

OOP is one of the most widespread paradigms (Java, C#, Python, C++, TypeScript all support it directly), but not the only sensible one — functional programming (emphasis on immutable data and pure functions with no side effects) and procedural programming (simple sequences of statements and function calls with no object model) often solve certain problems more elegantly. Many modern languages are now “multi-paradigm” and allow mixing object-oriented and functional style tools depending on the situation, instead of committing strictly to one.

A frequently cited criticism of OOP is the tendency towards deep inheritance hierarchies, which become confusing and hard to change over time (the “fragile base class problem”) — as a remedy, many experienced developers today generally recommend “composition over inheritance”: achieve behaviour by composing small, independent objects rather than through ever-deeper class hierarchies.

See also: Classes, Objects, Encapsulation, Inheritance, Polymorphism, Abstraction