Sep 3, 2016

Turning coding into a 4X game

I am a fan of 4X games, but I don't have time for gaming these days :( So, let's see if we can add a hint of gamification to coding! Get points for doing stuff you should do anyway, and earn new "abilities" on the way.

I've been surprised before at how much a point system or a badge can do (just look at untappd). So why not give this a shot? The hardest part will probably be keeping count of your points.

Worst case if you try, you'll end up with better code - or better knowledge of it.

This one's a given, I guess. Whenever I join an existing project I spend some time exploring it, taking the tour so to speak. This may be the hardest task, it's not always easy to pick up all quirks or where non-core logic lives. I generally recommend getting an overview from one of the architects or a well seasoned developer on the team, then dig from there.

A little hard to gamify, but: 10 points for completing, not skipping ahead!

Add to the existing code base. Write tests if they're missing. Implement new specs. Write more tests.

1 point for adding new functionality. After all, that's the fun and easy part. 5 points for each missing test added. 100 points for writing a test that uncovers a bug. In my experience you can get a lot of points here...

You can get new abilities as you progress as well, how about
Level 1: Write unit tests ONLY. Write 10 passing tests.
Level 2: Integration tests allowed. 10 integration tests and 10 unit tests.
...and so on,  let me know where you end up ;)

I like to think that I apply SOLID and DRY principles to my code. See if you find parts of the code that may be in violation.

Level 1: Find 5 DRY cases and fix them
Level 2: Find 5 Single Responsibility cases and fix them
Level 3: Find 5 Open Closed cases and fix them
... and so on

The fun part! You get to delete any dead code you encounter, be it commented code, unreferenced functions or entire files.  But here be dragons: Unless you have gained an intimate knowledge of the project, see "Explore", you'll risk deleting code that seems unused, but is actually referenced from some arcane spell.

Another way to "exterminate" may be to do code reviews with your peers (or shall we say, competitors) and give points for finding issues in their pull requests.

1 point per deleted line of comments, 5 points per file or class, 10 points for issues in your peers code.... this may harden the competition. Increase at own risk for further friction in the workplace!

Complete all 4 without breaking anything and get an extra life for you next project!


No comments:

Post a Comment