New website, now Azure powered

Posted on Wednesday, 11th February 2015

In the beginning

When I first decided to start a development blog I wasn’t sure as to how much time I’d be able to dedicate to it and was concerned that, like many blogs online, my post frequency would start out string but begin to dwindle over time until it was never touched again.

With this uncertainty in mind, I didn’t want to spend too much time putting together a blog so I bought a domain and setup WordPress on my Linux VPS with a simple, only slightly customised template with the intention to see how I got on.

Fast forward just over a year now and I’m still blogging with reasonable frequency and feel I have gotten to a point where I feel it’s safe to say that I won’t be stopping any time soon. The rewards of blogging about programming related subjects have become clear to me and I’ve learned a great deal from investigating a subject enough to confidently write a blog post; and with this in mind I decided it was time to commit to spending some time and effort in updating my upgrading my blog to aid reader retention and act a platform for me to continually develop and evolve over time.

About the new blog

Whilst I was perfectly happy with WordPress as a blogging platform (I have reservations about the language used to create it but that’s another story!), I was keen to develop a solution in ASP.NET, and whilst conscious that I did not want to reinvent the wheel, I built myself a simple administration area that I can use to create and maintain posts. I’ve also been looking at other design patterns and techniques over the past few months and creating a blog seemed the perfect way to put some of them to practice and live with them a while to see their worth.

For those interested in what I used under the hood, below is the technology stack and why I chose to use them:

ASP.NET MVC

Being an ASP.NET developer MVC was an obvious choice. It’s a great, extensible framework that I love the more and more I use. I was tempted to dive into using ASP.NET MVC vNext but I decided to wait a bit until I cross that bridge, but it’s certainly something I entend on doing.

Dapper ORM

Initially I started out using Entity Framework, but given the simplicity of the blog and desire for speed, decided to give StackOverflow’s Dapper ORM a try. It’s a mega lightweight ORM created and used internally by StackOverflow who built it with speed in mind. I’ve really enjoyed using it and will no doubt be using it couldn’t recommend it enough when simplicity and speed are what you’re after. As an example of what Dapper does, among many of the other benefits, Dapper allows you to easily hydrate POCO objects like so:

public class Dog
{
    public int? Age { get; set; }
    public Guid Id { get; set; }
    public string Name { get; set; }
    public float? Weight { get; set; }

    public int IgnoredProperty { get { return 1; } }
}            

var guid = Guid.NewGuid();
var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });

dog.Count()
    .IsEqualTo(1);

dog.First().Age
    .IsNull();

dog.First().Id
    .IsEqualTo(guid);

Dapper also allows you to map a single row to multiple objects and allows you to process multiple result grids in a single query.

MediatR

This was an interesting choice and proved a real eye-opener to me.

I’ve always found software architecture an interesting subject and one that I’ve always gravitated towards, and being a frequent reader of Jimmy Bogard’s blog (creator of AutoMapper, and technical architect at Headsprings in Austin,Texas), I found his Putting your controllers on a diet blog posts particularly interesting as they introduced me to Command - Query Separation (CQS), and an alternative approach to the typical n-tier architecture that any enterprise developer will be familiar with - and Mediatr is a 

Being a separate subject in itself that deserves its own blog post, CQS is the process of breaking a solution down into simple, isolated Command or Queries; in this instance, using Jimmy Bogard’s MediatR library. When you do this you realise that the service layer becomes redundant and your code can becomes far more succinct and expressive.

Azure

I’ve been playing around with Azure for sometime now and decided to use it as my hosting provider. Using a shared instance that costs just a few pounds a month, Azure has done a great job in removing many of the issues you can have when setting up a website.