The 2009 Advent calendar situation

Assume that you have some important object that performs some important task. It may look something like this: 1: public class ImportantObject 2: { 3: public void ImportantMethod() 4: { 5: // Do things. 6: } 7: } You’ve done everything right and created this object using BDD/TDD but one day everything changes. You need…


Advent calendar 2009 – how to TDD thread safety

Last year I wrote the same test in 24 different ways as a little advent calendar for you to enjoy. This year I’m going to do something similar but also a little bit different. I’m going to start with a simple piece of code and then show how this code can be tested for thread…


How do you reward good service at a restaurant?

I bet your answer to this question is; by giving a good tip. So what do you do if the service was bad? Here I predict two different answers, either you don’t give a tip or you complain to the management of the restaurant. If don’t tip I bet you leave the restaurant with a…


Pugh Decision Matrix

The Pugh decision matrix is a is a tool to help you make decisions when you’re trying to sort out what alternative is the best but they all have their pros and cons. It can also be used to help a group decide on a decision. The way it works is that you first list…


How to prevent the use of "SELECT *"

One good tip for writing good SQL code is to always select the columns you need and never just select everything. Well here is a description on how to actually prevent SELECT * queries (you need to complete a free registration to see the article). The basic idea is to add a dummy column to…


Team Coding Dojo 7

This time we did a new Kata – variant of poker hands. Instead of being so specific about the interface the user story we used for the Kata was simply; Given two five card hands I want to know which hand is the winner. We also choose to use the object calisthenics rules. The biggest…


Refactoring is not rewriting

Today I got that feeling of how the use of one word, interpreted differently by different people result in misunderstandings. It was when I read this which IMHO is full of misunderstandings (including some of the comments). One example is that refactorings must break unit tests. No that can never happen because refactoring is about…


How do I get someWin32API method to work in .Net?

It was some time since I last needed to use P/Invoke but it seems like I always need something from a standard C DLL or the Win32 API. Not that I needed it today, but I stumbled across this site which I will remember for future reference. Looks very helpful.