Python Object Design

4 chapters · 19 lessons

How should a Python program organize information that changes? This course starts with a function and a dictionary, then introduces classes, supported state changes, collaboration, and the choice between composition and inheritance. Examples are small enough to trace, with explicit limits where a design offers no security or transaction guarantee.

Before starting

Be comfortable with Python variables, functions, lists, dictionaries, loops, conditionals, and raising and catching exceptions. No previous class-design experience is assumed. Examples use Python 3 and each Python block runs independently. Read the chapters in order; diagrams are explanatory, not program output.

Chapters

  1. Finding a home for state — functions, objects, references, and attributes.
  2. Keeping state consistent — invariants, methods, boundaries, and collaboration.
  3. Designing collaboration — interfaces, contracts, delegation, and polymorphism.
  4. Choosing relationships — inheritance, substitution, composition, and Python operations.

Finish with the 20-question assessment. It checks conceptual understanding, not independent programming ability.