1. #1
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default 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:

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,790
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2008
    Posts
    322
    Vote Rating
    4
    Scorpie is on a distinguished road

      0  

    Default


    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!

  4. #4
    Sencha Premium Member
    Join Date
    Feb 2009
    Posts
    316
    Vote Rating
    3
    azuroff will become famous soon enough

      1  

    Default


    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?

  5. #5
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Quote Originally Posted by azuroff View Post
    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?
    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.

  6. #6
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    azuroff, where and how did you learn not to use Ext.getCmp?

  7. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,790
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by jgarcia@tdg-i.com View Post
    My goal is to eliminate the use of Ext.getCmp all together, if possible.
    Is this the best idea though? Is there a way to render it useless when extending?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  8. #8
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,353
    Vote Rating
    79
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Is this the best idea though? Is there a way to render it useless when extending?

    Sure there is. use the "ref" option (i'm not a fan of that), or use the container model methods in conjunction with itemId.


    I smell a screen cast brewing..

  9. #9
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,790
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by jgarcia@tdg-i.com View Post
    Sure there is. use the "ref" option (i'm not a fan of that), or use the container model methods in conjunction with itemId.


    I smell a screen cast brewing..
    I understand but I think it has it's uses in normal coding but that just may be because of laziness. Maybe it is a good idea to force people to use good practices?

    I just wouldn't like to lose people because of something like this.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    46
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Could be a preprocessor for Javascript might work.

    Parse the JS, extract all itemId configs.

    Wrap the JS with

    Code:
    (function() {
        var <itemId1>,<itemId2>.......;
    
        <The original JS with initComponent method injected into the configs which contains the line
            <itemIdVarName> = this;
        </TheOriginalJS>
    })();
    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.

Similar Threads

  1. paypal tips for ext developers
    By smokeman in forum Community Discussion
    Replies: 23
    Last Post: 17 Mar 2011, 11:49 AM
  2. Ext developers needs donations?
    By dolittle in forum Community Discussion
    Replies: 3
    Last Post: 4 Mar 2010, 8:14 AM
  3. Questions for Ext developers
    By arthurakay in forum Community Discussion
    Replies: 3
    Last Post: 11 Feb 2009, 1:38 PM
  4. ext developers wanted!
    By albertyips in forum Community Discussion
    Replies: 0
    Last Post: 2 Jul 2007, 10:40 PM
  5. Chicago Ext developers...
    By zquirm in forum Community Discussion
    Replies: 1
    Last Post: 28 Jun 2007, 10:13 AM

Thread Participants: 24

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi