Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 868 Bytes

File metadata and controls

29 lines (20 loc) · 868 Bytes

Module 051: Composition vs Inheritance

  • Phase: 6. Advanced OOP & Errors
  • Duration: 1.5 hours

Learning Objectives

  • Understand "has-a" vs "is-a" relationships
  • Implement composition by containing objects as attributes
  • Implement inheritance by extending classes
  • Apply the "favor composition over inheritance" guideline
  • Choose between composition and inheritance for real-world problems

Topics Covered

  • "has-a" relationship (composition)
  • "is-a" relationship (inheritance)
  • Composition: delegating behavior to contained objects
  • Inheritance: extending and overriding parent behavior
  • When to prefer composition over inheritance
  • UML-style diagram notation for both patterns

Prerequisites

Modules 000–050, including OOP basics through abstract base classes.

Next Module

Module 052: Class Methods, Static Methods, Properties