Today’s episode is one with a pretty directed focus. I’m actually typing this prior to doing the screen capture, but I know what I want to do ahead of time. I want to implement the King piece, and I have a relatively good idea how to do it.
Here’s what I accomplish in this clip:
- Implement King with GetMovesFrom()
Here are some lessons to take away:
- Sometimes you’ll go into a coding session with a discrete, obvious goal, and other times you’ll have to break a nebulous goal into discrete, obvious ones. But you always want discrete, obvious ones if you can.
- If you can save yourself using the mouse via being proficient with keyboard shortcuts, I’d definitely go this route. The time savings amortize over lots of coding.
- For “simplest thing” in TDD, it doesn’t always mean that you have to bang out a line of code. Maybe you can pull an existing method to a common ancestor and use it, or instantiate and use some other object.
- “Simplest thing” is kind of an art form geared toward your best productivity. If you’re new to the process of TDD, you probably want to keep it really simple before you’re experienced enough to be discerning. Once you’ve established it and gotten good at the basics, you can adjust to situational taste. Perhaps sometimes you’re stuck and need to get really simple while, in other cases, you have a good grasp on what comes next and being obtuse would just be busy-word. Practice and use your judgment.
- If you’re using a continuous testing tool (and specifically C#), pay attention to coverage with IEnumerables. It seems trivial, but it’s really better if you’re executing every line, even if it just means calling ToList() somewhere.