Results 1 to 13 of 13

Thread: MVC3 or JQuery ?

  1. #1

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    MVC3 or JQuery ?

    We have started a massive framework building exercise, using the POCO and building repositories and services and such stuff. Now when it comes to the UI, we decided to go ahead with MVC3 and JQuery. Things were fine initially, but now I see all the UI being exclusively developed using JQuery.

    Two major problems I see with this approach are the development time and UI complexity has increased multifold, since the default MVC views are much cleaner/clearer and easier to generate/modify as soon as your model changes. While in JQuery the developers are often struggling to get things up and running with so much of scripting required. Also there are some strange situations where the controller action simply renders a view to have a JQuery call another controller action to fetch the actual data. I don't know if this is taking things to the extreme.

    The only real advantage of JQuery seems to be for performance where partial page updates are necessary or you are moving a lot of data back and forth and need to prune it down to the last bit.

    So what's the ideal mix? Use JQuery liberally or use it only where it really helps speed up things?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: MVC3 or JQuery ?

    I've never used MVC3 - went from Winforms to Webforms with standard ASP.net.

    I've now completely abandoned using ASP.net for the UI - I use 100% jQuery in the browser and async talk with ASP.Net web methods.

    Having little Javascript background - and no C-syntax experience - the learning curve was long. But I am proficient and think I can kick out UI code using Javascript and jQuery faster then just about any prior paradigm.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: MVC3 or JQuery ?

    Hey,

    Personally, I see there being a happy medium between the two. jQuery is heavily embedded within MVC (so much so that Microsoft actually submitted code for inclusion within the jQuery library). Obviously, on the UI much of it will be done using jQuery to ensure speed and interactivity on the client, but on the back end, MVC will give you the ability to leverage all the functionality on the server.

    Is it possible that you can show an example of what you are seeing, and why you think the paradigm isn't working?

    Gary

  4. #4

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: MVC3 or JQuery ?

    To give a specific example of the Index action, there's a controller which has code like this:

    Code:
    public ActionResult Index()
    {
        //Normally fetching the necessary data and processing it would go here
        //Also the Index() method would normally have the necessary parameters
        //required to fetch data
        return View();
    }
    
    public JsonResult GetData()
    {
        //Code to fetch and return data goes here
        //along with the necessary parameters
        return <whateverdata>;
    }
    The view is rendered, so the html sans data is rendered to the client. Then a jQuery call from within the pageload of the view invokes the GetData() action on the controller which fetches the data. Is this the right way?

    The other example is the jqGrid control. For all the features it offers, I see the manual coding takes a lot of effort, which could very well be achieved by using a standard grid or even by modifying the standard MVC List view for the model.

    And by the way, the only functionality our grid is offering is sorting and column resizing. No editing or adding within the grid. All the detail level actions are handled either through AJAX popups or separate views.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: MVC3 or JQuery ?

    Hello,

    No, I don't necessarily see anything wrong with that. One could argue that the information that you are getting from the GetData call could be returned in the View from the Index action on your Controller, but like most things you would get people arguing both sides of this.

    Gary

  6. #6

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: MVC3 or JQuery ?

    Exactly my point: I could very well do this in the Index method in the traditional MVC way without using jQuery, and the performance gain/loss would not necessarily be significant. The paging has been implemented at server side, so even with MVC the paging would need a postback/server roundtrip. The only savings are the payload of the markup.

    As against that the development time of more than a whole day for jQuery as against a few minutes for the MVC is what is killing me. Where my prototype UI would/should have been up and running in a matter of hours, it's now taking weeks. The code's not much readable and I am sure with a team it's going to land me in a nice soup.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: MVC3 or JQuery ?

    Most of my work at the moment is using MVC3 and we use jQuery liberally. In a complex application you will almost always benefit from using jQuery for not just asynchronous calls but also for numerous dynamic UI elements, dialogues, grids, etc. In the example you've provided, while it's not wrong to make the second call to get the data, you'd want to have a specific reason for doing so because making the extra call is going to make the overall operation take longer. I would tend to only make the second call if passing the data back from the first call presented some sort of issue. Some may say that it helps to keep the code ordered by having the two calls and there may be some truth in that. If you find that the performance difference is small enough to justify it then by all means go that way.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: MVC3 or JQuery ?

    All I want to do is follow MVC3 standard controller-view model (pun unintended) and inject jQuery where necessary instead of using jQuery everywhere. While jQuery will give me performance benefits in the long run, the longish learning curve and consequently longer development times make it difficult for me to justify jQuery everywhere.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: MVC3 or JQuery ?

    Quote Originally Posted by honeybee View Post
    All I want to do is follow MVC3 standard controller-view model (pun unintended) and inject jQuery where necessary instead of using jQuery everywhere. While jQuery will give me performance benefits in the long run, the longish learning curve and consequently longer development times make it difficult for me to justify jQuery everywhere.

    .
    Then the answer is simple: don't use jQuery everywhere. You could start out with no jQuery at all if you wanted. It's a tool to create better applications but it's not essential. Once you have something working, then you might start looking at ways to improve it using jQuery using asynchronous calls, etc.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: MVC3 or JQuery ?

    Quote Originally Posted by jmcilhinney View Post
    Then the answer is simple: don't use jQuery everywhere. You could start out with no jQuery at all if you wanted. It's a tool to create better applications but it's not essential. Once you have something working, then you might start looking at ways to improve it using jQuery using asynchronous calls, etc.
    I think that sums it up quite nicely

  11. #11

    Thread Starter
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: MVC3 or JQuery ?

    Thanks, jmcilhinney. I wanted to add to your reputation but for some reason it keeps saying I need to distribute a few more reputations around before I can give it to you again.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: MVC3 or JQuery ?

    I'll accept cash in lieu.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: MVC3 or JQuery ?

    Quote Originally Posted by honeybee View Post
    Thanks, jmcilhinney. I wanted to add to your reputation but for some reason it keeps saying I need to distribute a few more reputations around before I can give it to you again.

    .
    Yeah, that is a function of the forums, in order to try to prevent malicious reputation spreading. I "think" it is sitting a something like 10 unique people that you have to give reputation to, before you can give to the same person again.

    Gary

Posting Permissions

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



Click Here to Expand Forum to Full Width