This was more a discussion for what peoples thoughts are these days on how to sp
ID: 647357 • Letter: T
Question
This was more a discussion for what peoples thoughts are these days on how to split a web application.
I am used to creating an MVC application with all its views and controllers. I would normally create a full view and pass this back to the browser on a full page request, unless there were specific areas that I did not want to populate straight away and would then use DOM page load events to call the server to load other areas using AJAX.
Also, when it came to partial page refreshing, I would call an MVC action method which would return the HTML fragment which I could then use to populate parts of the page. This would be for areas that I did not want to slow down initial page load, or areas that fitted better with AJAX calls. One example would be for table paging. If you want to move on to the next page, I would prefer it if an AJAX call got that info rather than using a full page refresh. But the AJAX call would still return an HTML fragment.
My question is. Are my thoughts on this archaic because I come from a .net background rather than a pure front end background?
An intelligent front end developer that I work with, prefers to do more or less nothing in the MVC views, and would rather do everything on the front end. Right down to web API calls populating the page. So that rather than calling an MVC action method, which returns HTML, he would prefer to return a standard object and use javascript to create all the elements of the page.
The front end developer way means that any benefits that I normally get with MVC model validation, including client side validation, would be gone. It also means that any benefits that I get with creating the views, with strongly typed html templates etc would be gone.
I believe this would mean I would need to write the same validation for front end and back end validation. The javascript would also need to have lots of methods for creating all the different parts of the DOM. For example, when adding a new row to a table, I would normally use the MVC partial view for creating the row, and then return this as part of the AJAX call, which then gets injected into the table. By using a pure front end way, the javascript would would take in an object (for, say, a product) for the row from the api call, and then create a row from that object. Creating each individual part of the table row.
The website in question will have lots of different areas, from administration, forms, product searching etc. A website that I don't think requires to be architected in a single page application way.
What are everyone's thoughts on this?
I am interested to hear from front end devs and back end devs.
Explanation / Answer
I'll offer my highly subjective 2 penny worth (for what it's worth ;)). There isn't a right or wrong answer to this and there are many real world considerations in addition to your points, for example:
Do you have the relevant experience in house? building a client side driven app is very different to a predominantly server driven one with a completely different skill set.
How long do you want it to take and which browsers do you need to support? - the more you do on the client the more browser issues you'll face; IE8 is painful and JavaScript performance is quite poor, but there there are a lot of businesses running XP/IE set ups.
What devices are your users going to be viewing the site on? JavaScript parsing and running may be fast on a recent version of Chrome - but it isn't on an older mobile device, especially not a large amount of JavaScript with a load of business logic in it
How important is initial load? Server templating is faster than client templating
This list is by no means exhaustive and sounds like a client side bashing which isn't my intention, I've made sites with a heavy emphasis on the front end end.
For me it really comes down to user experience and API re-usability. To address each of these.
If you are going to be making an app or offering an API, there's a lot of sense in using a .Net API project, this then forms the logic, checking and implementation cross platform. In this scenario a complete client side approach may be favourable, the API can be maintained separately and just provides an interface to your application. You can amend the logic and refactor comfortably and just have to keep the interface the same. You can easily write different applications for different media all using the same background code.
The strongest argument for a pure front end solution (in my opinion) is that of user experience.
Does (when considering all the downsides) a pure JavaScript browser application offer a substantial improvement on usability and user experience on a traditional website?
When creating sites that work like native applications; I'd argue the answer is an obvious yes. Most sites however aren't this clean cut though, so it's a matter of assessing whether individual user workflows benefit from a highly dynamic interface.
I take a fairly pragmatic view of this, it isn't an either or matter; JavaScript will obviously play quite happily along with Server technologies and you don't have to choose one or the other - every site isn't a single page web app - but there's nothing stopping you using Knockout, backbone and the suchlike on individual pages to improve things where it's deemed necessary.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.