Identifying design patterns in game unit hierarchies
This is an easy C++ question that tests whether you can recognize a classical Gang of Four design pattern in a concrete codebase. It's the kind of problem used in early-round interviews to confirm you understand foundational object-oriented design principles and can name patterns when you see them applied.
The scenario presents a common refactoring challenge: a system initially designed around a single unit type (knights) must be extended to support multiple types (dragons) that share common behaviour. The question asks you to identify which structural or behavioural pattern your co-worker used to solve this extensibility problem. Strong answers name the pattern, explain why it fits, and articulate what design principle it upholds—such as the Open/Closed Principle or Liskov Substitution Principle.
- Recognizing polymorphic base classes and inheritance hierarchies
- Understanding when and why to abstract shared interfaces
- Distinguishing between structural patterns (Adapter, Decorator, Bridge) and behavioural patterns (Strategy, Template Method)