Multiple choice technology programming languages

You're designing a paint application and as part of the user interface you have a toolbar along the left hand side of the screen. Each of the icons on the toolbar has different actions when you are using different tools. The way you've structured it, the application is required to pass commands from one object to another. When the appropriate object receives the command, it handles the request. This is an example of which pattern?

  1. Command

  2. Chain of Responsibility

  3. Adapter

  4. Interpreter

  5. Strategy

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The Chain of Responsibility pattern passes a request along a chain of handling objects, where each object can either handle the request or pass it to the next. This matches the toolbar scenario where commands are passed from one object to another until the appropriate handler processes it. The Command pattern encapsulates requests as objects but doesn't inherently chain them. Adapter converts interfaces, Interpreter evaluates language syntax, and Strategy encapsulates algorithms - none of which fit this command-passing behavior.