DominicPettifer.co.uk (this Blog)

Completed Date April 2009. Webite: www.dominicpettifer.co.uk

My own personal blogging site. Originally written in ASP.NET 2.0 Webforms, it has now been converted over to ASP.NET MVC 1. They say you have to rewrite something 3 times until you produce your best work, so maybe once I port it over to MVC2 it'll be the best blog in the world :)

Core Technologies & Skills

  • ASP.NET MVC 1.0 / C#
  • Visual Studio 2008
  • Subversion source code control
  • NHibernate
  • SQL Server 2008
  • XHTML/CSS

Description

The original version of this blog was written as a way for me to learn ASP.NET 2.0. It was completed in November 2006 and was my first real ASP.NET application. The newer version of this blog you see before you has been written in ASP.NET MVC and was rewritten for similar reasons, as a way for me to learn ASP.NET MVC, and also to apply new skills and techniques for building websites that I have learnt since 2006.

These new techniques include more sematic, standards compliant XHTML/CSS, leading to better accessibility, SEO, and website download speed (slimmer HTML payload). The old version of the site used some table based layout, and mixed in some more presentational based mark-up, instead of keeping it in the CSS.

Code base

The old version of this blog used a custom built Data Access Layer using the Provider Model Design Pattern, which the WebForms code behind pages spoke directly to. In this rewrite I have used NHibernate ORM as the data access layer. The DAL is hidden behind an interface based Repository layer which serves domain centric objects, this is to make the data layer plugable. I can strip out the NHibernate Repository and replace it with something else such as LINQ 2 SQL, or Entiry Framework, or even a cloud hosted DB such as AmazonDB or Microsoft Azure, all without having to make any changes to other parts of the code base which speak to the Repository.

An interface based Service Layer sits between the MVC Controller and the Repository, The Service layer handles all of the business and validation logic. The Service and Repository layers make up the Model in MVC. Seperating the Model like this serves to make the Model more testable with Unit tests, as everything sits behind interfaces, those interfaces are easier to mock with Mocking frameworks such as RhinoMock. It also keeps the Controller logic as thin as possible. It's often said that an MVC application should have a thick Model, a thin Controller and a dumb View.

For the View part of MVC, I always strive to serve strongly typed ViewModel specific objects to the aspx view page, never data objects sent from the Repository. This serves to keep the View relatively clean of code segments, as any conditional logic or decisions the View needs to make can be contained in the ViewModel object. For instance, encoding a blog title into a format suitable for URLs so that /Blog/123/ASP.NET Tips & Tricks becomes /Blog/123/asp-net-tips-and-tricks, the View just calls a Property Model.UrlFriendlyTitle on the ViewModel object instead of having to import namespaces and call code in the View.

Future Work

Right now, in order to get the website up and running and out of the door, I have taken on a lot of so called 'Technical Dept', where I have implemented a lot of things in a quick 'n' dirty way, with the intention of implementng it properly later on (paying off the Technical Dept, read the article, it's a brilliant analogy). There are currently no Unit tests and there is no IOC container in place, recommended agile programming practices for an ASP.NET MVC application. There are also a few dependencies between the Service Layer and the Controler. I plan to continue developing the blog engine and fix these shortcommings, where I plan to eventually make the blog engine open-source. Watch this space.

Random Image

Hamster in a shoe

Hamster in a shoe (from the blog And So It Begins (part 2) )

Quick Poll

What is your DIP/IOC Container of choice?

Poll Vote
(see results)
View Comments (0) (See previous polls)

Latest Tweets

  • Red Bull gives you wings....that generate huge amounts of downforce #F1

    about 18 hours ago from Twitterrific
  • .vampire { -webkit-box-shadow: none; -webkit-box-reflection: none; } #cssjokes

    7:44 PM July 30th from Echofon
  • @edhenderson lol, lets get a trending topic going - .gangster .wrapper { color: #000; width: 150%; text-decoration: bling; } #cssjokes

    7:36 PM July 30th from Echofon
  • @weblivz I think the petition should be resubmitted but with security stuff taken out, as that's what the response purely focused on

    6:13 PM July 30th from Echofon
  • @weblivz I still think Chrome Frame can come to the rescue here, still keep their old browsers + legacy systems, no retraining costs etc.

    6:12 PM July 30th from Echofon

View Dominic Pettifer's Twitter page.