October 2009 Entries

Things I’ve learnt lead to badness…

Some of these I’ve done.. some I’ve just seen.. but they are all now things I watch for… Never talking to someone who is going to physically use your solution… Not having acceptance tests… Showing up for your new job and being handed a few binders worth of the design that someone who has already quit did… Working at the same job for so long that it makes you think about becoming an electrician… Not practicing TDD… ...

Rounding up to the nearest 0.05

Recently I ran into an interesting problem on a small project I was working on.  The problem was on the surface fairly simple.  Take a currency amount and round it up to the nearest 0.05.  While the solution is not earth shattering it took long enough to figure out that I figured it was worth recording for my future self.  The first part of the problem is to round to 0.05 which is accomplished by doing this (thanks Google..): decimal initialValue = 0.56; decimal value = Math.Round(initialValue / 5, 2) * 5; But the problem is this code...