Class counts for independent variations

A team compares two designs for software whose objects vary along independent dimensions. In the inheritance design, every combination of options gets its own concrete leaf subclass. In the composition design, the main class holds one component object per dimension, and every option is one concrete component class. For each system in the table, enter the number of concrete leaf subclasses the inheritance design needs and the number of concrete component classes the composition design needs. Do not count the main class or any abstract base classes, and enter whole numbers.

SystemIndependent optionsInheritance leaf subclassesComposition component classes
Coffee order3 sizes and 5 flavours
Electric scooter4 motors and 2 batteries
Report export2 formats, 3 page sizes and 4 themes

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Composition, Inheritance Questions: