Search

Friday, 31 May 2013

ConvallisCMS and ASP.Net MVC 4

In previous posts I've talked about how we slowly evolve our software by taking advantage of advances in the platform that we write our code in (the .Net Framework). Last time I discussed the Entity Framework and why I decided to move us over to it's most recent release. This time I thought I'd write a little about ASP.Net MVC.

This is a technology that I doubt hardly anyone who isn't a software developer (and probably a web developer at that) will have heard of. I'm sure many of you will know that ASP.Net is the name Microsoft gave the web development platform which is part of the .Net Framework, and the MVC framework is a subset of that.

MVC stands for Model View Controller which is the name of a widely used programming pattern. What it means is that the software (which from the point of view of the pattern doesn't have to be a web application) is architected in such a way that the data (the model), the presentation layer (the view) and the business logic that controls the presentation (the controller) is kept separate from each other. This has three advantages, firstly it means that the code should be more maintainable, secondly it should be easier to change the look of the application as the controlling code isn't mixed up in it and finally it should also be easier to test.

ASP.Net MVC has been around for quite a while, indeed we are now on version 4. But I chose to stick with the earliest version presentation framework in ASP.Net, known as web forms, when it was first released. The reason for that was simple, we already by then had quite a bit of code written using web forms and I wanted to concentrate on building on top of what we already had.

But with the release of version 4, I decided it was time to investigate. At the time I didn't know if I'd like what I saw or not and was expecting to come away with a very different opinion to that which I formed. As I learned about it I realised that it wasn't something I should ignore, and decided that from then on we should do any new web development using the MVC framework rather than web forms. However, we've got a lot of existing web forms code already and rather than just throw that away we've integrated the two frameworks so that for the foreseeable future our web software will be a hybrid of MVC and web forms. We'll convert our existing code as and when there is a need to.

Why did I decide to make such a drastic change? There are a number of reasons but the most important was that I liked the great degree of control that MVC provides over the form of the output HTML, which has allowed me to create web pages which are far less 'verbose' than the web forms equivalent meaning that there is less data to be transmitted to the browser. That's not so much of a problem with a browser running on a Wifi connection but is a boon when browsing over a mobile data connection where the user is potentially charged for how much data he or she uses.

Another reason was, and this is purely subjective, web pages seem to be rendered more quickly. This might not be the case but it certainly seems so, those pages that I've written with MVC certainly seem to be displayed in the browser more quickly than an equivalent page generated using web forms.

As a result of that decision we've now rewritten our Content Management System (CMS) to use ASP.Net MVC 4. This has yielded a number of benefits, for instance we've been able to simplify the interface, and more importantly it should now be possible for a customer to create their own template page and use it should they wish to as we've eliminated a lot of complex xml code that was needed to be added to the configuration file. Instead the details of the template are added to the database, this means that the user can copy one of our templates, make their own changes and then add it to and use it within the CMS.

Comments
To leave a comment please login
Register