Pair programming is a hot topic these days — everyone knows it leads to better code — but it’s also one of the most difficult things to do. At Makers Academy, where I learned to code, we only did pair programming , so here’s my two cents worth of advice for being a great pair partner.

For newbies to pairing, the most important is to understand the driver/navigator roles. The driver is the one typing the code, the navigator sits back and researches, proofreads, and maintains a global view of the code and the project’s direction.

1. Recognise that pairing is hard
Pairing is an intense relationship, summoning all your powers of ingenuity, communication, humour, and code. If you find it hard, or even just tiring, it’s because it is hard and tiring sometimes. But you can also make it easy with the right person and the right set of practices.

2. Listen more than you speak
I guarantee if your focus is on listening more than you speak, the result will probably be a 50/50 split. Most of us love to focus on our own ideas without really being present to the person next to us.

Listen actively: listening doesn’t mean you’re silent but inattentive. It’s a very powerful act requiring your full attention and presence to take in what the other person is giving you.

Exception: if you are very quiet generally, you may in fact need try to speak more than you listen to get that 50/50 split.

3. Ask questions — don’t command
Bad: ‘Assign that variable to equal “potato”.’
Good: ‘What do you think that variable should point to?’

Questions make your pair think and open a dialogue. Telling them the answer just makes you look superior.

4. Switch roles every 25 minutes
This is probably the most important skill! It’s easy to be a keyboard hog, and it becomes really annoying for your pair to have to request keyboard control. Every 25 minutes is a fair split, and it will keep you from getting in a rut.

5. Take regular breaks
And make them good breaks! Play music, meditate, go into the garden…do NOT code without your partner in the breaks! You’re in this together.

5. Give feedback
Ouch. This is hard. But so worth it. Full disclosure: I’m bad at giving helpful and kind feedback, so I’m not going to offer much advice here. But a good one to start with is 1) what went well 2) what can we improve for next time

6. Don’t pair 100% of the time
Like I said, pairing is intense. You’ll need some alone time to code so make sure you get that too.

7. Don’t interrupt
Interrupting == you weren’t listening. I don’t mean the kind of interruption that takes the other person’s idea and enthusiastically expands on it. I mean the kind of interruption that abruptly changes the topic of conversation. This says that you don’t value your pair’s opinion.

8. Say yes
In the time it takes to discuss whether it’s worth trying something, you can often just do it. Saying yes creates a positive atmosphere where your pair is respected. Arguing about it is just, well, arguing.

9. Be mindful of your body language
Is your back to your partner? Is your computer screen angled away? Do you never look at them? You want to create an atmosphere of inclusion so your pair feels respected and welcome to comment.
​​


10. Give high fives
Just completed a mother of a mission? High five! You go through the lows together — make sure to celebrate the highs.

Have some more suggestions for great pairing? Comment or sent a tweet my way!

​Keep your eyes peeled for a post on remote pairing!

And want a little laugh? https://www.youtube.com/watch?v=dYBjVTMUQY0

10/7/2017

Pair programming is recognised as a way of writing great code, but can remote teams do it?

Absolutely! I did my entire Makers Academy course remotely and I paired remotely everyday. It definitely has some benefits over in-person pairing and I think it’s a great way of working.

If you haven’t already, read my article 10 Tips for Great Pair Programming — this post assumes you’ve read it. The most important tips from that article? Swap driver/navigator roles every 25 minutes and listen more than you talk.

The main difference with pairing remotely is that you have to be a bit more intentional about your communication. Here are my 5 tips for communicating well virtually.

1. Use your camera
The major drawback of pairing is that you lose body language communication. You can in large part make up for this by turning on your camera and making sure your pair’s camera is on. I like to use Zoom for pairing as the screenshare/camera work well together.

2. Check in with your pair
Before you start working, make sure to ask your pair how they’re doing — the same way you would in person. Maybe even have a virtual cup of coffee together in the morning!

3. Take good breaks
This is one of the major benefits of working remotely — you’re in your own space so on your breaks you can easily meditate/pop outside to the garden/do your laundry.

4. Create a dummy branch
Swapping driver/navigator roles regularly is critical for healthy pairing. If you’re concerned about pushing experimental code to git, create a dummy branch that you can push to in order to swap your possibly embarrassingly rudimentary code — then you can start using the real branch when you have passing tests.

5. Virtual high fives
Totally a thing. The key is to slap the camera (almost) with one hand and slap your thigh with the other to get the sound. If you want a slightly ironic high five, you can facepalm at the same time.

Re-“Makering” Your Life

7/14/2017

I had a great chat yesterday with the new Makers Academy remote cohort, discussing feeling inadequate, strategies for learning, how soon to send a CV to employers, and myriad other topics. This morning I found myself reflecting on how I used Makers not just to learn to code but to reset my life.

