|
-
May 20th, 2012, 08:51 AM
#1
Thread Starter
Randalf the Red
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?
.
-
May 20th, 2012, 11:01 AM
#2
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.
-
May 20th, 2012, 01:10 PM
#3
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
-
May 21st, 2012, 12:32 AM
#4
Thread Starter
Randalf the Red
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.
.
-
May 21st, 2012, 12:39 AM
#5
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
-
May 21st, 2012, 01:32 AM
#6
Thread Starter
Randalf the Red
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.
.
-
May 21st, 2012, 04:18 AM
#7
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.
-
May 21st, 2012, 04:58 AM
#8
Thread Starter
Randalf the Red
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.
.
-
May 21st, 2012, 05:07 AM
#9
Re: MVC3 or JQuery ?
 Originally Posted by honeybee
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.
-
May 21st, 2012, 06:00 AM
#10
Re: MVC3 or JQuery ?
 Originally Posted by jmcilhinney
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
-
May 21st, 2012, 06:30 AM
#11
Thread Starter
Randalf the Red
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.
.
-
May 21st, 2012, 07:08 AM
#12
Re: MVC3 or JQuery ?
I'll accept cash in lieu.
-
May 21st, 2012, 07:09 AM
#13
Re: MVC3 or JQuery ?
 Originally Posted by honeybee
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|