Code Dojos

Learning continuously is important in our rapidly changing business to avoid being outlived by the latest technology or style. I guess most of our readers come to clean-cpp.org because they are interested to learn something new about C++ they did not know before, or they like the good feeling to read that someone else thinks what they are already doing is right. Besides reading blogs and books, there are a few things one can do to stay up to speed:

  • Write a blog on your own. You would be surprised what you need to learn in order to write an article.
  • Visit talks or watch them on Youtube or other video platforms.
  • Join an open source community and start working on a project you like.
  • Learn a new programming language.
  • Browse through someone else’s code.
  • Talk to someone who is a better programmer than you are.

A code dojo is a relatively new practice of learning from another, and it combines some of the best features of above list. Basically, it is an informal gathering of programmers. Together, they write code to solve a fun task. They talk with each other, drink beer, and eat pizza. It is almost like a night out, but with more code.

Prerequisites

In order to organize a code dojo, you need access to the following resources:

  • You need a bunch of interested programmers. Ten is a good number. If you have significantly more, you should consider splitting the group. Less than ten people is not a problem at all, but having a dojo with you as a sole member seems a bit sad.
  • You need a room to fit everyone in. If you need to push, then it is probably too small.
  • Find a computer with an installed development environment, i.e., compiler, IDE, Angry Birds, etc. The computer must provide two video outputs. Connect a display to one of them. It is meant for the active programmers, as is the keyboard and mouse which come with the computer.
  • Get yourself a digital projector and connect it to the computer’s second output. Mirror the desktop to both display and projector to allow the audience to follow what is happening.
  • Pizza and beverages are very important for a successful dojo. Get the phone number of a decent pizza delivery service. This may be the hardest requirement to fulfil, but you can replace good pizza with mediocre pizza and people will still love you for it. You might ask your company for sponsoring.

Code dojo rules

I will now apply  std::move to one of my coworker Philip’s brilliant ideas and pretend it is my own. In short, attendees of a code dojo are subject to the following rules:

Welcome to Code Dojo. The first rule of Code Dojo is: you do talk about Code Dojo. The second rule of Code Dojo is: you DO talk about Code Dojo! Third rule of Code Dojo: someone yells “stop”, writes code before a breaking test, or forgets to refactor ugly code, the show is over. Fourth rule: only two guys to a keyboard. Fifth rule: one pair programming at a time, fellas. Sixth rule: Stay fully dressed at all times. Seventh rule: A pair programs only a few minutes. And the eighth and final rule: if this is your first time at Code Dojo, you have to code.

 

The real deal

Okay, so what is a code dojo? Programmers attend a code dojo to practice their skills in a sacred environment. They learn from each other by watching fellow programmers code, correcting their mistakes, and having one’s own mistakes corrected. They see how other professionals refactor code, how they write tests, how they get the most out of the IDE. To get the most out of a dojo, all programmers should follow a few basic rules:

  • At the beginning of each dojo, the participants settle for a task they want to solve cooperatively. Since the dojo is also a place of enjoyment, the task should be fun and not too difficult. It should be possible to get started right away. It is perfectly fine to solve the same task multiple times. Remember that martial arts specialists practice katas over and over again. We will collect a few appropriate tasks and present them here in the near future.
  • At any time, two attendees pair program. One attendee sits at the keyboard; she shall be called the pilot. Her pair programming partner is called the co-pilot.
  • The pilot works test-driven to solve the task at hand. She explains what she is doing and why.
  • The co-pilot supports the pilot by reminding her to write a breaking test first before writing production code and points out things she may have overlooked.
  • After a couple of minutes (approximately seven), the pair is partly exchanged. The former pilot returns to the audience. The former co-pilot is promoted to pilot and assumes her place at the keyboard. A new co-pilot volunteers from the audience. You should not be too strict about the time. Make the exchange when a new breaking unit test has been written or a formerly failing unit test finally passes.
  • The programmers in the audience try to be reasonably quiet. They watch the code as it is being crafted. It is encouraged to ask questions, e.g., if language constructs, library features, or design patterns are unknown. After the dojo, all attendees should be able to reproduce the solution for themselves.
  • When you ask ten programmers to provide a working design for a feature, you will get ten different designs. Hold back criticism until you are near the keyboard.
  • It is explicitly allowed to refactor code. Code evolves, even more so if it goes through many hands. Explain your reasons for the refactoring and how the code benefits from it. Avoid unnecessary “refactorings” such as formatting braces “the right way”.
  • Everybody should use the same programming tool. An IDE such as Eclipse or Visual Studio works best and it simplifies the build process. File templates help to make the development feel more fluid.
  • Programmers participate in a dojo because they want to improve their skills. For a rookie programmer to enter the dojo takes courage and deserves your respect. Respect your colleagues at all times, even if they make (what you consider) stupid mistakes or ask (really) silly questions.

If everyone follows these rules (I guess the odd exception is alright), the code dojo will be enjoyable for everyone. The first time I organized a code dojo I was surprised how different the code came out from what I envisioned earlier, and I have to admit: all for the better…

So finally, have a go and organize your very own code dojo. Take my rules as suggestions and see what works best for you. Please tell me about your findings in the comments.

3 Replies to “Code Dojos”

  1. Amazing what people come up with. 🙂

    I guess if you work at a place where you feel (the majority of) your co-workers would enjoy this, you can feel blessed. 🙂

Leave a Reply to 7 Common Mistakes Companies Make With Google AdWords Cancel reply

Your email address will not be published. Required fields are marked *