The Cognitive Shift
In procedural code, data is passive (a list of raw dictionaries) and functions act upon it from the outside.
In object-oriented design, the object is an autonomous entity responsible for maintaining its own internal state invariants and defending against invalid mutations.
State + Behavior = Cohesive Entity
1. State (Attributes)
What the object remembers: balance, user_id, email, status.
2. Behavior (Methods)
What the object can do: withdraw(), deposit(), verify_identity().
Quick Summary
- Classes define the blueprint; Objects are autonomous instances living in memory.
- Next, we explore Encapsulation — hiding internal details to protect state.