Revision Notes/OOP Principles
Field Entry - OOP Principles
Encapsulation
Bundling data and the methods that operate on it within one class, and hiding internal details from the outside world.
Field Note - Real-world Analogy
“Like a capsule pill. The medicine (data) is inside the capsule (class). You don't directly touch the medicine — you take the whole capsule. The capsule controls how the medicine is released. The internal contents can change (different formulas) without you doing anything differently.”
Field Observations - Key Topics Covered
Encapsulation means the object controls its own data. Instead of anyone being able to reach in and change a field directly, you access it through methods the object provides. This lets the object validate changes, enforce rules, and maintain consistency.
4 more observations inside
Sign in to read every key point in full
Ready to go deeper?
Open the complete revision note.
Sign in to read every field observation in full, including a runnable code example and side-by-side comparisons with related patterns.
Read Full NotesSee Also in OOP Principles