Coding and Dismantling Stuff

Don't thank me, it's what I do.

About the author

Russell is a .Net developer based in Lancashire in the UK.  His day job is as a C# developer for the UK's largest online white-goods retailer, DRL Limited.

His weekend job entails alternately demolishing and constructing various bits of his home, much to the distress of his fiance Kelly, 3-year-old daughter Amelie, and menagerie of pets.


  1. Fix dodgy keywords Google is scraping from my blog
  2. Complete migration of NHaml from Google Code to GitHub
  3. ReTelnet Mock Telnet Server à la Jetty
  4. Learn to use Git
  5. Complete beta release FHEMDotNet
  6. Publish FHEMDotNet on Google Code
  7. Learn NancyFX library
  8. Pull RussPAll/NHaml into NHaml/NHaml
  9. Open Source Blackberry Twitter app
  10. Other stuff

How To Test Your MVC3 Model Validation and Controller Logic

Hi all,

Today, I've come across some code that's testing an MVC controller to ensure that the controller responds correctly if the model passed in is invalid. This sounds a good plan - except that you need to be mindful that your controller doesn't validate your model! Your view model is validated by a separate class, the ModelBinder, that fires up just before your controller is executed. This ModelBinder is built into the MVC engine, you can bet that it's been tested a zillion times by a zillion other devs, so you definitely don't want to find some way to test this ModelBinder directly.

So what to do? Let's take a look at the original test, exactly what code we've written, and so what we want to test.


Permalink | Comments (1)

Unit Testing Good Patterns #4 - Know When Not to Test

This week's been aaaallll about automated testing for me. On Monday, I attended Preston Codejo, looking at unit testing in Ruby. I was there as a Ruby novice, there were a couple of TDD novices, so some great discussion around the merits of TDD. My working week has been spent sneaking SpecFlow and acceptance testing into a new project at work, and yesterday I spent a few hours watching one of Uncle Bob's Clean Coders videos with some colleagues. As usual, my DRL posse had some really interesting thoughts around it - more discussion around the merits of testing followed.

And then there's a bit of discussion on Twitter about TDD not being the silver bullet some would tout it, I speak very highly of TDD as a practice. Some would describe me as a bit of a zealot, so in the interest of balance, I want to make a confession.


Permalink | Comments (0)

NHaml - Lessons From Adopting an OSS Project

Hi all,

Some weeks ago now, I blogged that I've adopted the open source NHaml project over at GitHub, I'm now an administrator. I also mentioned that I was looking to get an initial release out sometime in December. Since then I've been beavering away at the thing, we're now most of the way through December, it feels like it's time for a status update.

In this post, I'll be talking a little about the project as I picked it up, lessons learned in my first baby steps adopting an established OSS proect, the decision to go with a (almost) rewrite, TDD and why I feel this is important stuff, and a few other odds and ends.

Incidentally, I in no way whatsoever mean to sound like I'm having a dig at previous contributors to the project, the stuff I'm putting into the project now owes massively to these earlier contributors, I'm trying to evolve as many of their existing ideas as I can. 


Permalink | Comments (0)

An Enterprise MVC .Net Project Template - Part 1 of Many

Hi all,

That time's come again - another project's come along (actually an oooollld project from 6 years back has come around again), and I'm about to fire up Windows Explorer and Visual Studio ready to start dev.

I've done this dozens of times over the last couple of years, but I still remember back in the early days struggling to get to grips with where to put what, where to put my DLLs, my unit tests, etc. So I thought some folks might benefit if I jot down some notes as I go along. This post will detail exactly how I get started with a new Visual Studio project, in this case looking at an MVC project, and all of the things I do before I start cutting code.

By the way, this is the same project structure I use for most of my enterprise level work. I'm going to document this for Subversion users, as I still feel like they're in the majority (and I still suck at Git), so Git or Mercurial users will possibly want to ignore me when I talk about branches and trunks!


Categories: Architecture
Permalink | Comments (2)

An Announcement - I've Adopted NHaml!

Hi all,

