Encapsulation
Domain: Programming Fundamentals
π― Motivation
Hiding internal details and only exposing a clean interface prevents other code from accidentally breaking things.
π Concrete Example
A BankAccount class hides its balance variable. You can only change it through deposit() and withdraw() methods that check rules.
π Analogy
A carβs engine - you donβt directly control the spark plugs. You press the gas pedal (interface), and the engineβs internals (encapsulated details) handle the rest.