Back in the saddle and making these regularly once again. In this episode, I start implementing castling. This proves to be something of a challenge because I’d gotten into such a routine of adding acceptance tests for the Pawn feature and changing mainly the Board class. Here I’m in a different set of acceptance tests and changing a different set of production code, so it took a bit to get my bearings. Castling, like en passant, is also a non-trivial edge case that deviates a fair bit from standard piece movement.
What I accomplish in this clip:
- Implemented castling to the short side of the board.
- Implemented castling to the far side of the board (though I think I got the move wrong).
Here are some lessons to take away:
- It’s a big help if you keep a nice, large surface area of testable code in your code base. This lets you dig in with the granularity of your choosing for writing tests.
- You need to carve out time to keep your code clean and do boy scout refactorings. If anyone is telling you not to do this, that’s a serious organization/group smell. You need to keep the code reasonably clean to sustain the pace at which you deliver value.
- As you have a larger and increasingly complex code base, “do the simplest thing that will work” becomes an increasingly tall order. With more tests that can go red, it gets harder and harder to do trivial things that satisfy all tests.
- It’s important to audit your tests continually to make sure they continue to add value.