1. #1
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    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 MVC app listing all views, stores and models is unmanageable

    MVC app listing all views, stores and models is unmanageable


    When reading source code for pre PR4 controller extensions, it was easy to determine what views, models, and stores a particular controller is to manage. That pattern worked well in the direction of the "Self documenting code" practice.

    Moving views, models and stores to the application really goes against self documenting code as controllers often are specific to a certain view and/or model. I initially liked the idea of centralized configuration, but am now against it. Application definitions will become bloated and hard to manage/maintain for larger apps.

    While thinking about MVC for ST2, please keep in mind that this code will most likely be used for Ext JS5, where tens of views, stores and models can pollute the application definition.

    Just look @ the app.js for the kitchen sink demo. Imagine if there were an equal amount of models and stores listed there.

    Code:
     views: [
            'NestedList',
            'List',
            'SourceOverlay',
            'Buttons',
            'Forms',
            'Icons',
            'BottomTabs',
            'Themes',
            'Map',
            'Overlays',
            'Tabs',
            'Toolbars',
            'JSONP',
            'YQL',
            'Ajax',
            'Video',
            'Audio',
            'NestedLoading',
            'Carousel',
            'TouchEvents',
            'SlideLeft',
            'SlideRight',
            'SlideUp',
            'SlideDown',
            'CoverLeft',
            'CoverRight',
            'CoverUp',
            'CoverDown',
            'RevealLeft',
            'RevealRight',
            'RevealUp',
            'RevealDown',
            'Pop',
            'Fade',
            'Flip',
            'Cube'
        ],
    One thing I must say about the older model is that the dependency chain was clearly defined. App required controllers, controllers required views, stores & models. If i did not want to include an entire branch of application, all I had to do was comment out the controller. At that point, the controller and its associated views and models would not get required, thus eliminated in one easy step.

    In this new model, I have to remember: What controller requires what models, stores and views? Did i get ALL of them in the app.js? This leads to potential pollution in production apps.

    I'm sure the team has a really good reason for making this change. I just can't see it.

    I would love to hear what the community thinks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    872
    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


    Since Ext.app.Application extends Ext.app.Controller, I would think it would be trivial to move these kinds of configs to the Controller and still have the Application use it. I'm not sure why the behavior was moved off of Controller, possibly a performance decision but I will open a ticket for this.

    I'm not sure about the SenchaCon app but TouchForums has quite a few views and if I were to define them in the Application that array would be quite long also. However, most of the time I don't put views in the application, I use the requires property in the different views that require that view.
    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
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    557
    Vote Rating
    25
    estesbubba will become famous soon enough estesbubba will become famous soon enough

      0  

    Default


    Jay - totally agree with you and didn't like having to move all my views, models, and stores into the application. What if you have a controller that is used in 3 different applications? Now when you add a view to that controller, instead of adding it in one place (the controller) you have to add it to three applications. What if developer A is working on application A and didn't realize he just broke applications B and C?

    The thing I like to do is keep my application dumb. I prefer to define controllers and a launch() function in the application and that's about it. I define a launch() method in a controller that I want to initially control the app.

  4. #4
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    773
    Vote Rating
    28
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Default


    I was surprised that in beta1 they moved it to a central place, but on the other side, the new routes config moved to the controller (as opposed to a central place as in ST1).

    I don't have an opinion on both yet, though. I'll see with time how it feels/maintains.

    Usually you have your views structured into namespaces, therefore a "views" array of a normal application would look a bit more organized than the kitchensink code example.

    What I don't like in >= beta1 though is that if you use namespaces in views, you have to specify the complete namespace, e.g. "SomeApp.view.nested.View" instead of just "nested.View".

    Also, I'm often on the fence if I specify a view in the app config or in the "requires" config option of the main views as Mitchell points out.

  5. #5
    Ext JS Premium Member perfusorius's Avatar
    Join Date
    May 2010
    Location
    Berlin, Germany
    Posts
    3
    Vote Rating
    0
    perfusorius is on a distinguished road

      0  

    Thumbs up


    +1

  6. #6
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    773
    Vote Rating
    28
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Default


    estesbubba,

    could you give me an example of where you'd use the same controller in 3 different applications?

    Just curious.

  7. #7
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    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 Steffen Hiller View Post
    What I don't like in >= beta1 though is that if you use namespaces in views, you have to specify the complete namespace, e.g. "SomeApp.view.nested.View" instead of just "nested.View".
    Agreed.

    I'm really glad you guys are chiming in. I think we all play a major role in making Sencha Touch 2 as best as possible.

  8. #8
    Sencha User
    Join Date
    Jan 2012
    Posts
    17
    Vote Rating
    2
    ryancanulla is on a distinguished road

      0  

    Default


    +1 for this.

    To me, having controllers define views, stores, & models bodes well for reusable modules. Also, as stated earlier, it makes our controllers more humanly readable.

  9. #9
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    557
    Vote Rating
    25
    estesbubba will become famous soon enough estesbubba will become famous soon enough

      0  

    Default


    Quote Originally Posted by Steffen Hiller View Post
    estesbubba,

    could you give me an example of where you'd use the same controller in 3 different applications?

    Just curious.
    You bet. We have a product for ordering and activating devices and have 3 applications (and both Ext JS and Touch versions).

    Device Order App (workflow used by end user and CSR)
    Device Activation App (workflow used by end user and CSR)
    Account Maintenance App (used by end user and can also do Device Order and Device Activation workflows)

    The workflows have controllers, views, stores, and models that are shared by all 3 applications. Each workflow has a "master" controller (DeviceOrderController and DeviceActivationController) and they communicate with the workflow controllers via events.

    In addition to the 3 applications in the above product we also have other products which use these workflow controllers, views, etc. So this "workflow library" is used by several products and each product can have multiple applications within it.

  10. #10
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    I've moved this into Discussion as it's obviously not a bug. The imminent B3 release has a new guide on dependency philosophy that I'd like you to take a look at as it lays out the reasoning behind this change. Happy to hear other viewpoints of course.
    Last edited by edspencer; 14 Feb 2012 at 1:28 PM. Reason: yes I meant viewpoints not viewports ;)
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer