About the Blog

Its about anything and everything. I, Steven Hancock started this blog for a variety of reasons. I want to start documenting my life and sharing that with others, whether that's family, friends, strangers or my future self. I also want to start sharing my experiences with others in hopes that others can learn from me. Perhaps I can help someone set up an Ubuntu server, write a Django Web Application, or setup a Phonegap Mobile App.

That's it. I'm hear to share. Nothing more, nothing less. I will be covering a wide variety of topics so feel free to browse for the blog entries that interest you most.

Do It With a Partner!

June 13, 2013

How can programmers write better code?

How can programmers reduce bugs?

How can programmers improve their skills?

Pair programming.

Pair programming doubles a programmer’s most useful asset, their brain. In its essence pair programming is two programmers working on the same code together. There are many possibilities as to how they work on that code, they could be sharing a single monitor, sharing a screen with a remote partner, or simply just working on the same code. However, the programmers must be examining the same code block, communicating freely through voice (as opposed to text-based) all in real time. Often there is a driver, the person writing the code, and a navigator, the person planning what to code.

The pros

  • Two heads are better than one
  • Instant code review
  • If one person loses focus, the other can help re-focus
  • Skills can transfer from one programmer to another
  • Two programmers have an in depth knowledge of the code

The cons

  • One person getting off track can lead to another
  • Not all tasks are complicated enough to benefit from two programmers
  • Requires two programmers who are willing to communicate
    • This is not always trivial, there may not be anyone available, or perhaps the programmers communication skills are lacking
  • Freeloader affect
    • If there is a large difference between the programmers’ knowledge and work ethic, one programmer may become feel discouraged

My experience

I haven’t experienced a lot of pair programming. Throughout my education and few times during work, I have worked in paired up and done some programming. School offered a variety of opportunities and challenges. Sometimes you were working with someone who had no idea what they were doing and had no motivation to be there. Sometimes I had no idea what I was doing, while my partner was a seasoned pro. There were times where you could pick your partners, other times where your partners were assigned. Having a good partner was important. A good partner is someone eager and willing. They don’t have to be incredibly smart nor do they have to be a great programmer. A great partner for pair programming is someone who contributes and someone who offers a different perspective. Two heads are better than one right? Well the more diverse those two heads are the better. It is always very important for both individuals to have clear objectives for the pair programming session. Both parties should know what they want to accomplish and an estimation for the amount of time that may take. Without a clear goal, sessions can rapidly degrade into a chat about what you did last weekend, or your favorite color, or whatever. Estimating time allows for every party to appropriately schedule for the session. We all live busy lives, and during school especially, we all have different priorities.

Work offered a different experience. I had been working with the same company for the past four years and most of my work was programming by myself with occasional consultation with others. The company decided to hire a summer student whose job it was to work on projects that I had previously worked on and no longer had time to develop. Because of the job’s nature I worked closely with the summer student, mentoring them, and trying to walk them through the existing code. I put aside time where we would pair program together. We stuck to a schedule and took turns driving and navigating. Unfortunately, I took too much control of the sessions. I allowed my partner to set the agenda, but I would often come up with the solution (navigate) as well as write the code (drive). Ultimately we were successful, completing the summer project, however, I feel I could have done a better job pairing up with the summer student. If I would have allowed my counter part to do more driving or navigating he would have learned a lot more. It may have been a slow process at the beginning of the project but towards the end he would have felt comfortable navigating.

What I would like to do

Pair programming should occur all the time. It’s especially useful when a new programmer is brought into a project. The best way to learn the code base is to work with it. New developers should be put immediately in the driver seat. The senior developer can be the navigator and they can go through the code base together. If a new developer has to learn a new system by themselves they are going to make mistakes, they are going to misunderstand things. Pair with an existing programmer, the new developer will be able to ask questions and get feedback in real time.

Pair programming is also a great method when beginning a new project or a starting a complicated block of code. There’s no code base to start with and to build off of. There are a lot of crucial decisions that have to be made, its best to work them out with someone else. Get two minds with different perspectives working together to come up with the best possible solution. It’s better to spend the time at the beginning thinking out processes than after all of the code is written.

Yes, pairing up can be very advantageous when dealing with new code (whether that’s new code to a programmer or new code period) but it’s also great period. Programmers can all too often focus in on themselves. Getting feedback is important for any job. Unfortunately, programmers often don’t get feedback until their application is released. The quicker feedback can be provided, even if its by peers, the better.

The movement

What really got me to into thinking about pair programming was a podcast by The Changelog. Adam Grimm was on the podcast to talk about pair programming, among other things. Adam is the founder of a community that encourages and facilitates pair programming among developers. Pair with me is an intriguing movement. There’s not much to it. Are you open to a spontaneous pair programming session with someone you may not even know? I think it’s a great way to pick up some skills while contributing to the community. I’m going to post the Pair with me badge on my blog and website. Hopefully someone (maybe even you) will be interested in it and get a hold of me (Twitter, Facebook, LinkedIn, or http://www.StevenHancock.ca/contact).