PresentersandControllers

### Cairngorm 3 - [ Home ][1] - [ Guidelines ][3] - [ Tools ][4] - [ Libraries Downloads ][2]
### Cairngorm 2 - [ Home ][5] - [ Framework Downloads ][6] - [ Eclipse Plugin ][7]
### Project - [ Source ][8] - [ Bug Database ][9] - [ Submitting a Patch ][10] - [ Developer Documentation ][11] - [ Forums ][12] - [ License ][13]

Presenters and Controllers

Presenters

Presenters belong to the Presentation Layer. They have local coordination tasks between objects of the Presentation Model; within a functional area or a region of a functional area.

Decoupling Presentation from Domain

Presenters can be used to decouple PMs from domains with listening to domain events and setting PMs (this circumvents databinding as a cost)

Coordination of PMs

Presenters can be used to handle events from PMs and delegate them to other PMs. As described in Applying the Presentation Model - Componentized vs Hierarchical an alternative solution to coordination between PMs could be messaging where every PM handles a shared event.

The motivations to use Presenters could be:

  • Easier readability and control - A higher level view of the coordination between PMs could ease readability and improve control of the coordination.
  • Ensure an execution order of event-handling PMs. Messaging mechanisms usually do not define an order or the receiver.
  • Prevent event-handling code in each listening PM.

Controllers

Controllers belong to the Application Layer. They have a wider coordination responsibility than Presenters and are not only local to a specific group of PMs. They can i.e.

  • translate events from one functional area to events of another functional area
  • intercept application events
  • translate application events into domain API calls in order to keep the domain object free from any knowledge of other architectural layers.