Object-Oriented Programming (OOP)
A programming paradigm modeling software as interacting objects with state and behavior. Promotes modularity, reuse, and information encapsulation.
Classification
- ComplexityMedium
- Impact areaTechnical
- Decision typeArchitectural
- Organizational maturityIntermediate
Technical context
Principles & goals
Use cases & scenarios
Compromises
- Incorrect domain modeling leads to hard-to-maintain code
- Overly complex hierarchies increase cognitive load
- Misuse of inheritance over composition causes bottlenecks
- Prefer composition over inheritance
- Small, focused classes with clear responsibility
- Program to interfaces and use abstractions
I/O & resources
- Domain requirements and use cases
- Existing architecture and interface descriptions
- Team experience with OOP principles
- Class diagrams and API specifications
- Modular, reusable components
- Test coverage for classes and interfaces
Description
Object-oriented programming is a foundational paradigm that organizes systems as collections of objects with attributes and methods. It uses concepts like classes, encapsulation, inheritance, and polymorphism to reduce complexity and increase reuse. OOP shapes design and architectural choices across many programming languages.
✔Benefits
- Improved modularity and code reuse
- Better abstraction of complex domains
- Easier testability and maintainability through clear boundaries
✖Limitations
- Can lead to excessive layering and boilerplate
- Not always optimal for very simple or data-oriented tasks
- Inheritance can create rigid coupling and fragility
Trade-offs
Metrics
- Cohesion
Measure of how related the methods and data are within a class.
- Coupling
Measure of dependencies between classes or modules.
- Number of public methods per class
An indicator of responsibility scope and surface area of a class.
Examples & implementations
Bank account class model
A typical example with account, customer and transaction classes demonstrating encapsulation and inheritance.
GUI components with inheritance
Base class for UI components and specialized widgets that encapsulate rendering and event handling.
CMS platform plugin system
Plugins implement defined interfaces, are loaded and operated via a common API.
Implementation steps
Analyze domain and identify core concepts
Define interfaces and class responsibilities
Implement, test and refactor iteratively
⚠️ Technical debt & bottlenecks
Technical debt
- Outdated inheritance structures making refactoring hard
- Unclear ownership of classes and responsibilities
- Missing tests for critical classes
Known bottlenecks
Misuse examples
- Using inheritance for reuse instead of extraction
- Creating many tiny, unnecessary classes without clear benefit
- Public mutable fields instead of controlled access methods
Typical traps
- Excessive abstraction hides simple bugs
- Undefined interfaces lead to implicit dependencies
- Refactoring without tests endangers behavior
Required skills
Architectural drivers
Constraints
- • Language limitations and runtime costs
- • Compatibility requirements with existing APIs
- • Team skills in OOP design principles