Patterns

I See AnemicDomainModels

AnemicDomainModel is an anti-pattern I seem to keep coming across. Here's an overview of it, the problems it causes, and some pointers on leaving it behind.

Using Dependency Injection When Calling .NET Over COM

I've recently been working with a number of VB6 systems which use C# .NET components via COM, and wanted to keep the same sort of organisational structures and patterns in the C# part of the application as I would if it was a standard MVC app or WCF service - namely, using Dependency Injection to plug the various C# classes together. This is easier said than done with COM, but here's an approach I've used to achieve it.

So I did a grok talk on Unity Interception...

Yesterday I did my first grok talk - it was on Unity Interception at Dot Net Dev Net in Bristol, UK. It went ok! The feedback was that the content was very good but the presentation could have been a bit better, which is very possibly the story of my programming life :) For posterity, I've put the content on Github.

Why Automated Tests Are So Great

I've recently done work at a company where there are no automated tests, and tests aren't part of the culture. I've been writing tests for so long now that it's jarring to consider working without them, so I've gone ahead and written tests for my part of the work. As I've done so it's really brought home the advantages of writing tests, and I wanted to list them out.

Extending WatiN 3: Detecting if a PDF Has Opened In a New Window

WatiN lets you attach to browser windows so you can verify their contents and close them as part of your tests, but the standard API doesn't detect windows with PDF documents in them. Here's an extension method which does.

No More NCrunch For Me

NCrunch is a Visual Studio add-in which runs your tests while you work so you know if you've broken anything, as well as providing coverage indicators in the IDE and coverage metrics on demand. It recently went commercial, and time is running out for the free version I've been using for the last couple of months. From my experiences using NCrunch I'm going to let it expire, and go about my business without it. Here's why.

Agile Programming Practices 101 with the Nimble Pros Calendars

For the last two years, I’ve ordered the Nimble Pros Software Craftsmanship calendars, which use ‘motivational poster’ style pictures to depict various software practices and principles worth keeping in mind. Here’s one of the walls at work, where I’ve got the calendars cut up and displayed for easy reference: I like being able to point to a principle when its use pops up, and they provide a nice illustration of things everyone should be aware of. I’ll be following this up with a post on each month’s ......

Clean Code: Writing Readable Unit Tests with Domain Specific Languages

I'm currently reading Clean Code: A Handbook of Agile Software Craftsmanship by 'Uncle Bob' Martin, which includes a section on writing readable unit tests. I've had an article about using Domain Specific Languages (DSLs) to write readable unit tests in the works for a while now, and was inspired to finish it off using a 'clean' unit test from the book.

Populating ASP.NET MVC ViewModels using ViewModelBuilders

The ViewModels in my current project had got quite complex; as well as properties copied from model objects, they increasingly had flags used by Views to know whether to render links or sub-sections. The logic which set these properties was bloating Controllers, so I factored it out into objects which populate all non-editable properties of a ViewModel; ViewModelBuilders. Here's how :)

An Improved HttpModule to Redirect Requests When an Uploaded File is Too Big

Further to comments on my previous post on this topic, I realised my HttpModule which gives a user a friendly error message if they upload a file which is too big only dealt with half of the problem. The maximum size a request can be is specified in the machine.config and web.config in the maximumRequestLength attribute on the httpRuntime element; if a user uploads a file which is larger than that, the part of the HttpModule which checks the request size is by-passed, and the user gets a not-ver

Full Patterns Archive