Using MVC at Specialmoves - Specialmoves

Using MVC
at Specialmoves

Specialmoves Labs

I joined Specialmoves as a .NET developer at the beginning of 2011. At the time, the lead developer had just started an MVC 3.0 .NET Razor project. At my interview, it was clear that MVC was the way forward for Specialmoves and I wanted to get involved with that. I had only ever worked on web forms and was really looking forward to seeing what was new.

A year into using MVC and I have to say it’s been a revelation. Writing and maintaining code is far more enjoyable than using traditional web forms. So why use it and why is it so enjoyable?

I would say the most compelling reason for using MVC is unit testing.  Anyone who has ever tried to unit test a traditional web form, will have found it very hard. You end up having to go around-the-houses to test around the page event lifecycle. Most unpleasant! MVC on the other hand is geared towards TTD.

MVC allows you to work in a loosely-coupled manner. We have been working with IOC (inversion of control) containers with an ORM called Entity Framework. The first IOC container we used was called Ninject.There was an issue with the way that exception handling was managed which meant we tried another one called AutoFac. This works great, and is dead easy to integrate into the project. Code written this way is easily testable. We use NUnit and Moq and find these frameworks work very well too.

MVC also gives you tighter control of the UI elements. MVC has ditched the idea of user controls (using partials instead) and that horrible abstraction of complex UI elements that tie the code behind to the html. At first you feel dirty working in loops and fragments of html, but it actually makes more sense once you get used to it. When using this with the new Razor engine, it provides a very streamlined syntax for writing clean and concise views.

When working in teams that include frontend and backend developers, this structure of coding makes it so much easier to work together.

MVC 3.0 integrates nicely with JQuery and has nice features such as ‘Unobtrusive JavaScript’. This makes the process of validation a no-brainer. 

In conclusion, MVC is a great framework that has a bright future. MVC 4.0 is just around the corner with some great new features, including built in minification of JavaScript and CSS files. Also there will be support for building mobile web applications and a bunch of other stuff. Read Scott Guthrie’s post on it.

Very exciting!

---

Christophe Chang is a developer at specialmoves where he likes to layer his code like a good lasagne @christophechang

Follow us on Twitter @specialmoves