Skip to content

Architectural Guidelines

cilquirm edited this page Sep 13, 2010 · 2 revisions

View and Controllers initialization

Controllers initialization is handled by the main view. The controller normally acts on an instance of a view object or more. For testing the view can be injected from outside as a key of a hash. If the view is not passed in at initialization time, the controller creates a default one passing “self” to the constructor of the view. The standard can be summarized as following:

  • The controller is initialized first with no params to the constructor
  • The controller has the responsibility to initialize the views it depends upon
  • The client of the controller (usually the main view) delegates to the controller the rendering of the view as the effect of a button click or other event
  • Views always have a ‘render’ method that creates all the hotcocoa objects
    A view is only rendered (and visible) after the render method has been called.
Clone this wiki locally