A bit of background: my previous job was as a professional violinist. I was doing a lot of international touring, working as a freelancer. This was stressful because of the constant travel (between November 2016 — January 2017 I was in ten countries on 3 continents), the uncertainty of a freelance income, and the inability to plan downtime.

The intense experience of Makers forced me to look at my life and understand where I received sustenance; to make sure I was getting enough sleep; to develop patterns that made me a good coder but also a joyful human being. So I decided to seize the opportunity to use my Makers experience to set healthier boundaries between my work and personal life. ​

Here are six things I did that helped transform my life:

1. Resist peer pressure to overwork
I remember vividly coming back from a five-minute pomodoro break and asking my pair how his break had been. He said, ‘Oh it wasn’t much of a break — I spent the time researching.’ I’d gone into the garden and smelled some flowers. Guess which of us was better prepared​ for work? As the course went on, my cohort challenged each other to take healthier breaks: play music, take photos of bees, read Stack Overflow’s programmer jokes page.​

2. Ask yourself what’s the best thing you can do for your learning
For me on the course, if it was during lunch or after 6pm, the answers included:

  • Go to the gym
  • Take a walk
  • Call my friends/family
  • Go to the pub
  • Read some fluffy fiction
  • Colouring-in​

Only on two days during the course, both at the final project, did I do any code in the evening. And to be honest, one of those nights I was just sitting watching my teammate code because I wanted to be social.

And one memorable morning my pair and I were too knackered to do the diagram workshop, so we did a hip-hop Bollywood dance workout instead.

The answer to this question will be unique for everyone but it’s really important to ask it and understand that the answer may very well not be ‘write more code’!

3. Don’t compare yourself
Rather than looking at what the other people in the course have done, ask yourself these two crucial questions:

  • Am I a better developer than I was yesterday?
  • Am I having fun?

If the answer to those questions is ‘yes’, then you are doing just fine.

A great way of being able to figure out the answer to those questions is to use the pomodoro technique and at the end of each pomo, write down what you did. You will be surprised and happy to realise how much you’ve learned, even as you’re struggling and frustrated.

4. Ask your coach or Dana if you’re worried about your progress
One of the most difficult things for me, especially at the beginning of the course, was not having much awareness about what I didn’t know and how I was progressing. Was I learning enough, not enough, pushing myself too hard? It’s impossible to know this as a newbie coder, but as adult beginners we are keenly aware of a vast skills chasm.

So talk to your coach if you want to find out how you’re doing — but be warned, have specific ideas (i.e., I struggle with ‘attr_readers’ and ‘instantiating objects’). The act of having that conversation with yourself is in fact a really valuable part of learning, reducing the terror from ‘Oh my god, I don’t know anything’ to ‘Here are three specific things I don’t know and can I get some help learning them’.

If you’ve done that and you’re still full of anxiety, talk to Dana. She will help — and not by patting you on the head and saying you’re great but actually by helping you discover these thoughts that are tearing you down and realising that the reality is a lot kinder.

5. Be kind to yourself
I can’t say enough how brave you are for doing the Makers course. Taking three months off work is difficult! You will struggle. You will be frustrated. But that’s such a good thing — it means you are being stretched, that you’re growing. Lots of people talk about making big changes in their lives, but you’ve actually had the courage to go for it. Remember that, and be proud of yourself when the going gets rough.

6. Ask yourself what’s the bravest thing you can do in that moment
Maybe it’s meditating instead of smoking. Maybe it’s shutting off the computer and reaching out to a friend. Maybe it’s admitting your vulnerability. Maybe it’s asking the ‘dumb’ question that’s actually on everybody’s minds. Maybe it is writing more code! The answer will look different for everyone, and will change frequently. And if you’re really comfortable with your pair, you can ask them this question too.

And if you feel like sharing, tweet me at @FiddlersCode with #BraveMakers and let’s all celebrate these moments!

A friendlier type of nuking

Our practice tech test for the past two days at Makers Academy was? Refactoring some hideous legacy code. See that method above? That SINGLE method that is over 40 lines long and bursting with nested if/else conditionals?

Yep, that one. So we had to refactor it AND THEN add an additional item type.

(Ever heard of a squint test? Screw up your eyes and just look at the layout — see all those arrows? A bad sign.)

So this is what I did:

1. Wrote some tests
There was one pre-existing test, which was pretty meaningless anyway. I had no idea what all this code was meant to do, nor did I have any intention of losing myself in a forest of nested conditionals. I read the specs and wrote tests to pass the specs. As luck would have it, the hideous nests actually did work, so eventually I had a full suite of tests and a good knowledge of what the program was designed to do.

2. Deleted everything in the update_quality method
Nuking is not always the best method for refactoring, but that code was just irritating me. Luckily I had tests to guide me so I wasn’t too worried about writing the code.


3. Googled ‘ways to refactor nested conditionals’
Came up with references to duck typing

