Alexander Beletsky's development blog

My profession is engineering

Inside ASP.NET MVC: Packing bags for journey

I’m big fan of ASP.NET MVC framework. It is smart, clean and testable. A lot of stuff you can do with MVC are very intuitive, you don’t have to go thought pages of documentation to do some basic stuff. I do not use MVC on my primary work yet (unfortunately) but my small project became very nice sandbox to play around and learn stuff.

I definitely learned something thought the year of hooked up with MVC. But feel I still miss a lot of details. Moreover, my hackers curiosity always force to look - “what is inside?”.

Great stuff about ASP.NET MVC project is that is open source. It is been released as open source and remain open source project till version 3.0.. In fact, it is very easy to start learning framework from inside! This what I’m going to do. I would like to go depth and hope that journey would be interesting and valuable.

Today I’ll to prepare everything I need for journey. I would be happy if you join me, so we would help each other along the way :).

Getting out source code

That’s easy. Just google for “MVC3 source code” and it would bring you directly to ASP.NET Codeplex site.

Download mvc3-rtm-sources.zip. Unpack the archive and you will see the solution file WebRuntime.sln and 2 folders: mvc3 and webpages. Layout of both folders are similar:

    /--- bin
    /--- src
    /--- tests
    /--- tools

Source code package is pretty much organized. Solution does not using NuGet, btw :)

Meet the solution

It’s time open up solution! Fire up Visual Studio and open WebRuntime.sln. Let the journey begins!

Nothing fancy there. Minimal number of solution folders, just MVC and WebPages. Each of folder contains a bunch of projects in it. In nearest future we would be much interested in one System.Web.Mvc - heart of MVC framework.

solution

Build it

Don’t waste any time and just build the solution. As it usually happened to me, with OSS projects - you always have some issues during build. It is not the case for MVC. Build runs smoothly as possible. The output is being placed in mvc3/bin/debug folder. So, as soon as build finished check it out and see for content.

output

Run tests

All TDD lovers would be really pleased with a number of tests in solution. There is 5004 tests actually, solid number of tests. No surprise MsTest framework is used. Let’s just try to run them!

In menu Test -> Run -> Tests in Current Context. Here we go.. It took a bit time to run all. I was a little disappointed to see that some tests are failing.

I did an inspection of failures and found out that all of them are actually related to my Local Settings. I use “Ukrainian Locale” that means time format, decimal point symbol etc. are differs from “United States Local”. It’s a quite common issue of units, workaround could be a simply change your locale to the one that rest development team uses. The rests of tests run’s just fine!

tests

Conclusions

So, my initial impression are:

  • Easy to build and start up
  • Code looks really nice
  • Code style a little differs from default C# especially in with “{”
  • code
  • Tests following AAA pattern really nicely
  • test
  • Code contracts are not used, but code pretty defensive with check for null arguments etc.
  • exception
  • All members are with “_” underscore - I like that :)
  • Methods are small and clean

What I don’t like to far:

  • Solution is quite big - I would be happy to have separation between MVC part and WebPages (if it is possible)
  • Tests are really slow. Suite run for 3-4 minutes (upd: I blame MsTest runner for that, with TD.NET all tests passed for 89 sec’s)
  • Already found some comments that lie (one more point to try to avoid comments if possible)

What is next?

Next, I will setup a test project which allow us to fully get in deep of details and see how it work.

Please stay tuned.