I have been wanting to implement a simple turn based game for almost two years now. I have actually started on the implementation several times, with one version on GitHub and another three failed attempts that never made it far enough to be pushed.

So the question is: why was I unable to implement this game? The concept is not particularly difficult, nor the logic particularly complicated. Just the same, each of my previous attempts had been an abject failure.

I believe the reason for this is actually quite simple. I couldn’t work out how I wanted the front-end to look and function. I got so caught up in trying to imagine the interface that I almost always failed to implement any of the actual game. Instead, I got the user logged in, viewing games and joining games, but never made it to implementing the gameplay itself.

Why is this? I was following good BDD principles, designing from the outside in, writing tests as I went.

The issue here was biting off such a large project as a single implementation that I was focusing on how the whole world would interact before I had a chance to work out the important parts of that world. I had so much overhead that I got lost in the details.

This time around I tried something different: I still used BDD to drive my design and I still wrote tests before I implemented the code. However this time around I started with a gem that implemented the game engine instead of a game. I didn’t worry about persistence (beyond the JSON format), race conditions or player authentication as these are all parts of the “front-end”. Instead, the game can load from a hash/JSON representation, perform some game action or set of actions and then export a JSON representation of the game state.

By focusing on this core bit of what I wanted to do, focusing on the game logic itself, I have succeeded where in the past I had failed. That is not to say that I have a fully working application - at least not yet - but I can now see much more clearly how the game interacts with the interface.

In conclusion, I feel my mistake here was remembering that when BDD talks about building from the outside in it is important that you correctly identify and define what the outside is for your current project or task. Otherwise, you may find you’re stuck like I was after biting off more than I could chew - at least in one go.