• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Procedural programming organizes code as a sequence of instructions operating on global data. As programs grow, this approach leads to scattered, interdependent code that is hard to maintain, test, and reuse. A change in one function can break others, and there is no natural way to model real-world entities.

Core Idea

Object-Oriented Programming offers several key advantages over procedural programming: code reusability (classes and objects allow reuse of existing code, reducing duplication), better structure and maintainability (programs are organized into logical units), supports the DRY principle (common functionality is written once), and faster development (modular components enable quicker and scalable application development).

How It Works

Reusability works through inheritance (subclasses reuse parent code) and composition (objects contain and delegate to other objects). Structure comes from classes grouping related state and behavior into single units. The DRY principle is enforced through class hierarchies — write common code in the base class, specialize in subclasses. Faster development results because well-designed classes become reusable components that can be composed like building blocks.

Visual Explanation

oop_advantages Procedural Procedural --- Functions on global data Duplicated logic Hard to maintain No real-world mapping OOP Object-Oriented --- Classes + Objects Inheritance reuses code Encapsulated state Models real entities Procedural->OOP vs Reuse Code Reusability One class, many objects Inherit, don't rewrite OOP->Reuse Structure Better Structure Logical units Easier debugging OOP->Structure DRY DRY Principle Write once Use everywhere OOP->DRY Speed Faster Development Build on existing classes Modular composition OOP->Speed

Semantic Network

semantic_oop_advantages THIS OOP Advantages OOP OOP in Java THIS--OOP derived from CODE Code Reusability THIS--CODE related DRY DRY Principle THIS--DRY related

Key Properties

  • Code reusability: Inheritance and composition enable reuse across the codebase
  • Better structure: Logical units (classes) with clear responsibilities
  • DRY principle: Common functionality centralized in one place
  • Faster development: Pre-built components accelerate new feature creation
  • Scalability: Modular design makes it easier to add features without breaking existing code
  • Maintainability: Changes are localized to specific classes, reducing side effects

Connections

Edge Cases & Gotchas

  • Over-engineering: The structure and abstraction that make OOP powerful for large systems add unnecessary complexity to small programs
  • Reuse isn’t free: Inheritance creates coupling between parent and child — changes to parent can break children