-
7 Nov 2011 5:18 PM #1
Unanswered: instantiating views and controllers
Unanswered: 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!
-
8 Nov 2011 9:48 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
- Answers
- 3160
Views should be "dumb" and the app controlling done in the Controller. So instantiating the Controllers should be done first.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Nov 2011 12:04 PM #3
Sounds like the recommend approach then is more model-view-presenter with a passive view, or perhaps supervising controller, yes?
-
8 Nov 2011 12:06 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
- Answers
- 3160
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 @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote