Design Pattern Examples
Overview of object-oriented design patterns
DesignPatternExamples_python.handlerchain.handlerchain_exercise Namespace Reference

Functions

None _HandlerChain_ConstructWindowChain (HandlerChain handlerChain)
 Helper method to construct a list of windows.
 
def HandlerChain_Exercise ()
 Example of using the HandlerChain Pattern or Chain of Responsibility Pattern.
 

Function Documentation

◆ _HandlerChain_ConstructWindowChain()

None _HandlerChain_ConstructWindowChain ( HandlerChain  handlerChain)
protected

Helper method to construct a list of windows.

Messages will be passed to these windows via the HandlerChain object.

Parameters
handlerChainThe HandlerChain object that receives the new windows.

Definition at line 20 of file handlerchain_exercise.py.

Referenced by DesignPatternExamples_python.handlerchain.handlerchain_exercise.HandlerChain_Exercise().

◆ HandlerChain_Exercise()

def HandlerChain_Exercise ( void  )

Example of using the HandlerChain Pattern or Chain of Responsibility Pattern.

The Handler Chain pattern is used to support a dynamic list of handlers that are passed the same arguments. It is kind of the inverse of the Visitor pattern, where the Visitor pattern is a handler that is passed to all objects in a list and the Handler Chain pattern is an object passed to handlers in a list.

In this exercise, multiple rectangular regions called MessageWindows embody the handlers and the HandlerChain object passes message objects to each MessageWindow until the message is handled.

Definition at line 47 of file handlerchain_exercise.py.

References DesignPatternExamples_python.handlerchain.handlerchain_exercise._HandlerChain_ConstructWindowChain().