MVC - Where To Put Business Logic?

I just had an email from a friend asking where business logic should go when using MVC - the controller or the model. I thought I'd share my reply: I think asking whether the business logic should go in the Model or the Controller is a false dichotomy. There are…
Continue Reading

Testing IoC Registrations

When I first started writing automated unit tests for my code, I remember getting carried away writing lots of tiny little tests, each with a single Assert. It felt good initially to see all those green ticks, but rapidly became a maintenance headache, and I am now happier having fewer…
Continue Reading

SupportDetails.com

Here’s a super-handy little site for anyone who’s ever had to perform website support over the phone. Instruct the user to navigate to SupportDetails.com. They can then see the answers to most of the questions you’re likely to ask, and have the option to send the…
Continue Reading

WCF - NHibernate Unit Of Work Endpoint Behavior

OK, my last WCF-related code snippet of the day, I promise. This is quite similar to the last one. I required that the WCF service I was developing started a new NHibernate Session for each invocation, and closed it after invocation (i.e. session-per-request). I couldn’t rely on…
Continue Reading

Testing LINQ Queries

I’ve been asked “How do you test LINQ queries?” a couple of times in the past few months, so I thought I’d blog my answer for the benefit of all you lovely people. Firstly I should explain how I’ve been doing most of my data access in…
Continue Reading

WCF - Global Exception Handling

I’ve done a fair bit of WCF development recently (and amazingly I came out of it relatively unscathed, both psychologically and emotionally). Using Castle Windsor’s WCF Facility helped a great deal, but I still found myself writing a fair bit of infrastructure and plumbing code. I thought I…
Continue Reading

WCF - Logging Before and After Operation Invocation

Here’s another custom WCF EndpointBehavior I found useful recently. Not content with logging all unhandled errors, I wanted to output a DEBUG level log message before and after every operation invocation. As before, I’m using the Castle Windsor Logging Facility to handle my logging, but you can swap…
Continue Reading

An MVC Gotcha and the PRG Pattern

If you’ve recently moved across to ASP.NET MVC development following years of wrangling with the leaky abstraction that was WebForms, you may have encountered some seemingly curious behaviour when posting back to the same URL. Suppose we have the following simple, contrived and utterly imagination-free model: Here’s…
Continue Reading

On the Market Again

This blog post comes to you live from a Starbucks in the north of England. Yesterday I wrapped up another eight months’ stint contracting at my old haunt Marshalls Plc. It’s been a genuinely interesting gig, working on two distinct greenfield projects using bang up to date technologies including…
Continue Reading

MoreLINQ - IEnumerable Extension From Jon Skeet

I’ve just become aware of this MoreLINQ project containing some neat IEnumerable extensions authored by the inimitable Jon Skeet. I particularly like the look of DistinctBy – that’s gotta be a lot easier than passing custom instances of IEqualityComparer into Distinct(). Fun fact – I used to work with someone…
Continue Reading