4. Took a nap in the sunshine
Seriously. I was tired at this point and knew I had to have a clear grasp of the design before moving forward. So a nap sounded good.

5. Read POODR’s chapter on duck typing
A lot. Also looked into inheritance but that seemed possibly messy.

A big issue at this particular moment was the instruction that I wasn’t allowed to change the item class. Duck typing was a great solution, but it would require changing the item class, which would apparently upset a goblin.

​​6. Damn the goblin, I’m writing well-designed code
Once I made that decision, it was full steam ahead with TDD’d duck typing. I ran into some snafus about how I was storing and calling objects, but after a few hours had sorted those out and it was really simple. I ended up with several small classes and super-extensible code. I added the new feature on in about half an hour, complete with full testing.

7. Inheritance!
At this point I felt I’d done enough original work to watch Sandi Metz’s video on the Gilded Rose. In it, she mentioned that inheritance isn’t always bad, as long as all of the subclasses share the behaviour of the superclass. So I thought, hey why not DRY this out a bit more and create a Product class which will contain the instantiation behaviour common to all the objects? Easy!

8. Satisfying the goblin
On my way back from the gym later that day, I had an epiphany: I could in fact satisfy the absurd goblin by making the original Item class the superclass and having all the other classes inherit their behaviour! It meant a bit of name-switching (my product and item classes switched names, along with all attendant methods), and the one downside is I couldn’t work out how to throw the errors upon instantiation without changing the item class, so the goblin’s code has slightly less functionality. Still, I’m pretty damn happy with this duck typed, inherited code.

You can check out the full code on my GitHub repo. It should be pretty self-explanatory!

Master branch (with errors for instantiating with disallowed max/min quality)
Item-class branch (item class totally unchanged from original repo)

Don’t hesitate to get in touch if you have more ideas on duck typing, inheritance, or just want to chat code. I’m friendly and I like meeting people!

The refactored method

When I found out I was going to be pairing with “Captain Code”, I was curious to work with this snazzy computer program that would somehow mysteriously assist me in my programming learning. I envisioned a chirpy little bot that would come out with such pearls of wisdom as, “Ahoy there, are you sure your constant is defined, matey?”

Obligatory photo of Jack Sparrow. Entirely unrelated to Captain Code, who is much more intelligent.

Needless to say, Captain Code is a loveable pirate captain who retired from the high seas when his wooden leg was destroyed in a cricket match. He has a keen eye for detail, drinks just enough rum to be constantly jolly, and was never a very good pirate because he chatted too much to his captives, became their friends, and let them off for absurdly low ransoms. His profit margins were crap so he reinvented himself as a programming coach and joined a ukulele band.

Sing to the Beatles “All you need is love”

Turns out Captain Code is a polite way of saying, “You’re on your own today.”

So after 2.5 weeks of intense pair programming, today I became a lone wolf coder.

To be honest, I was really looking forward to today. I have found the pairing process rather exhausting, being in such close contact with another human being for so long. And while I’ve certainly grown better at it, and worked out when to take breaks and how to communicate to make the experience successful, I was delighted to have the chance to work untrammelled by a pair’s lunch schedule.


So here’s my run-down of a day of solo coding.

What went well:
1. My own schedule! I took my lunch break when I wanted it!
2. Pomodoros — I was really disciplined about 25 minutes on and 5 minutes off, and that timer really helped make my day productive.
3. Error debugging — I hit a stride today in debugging errors/fixing failing rspec tests. 
4. Code production — I finished the Single Responsibility principle, so am very happy that I’ve come this far.


What didn’t go so well:
1. I was lonely. I figured working on my own would be a walk in the park, after many years of practising violin 4–5 hours a day alone. Turns out I like talking to people, and this was the first day on the remote course I felt like I wasn’t getting enough human contact. This loneliness had a cascading effect:
2. I was grumpy because I was lonely.
3. I struggled to take breaks, because I was already grumpy so kind of figured I might as well keep on being a grump, and my grumpiness wouldn’t affect a pair. (I took 5 minutes because of my pomodoros, but really would have benefitted from longer breaks as well.)
4. Accountability. I didn’t slack off, but I really wanted to take an hour-long nap or watch TV and finish coding in the evening. This isn’t an option when you’re pairing, so the temptation never comes up. So I wasted mental energy combating this desire.
5. Not having a pair means you miss obvious things! I had to ring up my coach because of an absurdly stuck test and he spotted immediately that “Borg: 3 LS” and “Borg: 3LS” weren’t the same — a pair would have spotted it.

A borg, debatably.

I had wondered if the pair process was the best way of learning — it can be unbelievably frustrating to be at a different stage (whether higher or lower) than your partner — but after today, I can definitely say that I’d rather the frustrations and trials of pairing than doing much more solo coding.

So cheers to my cohort for being full of awesome pair partners!