I was working for my poker game client yesterday. This project now seems to be firmly test first. What was interesting with yesterday’s work was how the tests drove the design and how when I finally came to integrate the tested code into the main body of code the required design changes weren’t an issue as I had a whole load of tests to support the changes.
I was adding some code to manage the pot during play.
Today we wrote some complicated FX business logic tests. Things like making sure that the FX library can calculate a EURUSDCAD 1M rate - it can; or a USDCAD ON rate - it can’t and nobody had spotted the fact that it was out because it’s way down in the 0.00001’s of the rate.
It has taken us around a week to get here. The initial code was a tightly coupled mess.
So, it’s been 35c here in London for the last week and, strangely, my thoughts have turned to snow… We’re off to Saas Fee in September and I’m starting to do the ‘check the resort web cam daily’ thing. Having never skiied in Europe this early in the season it’s a bit nerve wracking. Still, Saas Fee has a good glacier and they are used to this kind of thing; so, finger’s crossed.
On Friday we got to the point where the FX buiness logic code was suitably decoupled from the display logic that we could write our first test for the business logic. In the words of Homer Simpson, “Woo hoo!”.
Test one was a simple one; can we construct the FX ’live point’ object. After adding a few interfaces and mocking up a service provider or two we could.
The object uses two-stage construction; not ideal, but the code doesn’t use exceptions yet.
We couldn’t skate last weekend as we were in Dublin at the wedding. This weekend was going to be really hot in London (35C+) which isn’t ideal skating weather. We decided to get up a bit early and skate before it got too hot… So we both saw 7.30am on a Sunday morning for the first time in a long time and skated before it got too hot at Hyde Park.
We had a busy weekend. Michelle’s brother Chris married Hilary in Dublin. Good fun was had by all and it was a wonderful few days. The wedding was in Castleknock and the reception was at The Four Seasons in Ballsbridge.
It was a bit of a shock to have to come back home; I could quite happilly have stayed on a few days longer at the Four Seasons and spent the time drinking Guinness and watching the world go by…
Bleugh! You are lost in a maze of crapy code, all alike (and much of it copy and pasted!). The last few days have been deep in the heart of darkness. Gently teasing the business logic and the display logic of the FX code apart so that we might one day be able to write tests for the business logic.
We’re nearly there but it’s been a long job. Much longer than any of the other refactorings that we’ve done.
Writing stuff down makes you think about things. Take the “balls in the air” piece. I had a problem, I didn’t realise what the problem was until I wrote about it and now, a week later I see the problem coming up again and know what it is and how to avoid it. Magic!
Some things that take 4 hrs can be done in 8 30 minute segments. Some must be done in one 4 hr session.
As I mentioned a while back, the refactoring project’s FX functionality was developed by guess work. We’re fixing that now by spending some time gaining an understanding of the problem domain as we refactor.
I’ve always been pretty proud of the fact that I deliberately set out to know nothing about your business. I think it makes me a better developer. I know that I know nothing about how your business works; I don’t assume that I know better than you do just because I’ve read about your business area a couple of times.
Hit a deadline early this afternoon and hadn’t chased up some requirements so I ran out of things to implement. Faced with a couple of hours spare I whipped out Gimpel Lint and started to polish…
I’ve been a fan of Gimpel’s PC Lint product for several years. It’s like turning compiler up to warning level 11. I try and keep all of my code passing through it without any warnings.