-
7 Jul 2010 10:32 AM #1Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 32
Ext.getCmp and developers using it as a crutch
Ext.getCmp and developers using it as a crutch
Does anyone else feel that Ext.getCmp is unnecessarily used as a crutch by new developers? I'm finding case after case where developers are creating extensions (pre-configured classes), using Ext.getCmp *inside* of their classes.

What can we do to minimize this?
UPDATE :: Added screencast:

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
7 Jul 2010 12:16 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
Idiots will be idiots and will always be idiots. 'this' (scope of course) can be very powerful if used correctly or at all. I'm no master programmer but even I know that using getCmp is not a good practice to have.
About your question.... You can't control what others do. They will learn that eventually things will go terribly wrong for them if they keep to that practice. It may work for them now but it won't in the long run and then their name is discredited when someone has to go through and fix the crap.
So why not learn to do things right?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.
-
7 Jul 2010 12:53 PM #3
Since I`ve implemented a MessageBus for event handling etc I dont even care about using Ext.getCmp. Its really nice to create plugins that have their own responsibility for handling events which they subscribe to. Clearer code & less conjunction.
I`m from Holland!
-
7 Jul 2010 2:10 PM #4
As someone who has been guilty of this in the past (and still shudders with revulsion when I have to go back and touch old code), I wouldn't call people who do this "idiots"... I think it's simply a case of not knowing any better. It's a quick, one-line statement and it works for the most part.
As far as "learning to do things right" - if it seems to work just fine, how are new developers even supposed to know that using Ext.getCmp() is not doing things right?
-
7 Jul 2010 4:45 PM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 32
I agree. The goal of this post is to understand what the senior community members can do to help prevent this in the future 4.0 user base.
I am hoping to outline some of the Ext JS 4.0 examples soon and present them to the Ext JS team. My goal is to eliminate the use of Ext.getCmp all together, if possible.
Any ideas/input would be greatly appreciated.
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
7 Jul 2010 4:46 PM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 32
azuroff, where and how did you learn not to use Ext.getCmp?

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
7 Jul 2010 4:52 PM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
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.
-
7 Jul 2010 4:53 PM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 32

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
7 Jul 2010 4:59 PM #9Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
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.
-
7 Jul 2010 9:12 PM #10
Could be a preprocessor for Javascript might work.
Parse the JS, extract all itemId configs.
Wrap the JS with
Similar to what I use, except that all my "pages" (loaded Components) are generated. I generate code which declares a var for every Component in that "page" who's name is the Component's itemId.Code:(function() { var <itemId1>,<itemId2>.......; <The original JS with initComponent method injected into the configs which contains the line <itemIdVarName> = this; </TheOriginalJS> })();Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
Similar Threads
-
paypal tips for ext developers
By smokeman in forum Community DiscussionReplies: 23Last Post: 17 Mar 2011, 11:49 AM -
Ext developers needs donations?
By dolittle in forum Community DiscussionReplies: 3Last Post: 4 Mar 2010, 8:14 AM -
Questions for Ext developers
By arthurakay in forum Community DiscussionReplies: 3Last Post: 11 Feb 2009, 1:38 PM -
ext developers wanted!
By albertyips in forum Community DiscussionReplies: 0Last Post: 2 Jul 2007, 10:40 PM -
Chicago Ext developers...
By zquirm in forum Community DiscussionReplies: 1Last Post: 28 Jun 2007, 10:13 AM


Reply With Quote
