Processing Semantic Events

Event Delegation

Recall that a view is an assembly of controls and sub-views. When a control receives a low-level event, such as MOUSE_CLICKED it converts it into a high-level or semantic event, such as OPEN_FILE. But then what? What other objects need to be informed of this event? One solution is event routing: tell everyone, but in some prescribed order. Of course most objects won't find this event interesting, so event routing is inefficient.

The Event Delegation technique uses the Publisher-Subscriber pattern to notify the appropriate controllers:

Controllers as command processors

We can use the Command Processor pattern to process events. We can combine this with the Memento pattern to implement an undo mechanism without violating the model's privacy.

Multiplicities

N = 1: Centralized Control

N = M: Page Controllers

N = # of Use Cases: Use Case Controllers

N = # of semantic events: Ultimate Decentralized Control

Variations

Smart Commands, dumb views and controllers

Dumb commands, smart views, dumb controllers

Dumb commands, dumb views, smart controllers