For the most part, I keep my professional blogging separate from my hobby blogging. During the day, I’m a programmer for the University of Notre Dame, and at night a pen, paper, and cardboard gamer.
I consider myself to be a reasonably competent programmer, but recognize continued room for growth. This manifests in reading and experimenting in code. Lately, I’ve thought of myself more as a software doctor than a software engineer. Doctors practice medicine, and I practice programming.
This past month, I picked up Avdi Grimm‘s “Objects on Rails” [Free legal online version] and Uncle Bob Martin‘s “Clean Code". I’m interested in exploring better software design, with a focus on code refactoring…I’m the primary maintainer of a 6+ year old Ruby on Rails based CMS (It started somewhere around Rails 1.1.6 for those keeping score). And sometimes it feels like I’ve donned the Black and patrol the Wall. But I digress.
I decided that I wanted to apply some of these principles to a problem space that I understood…RPGs. In particular, I wanted to automate the Diaspora Cluster Creation, not because it is convoluted, but because it is very well defined process. That is to say I already understood the domain.
Over the past week, I’ve worked on creating the Diaspora Cluster Creator command-line utility by striving to apply these recommended constraints and methodology. The tool I’ve created is an over-engineered solution for what amounts to 5 minutes of dice rolling at a table with a group of friends.
This exercise has proven to be ridiculously rewarding. I was working on a greenfield project and trying to adhere to the teachings of others. In some cases, I stumbled, creating code that I should’ve known would be a problem; Hint, if the tests are complicated to setup, then there are issues. But, through refactoring, I was eventually able to clean things up – I’m still not satisfied with the Node class.
While I typically try to work within these constraints, for this project I was trying extra hard to keep them at the front of my considerations: The Law of Demeter, Single Responsibility Principle, Test-Driven Development, Command/Query Separation, general readability, and fast tests (Corey Haines would be proud).
The result has been a code-base that has been very fun to work with, and has been relatively painless to extend. The Cluster creator can just as easily create Diaspora clusters with attributes different than the assumed Technology, Environment, and Resources.
The command-line solution is not suitable for the general role-playing populous, so I’ll need to take that into consideration.
For those of you interested in installing it yourself, it’s up on Githuband available as a Ruby gem –
gem install diaspora-cluster-creator. You can take a look at the Cucumber feature that defines the command-line behavior of the tool (Hint: there are several options).