A lesson in testing
October 28, 2006
A while back I wrote a basic Neural Net class in Objective-C, and tested it pretty well. Or, so I thought. The net was a bit slow at calculating output, so I decided to rewrite it. I had originally used Objective-C arrays for simplicity, but they were hurting performance so I decided to swap its implementation for C arrays instead. However, my test suite had poked inside the internals of the class, so at every step I was now having to rewrite the tests as I was rewriting the internals of the class I was testing. I did this to keep the interface small, but it was really biting me in the ass now.
I ended up reverting all the changes I had made and completely rewriting the test suite to only use the provided interface of the class, adding to the interface as needed. After cleaning up the test suite (this had the unforseen side-effect of making the interface a lot nicer to work with) I rewrote the internals as I had planned and managed to get a five-fold speed increase, without changing any of the tests at all.
Lesson learned: don’t be afraid to enrich your interface if it makes your code easier to test.
Home improvement
October 28, 2006
Man, I’m poofed! I’m relaxing on the sofa, treating myself to a Cobra. I’m celebrating that I finally managed to hang up the kitchen shelves I bought some time ago. When I say I bought kitchen shelves, that’s not actually entirely correct; I bought sheets of chipwood with pearwood finish that I had to cut into the right shape.
The shelves were going into a corner between two cupboards, so I needed to cut off all four corners of each sheet and end up with something five-sided that looked vaguely pentagram-shaped if you’d squint. Nadia and I spent several hours last weekend trying to calculate angles and lenghts until we saw squares and triangles dancing before our eyes; we had carefully measured the lengths of all the sides beforehand but just couldn’t seem to get things to match up. We had assumed that the angles between the two walls and between the walls and the cupboards were all 90 degrees. Unfortunately, they were not and I ended up just cutting the first one by careful eye-measurement and using it as a template for the last two.
After much huffing, puffing, drilling, sawing, panting, sweating, screwing and swearing the shelves are now finally up.
Google maps
October 4, 2006
I just learned, via the spool, that Google Maps have updated their London imagery. It turns out that my humble abode is now an actual building, and no longer a big hole in the ground. Yay.