Chess TDD 62: Finishing Chess TDD
You might not have expected to read this, and I honestly wasn’t really expecting to write it, but here we are. I’m going to call it and announce that I’m finishing Chess TDD series. It’s been a lot of fun and gone on for a long time, and I’m not actually done with the codebase (more on that shortly).
My original intention, after finishing the initial implementation with acceptance and unit tests, was to walk through some actual games, by way of “field testing,” so to speak. I thought this would simulate QA to some extent — at least as well as you can with a one person operation. And, with this episode, I’ve showed a tiny taste of what that could look like. And, I’ve realized, I could go on this way, but that would start to get pretty boring. And, I’ve also realized that it would be irresponsible.
What I mean is that plugging laboriously through every piece on the board after every move would be showing you a “work harder, not smarter” approach that I don’t advocate. I’d said that I would save ingesting chess games and using algebraic notation for an upcoming product, and that is true — I plan to do that. But what I shouldn’t be doing in the interim is saving the smart work for the product and treating you to brainless, boring work in the meantime.
So with that in mind, I brought the work I was doing to a graceful close, wrapping up the feature where initial board positioning was shown to work, and using red-green-refactor to do it.
You’ll notice in the video that the Trello board is not empty by a long shot. There’s a long list of stuff I’d like to tweak and make better as well as peripheral features that I’d like to add. But, to use this as a metaphor for business, I have a product that (as best I can tell) successfully tells you all moves available to any piece, and that was the original charter. It’s shippable, and, better yet, it’s covered with a robust test suite that will make it easy to build on.
What should you look for in the product? Here are some ideas that I have, off the top (and from Trello).
- A way to overlay algebraic chess notation for acceptance tests.
- Remove type checking for a polymorphic scheme.
- Improve the object graph with better responsibilities (e.g. removing En Passant logic from Board)
- Apply static analysis tooling to address shortcomings in the code.
- Make sure that piece movement also works properly (currently it probably wouldn’t for castling/en passant).
- Develop a scheme for ingesting chess games and verifying that our possibilities/play match.
In short, what I have in mind is bringing this application along with the kinds of work I’d advise the teams that I train/coach and assess. Here’s how to really make this codebase shine.
I have a couple of things to get off my plate before I productize this, but it’s not going to fall off my radar. Stay tuned! And, until then, here is the last of the Chess TDD posts in the format you’re accustomed to.
What I accomplish in this clip:
- Finish the testing of the initial rows on the board.
Here are some lessons to take away:
- The new C# language features (as of 6) are pretty great for making your code more compact and functional-appearing in nature.
- Always, always, always make sure that you’re refactoring only when all tests are green. I’ve experienced the pain of not heeding this advice, and it’s maddening. This is a “measure twice, cut once” kind of scenario.
- Clean, consistent abstractions are important for readability. If you think of them, spend a little extra time to make sure they’re in place.
- If something goes wrong with the continuous test runner or your test suite in general, pause and fix it when you notice it. Don’t accept on faith that “everything should be passing.” Like refactoring when red because “it’s just a trivial change,” this can result in worlds of downstream pain.