Results 1 to 4 of 4

Thread: instantiating views and controllers

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Vancouver, Canada
    Posts
    157
    Answers
    5
    Vote Rating
    14
      0  

    Default instantiating views and controllers

    i have a form that i'd like to instantiate at runtime, as well as its controller

    is it better to do a), b), or c)?

    a) instantiate the view, and then the controller (or vice versa)

    b) instantiate the controller, which then instantiates the view itself

    c) instantiate all the controllers at startup, and only worry about instantiating the views as needed

    what are the advantages or disadvantages to each?

    thanks!

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Views should be "dumb" and the app controlling done in the Controller. So instantiating the Controllers should be done first.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Vancouver, Canada
    Posts
    157
    Answers
    5
    Vote Rating
    14
      0  

    Default

    Sounds like the recommend approach then is more model-view-presenter with a passive view, or perhaps supervising controller, yes?

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    There are lots of different MVC ideals out there so it's kind of up to you to decide what's best for the application. The strictest is that a View should not know about anything outside of itself, an example is that it shouldn't even know what children is should have. The Controller should tell the View what children to have.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •