← All Chapters
7 topics

Object-Oriented Programming

Classes, inheritance and polymorphism as moving diagrams, not definitions.

  1. 61Classes and ObjectsStamp objects off a class blueprint, give each its own state, then lock a field down with encapsulation
  2. 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
  3. 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
  4. 64InheritanceBuild a robot family tree and watch method lookup climb the chain until an override wins
  5. 65PolymorphismSend one activate() call to robots all typed as Robot and watch each run its own behavior
  6. 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
  7. 67Composition vs InheritanceGrow an inheritance tree until it tangles, then build the same robot by snapping modules in