Object-Oriented Programming
Subject: Computer and Technology noun /ˌɑːb.dʒɪkt ˈɔːr.i.ɛn.tɪd ˈproʊ.ɡræm.ɪŋ/ 1 definition
- programming-paradigms
- software-engineering
- programming-languages
- software-architecture
-
Definition (noun)
Entry #148 · UpdatedObject-Oriented Programming (OOP) is a software design and programming paradigm that models programs as collections of interacting objects—self-contained units that encapsulate internal state (fields or attributes) alongside the behaviors (methods) permitted to inspect or modify that state. Built around core principles such as encapsulation, abstraction, inheritance, and polymorphism, OOP allows developers to hide implementation details behind explicit interfaces, share common structure across related types, and substitute specialized behaviors uniformly at compile time or runtime. Unlike procedural programming, which separates passive data structures from sequences of functions that mutate them, or pure functional programming, which favors immutable data and stateless transformations, OOP organizes program architecture around localized state ownership and message passing between discrete components.
Common Forms
Class-Based OOP: Organizes objects around explicit blueprint definitions (
classdeclarations) that specify data layouts, methods, visibility rules, and inheritance hierarchies, as used in Java, C++, C#, and Python.Prototype-Based OOP: Creates objects directly without separate class templates by cloning or delegating shared properties and methods along dynamic prototype chains, as seen in JavaScript and Self.
Pure Message-Passing OOP: Treats every runtime value—including numbers, booleans, and classes themselves—as an object that communicates by sending messages rather than calling standalone functions on primitive data, as pioneered by Smalltalk and reflected in Ruby.
Trait- and Interface-Based OOP: Emphasizes small behavioral contracts and composable traits or mixins over deep single-inheritance hierarchies, enabling unrelated types to share capabilities flexibly in languages such as Swift, Scala, and TypeScript.
Example
In a banking application, an abstract
BankAccountclass encapsulates a privatebalancefield and exposesdeposit(amount)andwithdraw(amount)methods that enforce validation rules instead of letting external code overwrite the balance directly. Subclasses such asCheckingAccountandSavingsAccountinherit this shared state management while overridingwithdraw(amount)to apply transaction fees or monthly limits, allowing the billing service to process all account types through a single uniform interface.