We break down why, in OOP, it’s beneficial to keep behavior next to data: we move “external” functions into the class as methods, learn to call them with dot syntax, and understand why methods can “see” an object’s properties. Separately, we discuss mutable state via
var, the nuance of a
val reference, the role of
this when names conflict, as well as invariants and checks via an early
return,
require/
check — so that an object remains valid even with incorrect input.