Route Testing and MVC 2.0 Areas

Paul Hatcher
Posted in MVC
I’ve been using the MvcContrib.TestHelper class for a while now to get rather nice fluent testing of the routes in my MVC applications. A typical test class would look like this public class CategoryRoutesFixture : RoutesFixture { private const int categoryId = 34; private static string BaseUrl { get { return "~/admin/Category"; } } [Test] public void Index() { BaseUrl.ShouldMapTo<CategoryController>(x => x.Index()); } [Test] public void Create() { (BaseUrl + "/create").

Algorithm Performance

Paul Hatcher
Posted in Algorithms
I was chatting to a colleague recently who although he was a very good programmer, did not have a computer science/maths background – this was fine until he wanted to use bubble sort on a large(ish) (100k) number of records and I had to explain to him about how algorithms that take n2 time are not your friend for big (or even little) n. One of the most important decisions you can make when optimizing an application is the up-front choice of algorithm to use, performance tuning and optimization can make a difference but you are very lucky to achieve 2x-5x improvement, to be able to make 10x or 100x improvement in your application you need decent algorithm choice.

Automating Visual Studio Templates

Paul Hatcher
I find Visual Studio Item Templates very useful, but a lot of teams I encounter haven’t really adopted them as they can be a pain to construct. Here’s the technique I use to manage the templates and make it painless to add new ones and modify existing templates if they need to change. What we do is put the templates into source control and then use a build process to automate the production and distribution of the zip files.

MVC 2 EditorForModel and DropDownList

Paul Hatcher
Posted in Patterns, MVC
Sometimes doing very basic things can be quite tricky in new technologies; case in point presenting a DropDownList (a ComboBox to those, including me, with a VB background) using the new EditorForModel syntax in ASP.NET MVC 2. I had a little class in my MVP framework called IdLabel which as the name implied just held an Id and a Label so that I wasn’t forced to have a separate display and edit model for every trivial case, so I wanted to do the same sort of thing when writing my shiny new MVC apps.

Debugging ASP.NET MVC 2 Source Code

Paul Hatcher
Posted in Patterns, MVC
I’m trying to write some templates for MVC 2 and one of the most useful things I’ve found is being able to step into the source code and see how it is actually interpreting what you’ve written. It’s easy enough to acquire the source, but what you might not have done before is set up a symbol server. A symbol server is a location that the Windows and Visual Studio debugging tools can use to obtain pdb files, so that you can debug almost anything, including drivers and the operating system!