Using MVC at Specialmoves - Specialmoves
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.
Christophe Chang is a developer at specialmoves where he likes to layer his code like a good lasagne @christophechang
Follow us on Twitter @specialmoves