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

What’s Being Compared

The four fundamental principles of object-oriented programming in Java: encapsulation, inheritance, polymorphism, and abstraction. Each addresses a distinct concern in software design, but together they form a cohesive paradigm.

The Core Tension

The four pillars balance competing goals: encapsulation hides state (safety), inheritance shares code (reuse), polymorphism enables flexibility (adaptability), and abstraction reduces complexity (clarity). Over-emphasizing any one pillar leads to design problems — rigid hierarchies from overusing inheritance, or anemic models from over-encapsulation.

Comparison

DimensionEncapsulationInheritancePolymorphismAbstraction
PurposeData hidingCode reuseRuntime flexibilityComplexity reduction
MechanismAccess modifiers, getters/settersextends, superMethod overriding, overloadingAbstract classes, interfaces
Java keywordprivate, protectedextends@Override, overloaded namesabstract, interface
Anti-patternAnemic domain modelDeep hierarchy, fragile base classType-checking with instanceofLeaky abstraction

The Insight

The four pillars are not independent — they reinforce each other. Encapsulation protects the internal state that inheritance extends. Polymorphism enables the runtime dispatch that abstraction promises. A well-designed Java class system uses all four in concert: encapsulation hides data, inheritance shares behavior, abstraction defines contracts, and polymorphism enables substitution.

Connections