ChessTDD 51: Getting Castling under Control
Editorial Note: These videos appear on my Youtube channel, but I’m starting to do a lot of other things there as well, including an upcoming series that I’m going to start uploading soon. If you like the series, it’s probably worth subscribing to the channel. You can subscribe by going to this link and clicking “Subscribe.”
After flailing around a bit in the last episode, this one was a little more fruitful. Castling is now somewhat more under control, and it seems like things are progressing along a good path.
What I accomplish in this clip:
- Added more robustness in the non happy path scenarios around the new CastlingStatusChecker.
- Got negative cases working for king and rooks having moved on the white side.
Here are some lessons to take away:
- Don’t get married to implementations. Keep things light so that you can modify your approach as it makes sense.
- When it comes to collaborators in a class, reason about your preconditions on those collaborators (e.g. they can’t be null). Check for problems in the constructor so that you can fail more closely to the problem than if you limped along and failed only when someone subsequently called a dependent method.
- As has been mentioned a lot in the past, make sure that you take appropriate time to pick good names for things.
- Experiment with your methods, trying on different local assignments and such, to get your code as readable as possible. Hard to know what you’ll find readable until you actually see it.