Skip to main content

Gamify TDD

I like it when things that would not normally be associated with games add concepts from games as a way to incentives you to accomplish things. Why simply go for a run if you can have an app that will track you and give you a gold star if you do better than you did the last time? Why go to the coffee shop that only gives you coffee if the other one will give you points that you can redeem for free drinks eventually?

I was recently introduced to CodeSchool, an online training system similar to PluralSight, it has video courses and challenges you can take to prove that you retained what the video taught. CodeSchool also adds badges and tracks to your learning, so as you complete a video and its challenges you get a badge. Complete a collection of courses within a specific discipline and you become a master of that discipline.

Some of these incentives are not tangible and really don't mean much in the real world, but they tend to work for me. If I start working towards a large goal and I have little pieces of motivation to help me along, I am more likely going to want to complete the goal and collect all the trinkets that come along with it than if the end is way off in the future. I am also more likely to complete the task sooner because I can get a sense of completion much faster by reaching a smaller goal/achievement/badge/star and I will continue to be motivated to reach that next smaller piece.

TDD has some of these incentives built in already. You should be making small breaking changes that you can then quickly fix. After I fix a small issue and see my tests pass, I feel a little surge of success that I carry with me into the next change that needs to be made. By breaking changes down into small chunks that you can solve quickly you are also focusing on the little thing in front of you that you can do, rather than on the overall, larger problem.

This is again an area that I love NCrunch, NCrunch is constantly testing my project and will tell me when a test is failing, and also when a test passes. Having this immediate feedback really increases the feeling of success when I get a test to pass. NCrunch goes a step further on the path of making TDD act like a game though. It adds to the sidebar of the code window indicators that let me know if the code I am looking at is covered by a test, passing that test, failing that test, and has possible efficiency issues. If I open an existing class and don't see a bunch of colored dots along the side, I know that this class is not covered under any tests. If I see a bunch of Red dots on the side, I know that there are failing tests that I need to fix. As I work through changes I can see my progress immediately, in the window I am coding in without needing to switch over and run my tests.

So NCrunch provides me with a level of gamification above just testing by providing feedback in the code window, attached to the executing code itself. What I would like to see next would be to increase the incentives for more coding. Perhaps some achievements could be added that tie into your tests and code. If I create 10 tests and get them to pass I get a badge. If I cover 100 lines of code with passing tests I get a star. Maybe it could be reputation points like StackOverflow. Design a fully tested class and you get 10 points. Find a way to refactor out 10 lines of code and you get 5 points.

These ideas are based on the details of the code, I think there is also an opportunity for gamifying productivity. If you work in the same class for 30 minutes, you get a medal. If you complete 4 uninterrupted pomodoro sessions within a day, you get a "Way to go" message you can post to Twitter or Facebook.

How about a way to unlock new features as you learn? Gating progress in a game until the user has shown the ability to complete certain tasks is a staple of games. If you are bringing on a new person to the team, they may not have knowledge of the product or the procedures that your team follows. You are probably going to limit what areas they touch in the system until they get up to speed. You are likely not going to throw them into the most complex part of the system on day 1. So I would assume most places have a gating system in place already, just probably not in a formal, defined way. Why not find a way to turn that into a game?

Lets say that your project is very well tested and you want to get the new developer up to speed, but you don't want to give them access to everything immediately. How about giving them the project without the tests. Have them look at a simple, small section of the system, and have them write tests until they have covered that section with passing tests. As they complete a section, move them on to a more complicated part of the system doing the same thing. That new dev would get a good understanding of the system as they worked through creating the new tests. Your team may also find some issues in the code as the new member find spots that they have difficulty with. Or you may find areas that the new member needs assistance with in getting up to the speed with the rest of the team. Turning the on-boarding process into a game will likely engage that new employee better than having them stare at their screen for a few weeks before you let them touch code.

What other ideas would be good to gamify coding and testing? Are there any tools that do any of the ideas listed above that I don't know about?

Comments

Popular posts from this blog

Converting a Large AngularJS Application to TypeScript Part 1

I work on a project that uses AngularJS heavily. Recently we wondered if using a preprocesser like CoffeeScript or TypeScript for our JavaScript would be beneficial. If our team is going to switch languages, we would need to be able to convert existing code over without much pain and we would have to find enough value in switching that it would be worth the conversion. I had read an article that stated that because TypeScript is a SuperSet of JavaScript, you could convert a plain JavaScript file to TypeScript by changing the extension to .ts and not much else would need to change. I wanted to test out this claim, so I took a file that I was familiar with, an Angular Controller, and tried to convert it to TypeScript to see how much effort it would take and then try to figure out where we would benefit from using TypeScript. This is what the controller JavaScript file looked like to start out with: ( function () { 'use strict' ; angular .module( 'app'

Interns: Taking off the training wheels

My intern team has been working for several weeks now on our new website. We have already completed one deployment to production and are finalizing our second one. We started with a plan to release often adding small bits of functionality as we go and so far that plan has been working really well. We already feel like we have accomplished a lot because we have completed many of our project's requirements and should easily be able to complete the rest giving us time to do even more than just the original requirements. One of the things I have had some difficulty balancing has been how much to lead the interns and how much to let them figure out on their own. In deciding what our team process should be and how we should allocate our time, I think it was important for me to do more leading. I saw some deficiencies in how we were currently working and brought up some ideas for how we could address them. We had moved into spending all our time just working through stories and did not

My idea for Hearthstone to add more deck slots

Recently someone asked the Blizzard developers for more slots for decks in the game Hearthstone. The response was that they are talking about it and looking into it, but no decision has been made yet. One of the concerns over adding deck slots is that it could complicate the UI for Hearthstone and make it more difficult for new players to understand. I have what I think would be a good solution to add more deck slots without increasing the learning curve for the game much if at all. First I would take a look at the current selection screen for starting to play a game. It defaults to showing the decks that are custom built by the player if they have any custom decks, and there is an option to page over to the basic decks. This basic deck screen is perfect for how I would change this process. Instead of having 2 pages of decks, 1 for basic and 1 for custom, you would just see the select a Hero screen. Then once you selected the Hero you wanted, you would see all of the decks that