Results 1 to 4 of 4

Thread: ViewControl vs plain old Controls in an MVVM pattern

  1. #1
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    30

    Default Answered: ViewControl vs plain old Controls in an MVVM pattern

    So I come from the world of MVC frameworks and have recently migrated to Ext JS. One of the areas I'm confused about is using an MVC pattern vs the newer MVVM pattern and specifically what is the purpose of a Control in a MVVM pattern if you also have a ViewControl.

    Hopefully someone can give me some insight.

  2. I think this is a change of thought.

    With MVC extending Ext.app.Controller you need to think globally. When you need to resolve a component, it's not the easiest to ensure you only get the one you want, your ComponentQuery selectors can get ugly real fast.

    However, with Ext.app.ViewController you think much more "local". A ViewController should only control the view it's bound to and the children that view specifies. This allows your code to be much more specific and module leading to more maintainable code. Listeners specified on the view can resolve to the ViewController automagically, very little configuration involved.

    Personally, I never really had an issue with MVC but since we brought MVVM into the picture, I don't use Ext.app.Controller at all. I only use Ext.app.ViewController throughout my application. Using Ext.app.Controller still has it's uses for global things depending on your application.

    As a matter of fact, I'll be giving a talk at SenchaCon on some architecture best practices and the difference between the two is going to be part of it... if you're coming

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    I think this is a change of thought.

    With MVC extending Ext.app.Controller you need to think globally. When you need to resolve a component, it's not the easiest to ensure you only get the one you want, your ComponentQuery selectors can get ugly real fast.

    However, with Ext.app.ViewController you think much more "local". A ViewController should only control the view it's bound to and the children that view specifies. This allows your code to be much more specific and module leading to more maintainable code. Listeners specified on the view can resolve to the ViewController automagically, very little configuration involved.

    Personally, I never really had an issue with MVC but since we brought MVVM into the picture, I don't use Ext.app.Controller at all. I only use Ext.app.ViewController throughout my application. Using Ext.app.Controller still has it's uses for global things depending on your application.

    As a matter of fact, I'll be giving a talk at SenchaCon on some architecture best practices and the difference between the two is going to be part of it... if you're coming
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Sencha Premium Member
    Join Date
    Dec 2012
    Location
    Seattle, WA
    Posts
    423
    Answers
    34

    Default

    The one area where I think a global controller works great is for routing especially when you need to route to a view that is not initialized when the application loads.

  5. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    True and hopefully for Ext JS 7 (under review for acceptance) I will have a change where routing becomes a mixin. I personally use utility singletons to manage my routes in the portal and new fiddle (under dev) for the same reason you are using a global controller. Thinking of the default Cmd app, MainController is pretty much a global controller but in a ViewController fashion since the Main view is always around.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Similar Threads

  1. Working with models in MVVM pattern: best practices?
    By silveralecs in forum Ext JS 6.x Q&A
    Replies: 3
    Last Post: 4 Feb 2016, 9:22 AM
  2. Replies: 1
    Last Post: 29 Sep 2015, 6:46 AM
  3. Can we use MVVM architectural pattern in Ext Js 6?
    By madaras_adrian in forum Ext JS 6.x Q&A
    Replies: 3
    Last Post: 8 Jul 2015, 4:09 AM
  4. Recommended MVVM approach to adding radio controls
    By seade in forum Sencha Ext JS Q&A
    Replies: 3
    Last Post: 25 Aug 2014, 2:23 PM
  5. Replies: 0
    Last Post: 6 Apr 2008, 10:49 AM

Tags for this Thread

Posting Permissions

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