1.6. Composite View

Composite View suggests composing a View from numerous atomic pieces. Multiple smaller views, both static and dynamic, are pieced together to create a single template. The Service to Worker and Dispatcher View patterns represent a common combination of other patterns from the catalog. The two patterns share a common structure, consisting of a controller working with a Dispatcher, Views, and Helpers. Service to Worker and Dispatcher View have similar participant roles, but differ in the division of labor among those roles. Unlike Service to Worker, Dispatcher View defers business processing until view processing has been performed. The Composite View pattern combines simple views into a more complex view without handling the content or layout. 

UML representation


Benefits

The following lists the benefits of using the Composite View pattern:
  • Code duplication is reduced because you can create common headers, footers, and other components.
  • Views can be changed based on access authorization.

When to Use

You should use the Composite View pattern when:
  • You want common view components.
  • You view component changes based on authorization.
Comments