Multiple choice technology architecture

A class that operates on different objects. Which one would be a better pattern to use?

  1. Invoker pattern

  2. Double Dispatch pattern

  3. Factory pattern

  4. Intercepting Filter

  5. None of the above

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

The Double Dispatch pattern (Visitor pattern family) allows an operation to vary based on both the object type and the operation type. It enables a class to perform different operations on different object types by dispatching twice - once on the object and once on the visitor. This is ideal when a class must operate on diverse object types with type-specific behavior. Invoker is Command pattern, Factory creates objects, Intercepting Filter modifies requests.