Composition over Inheritance

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • easy
  • Pro

Your game has a base class for characters, with subclasses for flying characters, swimming characters, and now someone wants a character that both flies and swims. Explain why the inheritance tree is struggling and how composition would help.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →