Object-Oriented Programming
Classes, inheritance and polymorphism as moving diagrams, not definitions.
- 61Classes and ObjectsStamp objects off a class blueprint, give each its own state, then lock a field down with encapsulation
- 62References, the Heap, and AliasingTrace new step by step as it allocates a Dog on the heap, then copy the reference and watch two names change one object
- 63EncapsulationGive a bank account one rule, break it through a public field, then make the field private so the object can refuse the writes that would violate it
- 64InheritanceBuild a robot family tree and watch method lookup climb the chain until an override wins
- 65PolymorphismSend one activate() call to robots all typed as Robot and watch each run its own behavior
- 66Abstract Classes and InterfacesBuild GuardBot against a Robot contract, switch the contract between an abstract class and an interface, and see live whether each choice compiles
- 67Composition vs InheritanceGrow an inheritance tree until it tangles, then build the same robot by snapping modules in