Object-Oriented Programming (OOP) is a programming paradigm that organizes software around objects — self-contained units that bundle together data (called properties or attributes) and behavior (called methods or functions) that operate on that data. Instead of writing a program as a list of instructions that manipulate separate data structures, OOP models a program as a collection of interacting objects, each representing a real-world or conceptual entity.
For example, in a banking application, a BankAccount object might hold data like balance and accountNumber, along with behavior like deposit() and withdraw(). The object controls its own data — external code can't reach in and corrupt the balance directly; it must go through the object's methods.
The four pillars of OOP (explored in depth in later chapters) are:
- Encapsulation — bundling data and behavior together, and hiding internal details
- Abstraction — exposing only what's necessary, hiding complexity
- Inheritance — building new classes on top of existing ones, reusing and extending behavior
- Polymorphism — letting different objects respond to the same interface in their own way
OOP is the dominant paradigm behind most modern software — Java, C++, C#, Python, PHP, Ruby, and Swift are all OOP languages (among others), and it remains the standard approach for building large, maintainable applications, even as functional programming ideas increasingly complement it.