Chess TDD 46: En Passant Expiration Date
This installment of Chess TDD was another episode focused on en passant. It’s been a while since I was in this code base. I’d been on the road a lot and without my main development/recording rig. But now I’m back and was able to take the opportunity to record a little Chess TDD ahead of my wedding next week. This episode went pretty smoothly. I cleaned up a method from last time that had become unwieldy and then got the next acceptance test to pass without any flailing. Not bad for so much time between episodes!
What I accomplish in this clip:
- Refactored the Board.MovePiece method away from mounting ickiness.
- Implemented functionality to prevent en passant from lasting beyond one turn.
Here are some lessons to take away:
- When extracting methods during a refactor, if you have a hard time giving the new method a coherent name, it might be a sign that you’ve selected non-cohesive functionality to extract.
- Spend a few extra brain cycles contemplating the names that you give things. This investment will pay off because it’s easier to give things good names when their functionality is fresh in your mind.
- If you start to have code that no longer seems to belong in a class, make sure you’re keeping that visible to yourself as you go so that you can have a nice cue for refactoring.
- Take care to keep communication between methods and classes at an appropriate level of abstraction. Make sure they’re communicating in obvious domain concepts.