On this page
Object-Oriented Programming
Prev: Imperative & Procedural Programming | Up: paradigms | Next: Functional Programming
Rel: Python OOP, Python Object & MRO, JS Prototype Chain, Modularity, Cohesion & Coupling
Ref: Wikipedia — Object-Oriented Programming
Tags: #public #prog #programming #paradigms #oop
Contents
- > Encapsulation & Polymorphism
- > Class-Based vs. Prototype-Based Dispatch
- > Composition Over Inheritance
Encapsulation & Polymorphism
OOP groups state and the operations that preserve its invariants into objects:
- Encapsulation: hides internal representation behind a public interface so invariants cannot be bypassed.
- Polymorphism: lets callers operate on any object implementing a shared interface (virtual method tables / dynamic dispatch / traits / protocols) without switching on concrete types.
Class-Based vs. Prototype-Based Dispatch
- Class-based (Python, Java, C++): instances are stamped from class blueprints; method lookup walks the class hierarchy / MRO.
- Prototype-based (JavaScript): objects delegate directly to other objects via a prototype chain.
Composition Over Inheritance
Deep inheritance hierarchies tightly couple subclasses to parent internals (the fragile base class problem). Prefer composition (holding collaborator objects that implement small interfaces) over multi-level class inheritance.
Linked from
- tuts/c/pointers_and_memory/function_pointers_and_callbacks
- tuts/java/language_and_oop
- tuts/programming/paradigms
- tuts/programming/paradigms/functional_programming
- tuts/programming/paradigms/imperative_and_procedural
- tuts/programming/paradigms/object_oriented_programming
- tuts/programming/software_design/modularity_cohesion_and_coupling
- tuts/rust/ownership_and_internals/traits_generics_and_dispatch
Related notes
- tuts/programming/paradigms Linked here; links to this page; shared tags: #paradigms, #prog, #programming
- tuts/programming/paradigms/functional_programming Linked here; links to this page; shared tags: #paradigms, #prog, #programming
- tuts/programming/paradigms/imperative_and_procedural Linked here; links to this page; shared tags: #paradigms, #prog, #programming
- tuts/programming/software_design/modularity_cohesion_and_coupling Linked here; links to this page; shared tags: #prog, #programming
- tuts/java/language_and_oop links to this page; shared tags: #oop, #prog
- tuts/c/pointers_and_memory/function_pointers_and_callbacks links to this page; shared tags: #prog
- tuts/python3/tutorials/intermediate_python_and_software_engineering/object_oriented_programming Linked here; shared tags: #oop
- tuts/rust/ownership_and_internals/traits_generics_and_dispatch links to this page; shared tags: #prog
- tuts/javascript/tutorials/prototype_chain_and_new_flow Linked here
- tuts/python3/tutorials/advanced_python_internals/python_object_mro_and_initialization Linked here