A really quick blog post, to make a quick (and for me very, very happy) announcement - I've been given the opportunity to adopt the currently dormant NHaml project, a .Net port of the popular Haml Ruby markup language.

This is the first opportunity I've had to work on an established open-source project such as this, and while what's been built is impressive stuff, there's clearly a lot of work to catch up with the current Ruby implementation! Fortunately I've got a good clear initial target to aim for, thanks to the hugely useful Haml Spec project.


Permalink | Comments (4)

What The Heck's a 'Front End Dev'?

I had an interesting chat with a few colleagues of mine yesterday, and it was on the subject of the "front end dev". The two colleagues in question were a designer, and a good all-round developer, each with 10 years experience in their respective fields. So they've been through the mill.

The subject of JQuery came up, and after a little rumination on things, we kinda agreed that what the web needs, is a new specialism, the front-end developer. So were we right? If you're a dev, is now the time to go for that niche and specialise, if you're a designer, are you going to have to get used to your finely crafted CSS getting butchered by some nightmarish hybrid creature, neither a designer or a fully fledged dev? (A were-dev?)


Categories: Software Industry
Permalink | Comments (0)

Editing JPEG Photos Without Recompressing - Part 2

Hot on the heels of Editing JPEG Photos Without Recompressing - Part 2, I've had a few days to ponder, and I'm back with more thoughts on editing JPEGs without recompression, and maybe with a conclusion. Where we left off, we'd determined that the JPEG compression steps that we'd need to deal with, in decoding order, are:

  1. Huffman decoding
  2. Run-Length Encoding
  3. Zig-Zag scan
  4. Quantisation
  5. DCT transform

We're aiming to do as little of the above as possible, so to affect the image compression as little as possible (if at all).


Permalink | Comments (0)

Editing JPEG Photos Without Recompressing - Part 1

Hi all,

A bit of a departure from the norm today, I've just spent the afternoon having a whale of a time with a good mate of mine, talking guitars, web programming, a bit of home automation, and at some point the subject of time lapse photography came up. But wait, isn't this a coding blog? What the heck's this got to do with code!?

Okay, some background first. My friend is fortunate enough to have a view from his window over the beautiful countryside surrounding Preston, out towards the coast. For a year now, he's had a digital camera trained on said countryside, taking a photo every minute. 12 months and half a million photos later, he's discovered a problem. Some of his photos need touching up, and by some I mean a LOT. Here's where the coding comes in.


Categories: Hacking
Permalink | Comments (0)

Four Of The Best Linq Extension Methods

If you've read any of my previous blog posts, you might have the feeling that I absolutely love Lambdas in .Net, they're just plain awesome. Get a good handle on Lambdas, and you can chuck out a good wedge of your crummy old nested "foreach" statements. When the language feature first came on the scene, Lamdas seemed (to my eyes at least) to be confined to the world of Linq extension methods. Since then of course there's been a plethora of tools that have jumped on, such as Fluent NHibernate and Moq, but there's still plenty of life in the ol' Linq extension method yet! Here are my top four linq extensions, the lifesavers that I keep coming back to.


Categories: Architecture
Permalink | Comments (0)

"The Rules" Part 1 - Single Responsibility Principle

Over the last few years, my experience of being a software dev has changed massively. I've not changed the language I code in, I've not changed what I'm trying to achieve, the change has purely been a move from coding on my own, to coding as part of a team.

Previously, my number one concern was "Does this code produce the right end result". Today, I balance this with the need for clean and reliable code. Now that I work as part of a team, I see that code needs to do more than just work. It needs to work reliably, it needs to be resilient in the face of unanticipated change, and it needs to be trustworthy in the eyes of my colleagues.

This should be the first of a couple of blog posts looking at different ways I'm striving to write resilient code. My four planned posts are:

  • Single Responsibility (this one)
  • Command-Query Separation
  • Tell Don't Ask
  • The Law of Demeter

If anyone can suggest anything to add to this list (Open-Closed principle and Design By Contracts are on the edge of my mind somewhere), please let me know in the comments below.


Categories: Architecture
Permalink | Comments (0)