Collaborative programming

Intro
This is a guide with a set of recommendations for collaborative programming sessions and learnings that addresses all engineers, contributors, and volunteers who write code or are learning how to code and are interested in working more collaboratively. As anyone that is contributing to the work of the Wikimedia Foundation it can be inspiring is nice to go back to our values regularly and think: what does this mean for the way we work together on a daily basis? Thinking about more collaborative ways to write code this one stands out:

We are in this together. Collaboration is not always easy. Sometimes we struggle. Working together is hard, but it’s worth it. We do it because it makes us stronger. We solve problems better together. For it to work well, each of us needs to be honest, accountable, and transparent to one another.

Definitely one has to experience a good pair programming session to get convinced of doing it repeatedly. It's actually a little bit hard to get into because you might feel vulnerable and exposed to everyone's observation, but soon after there is a point where that openness to show the way you work allows you to build trust within the team because we realise that nobody knows it all and everyone has to look things up and think stuff through properly. The huge advantage of a pairing session is that "we are in this together" and the others can help you think and research. What if getting into a more collaborative way to write code actually solves problems in a way that addresses the lack of diversity and leads to less bug-prone code?

Terminology
Isn't that all the same: Pair Programming, Mob Programming, and Collaborative Programming? Yes, it's pretty much all the same while Mob Programming allows more joiners that contribute to a session. We decided to use Collaborative Programming as a more general term that includes all of the other ones.

Benefits

 * it can lead to more diverse teams and groups where people really feel welcome, where knowledge is being actively shared and where developers want to stay
 * a bigger variety of opinions in the process of code creation leads to a wider range of problems being solved
 * improvement of developer experience
 * although studies were small team velocities seem to have gone up
 * quality of code can be improved
 * sense of belonging in teams
 * improved knowledge sharing

While some of us have experienced collaborative programming as a beneficial approach there are actually various studies backing this:

How could one classic way of Collaborative Programming work?

 * 1) There are no rules, there is only a set of recommendations.
 * 2) It’s not a requirement to join the session that one knows the codebase or a specific language because you will be working as a team (a group of two to five people) who meets for a call.
 * 3) One person is always leading the session for a while and sharing their screen and is implementing one small step of a problem that the group wants to solve together, let's call that person the writer.
 * 4) One other team member is the "researcher" that asks curious questions and suggests things to try and implement that could be one step of a solution.
 * 5) If you have a nice pair programming tool setup that’s great, so different people can be active, otherwise the one that shows their code, the writer, can be following the instructions of the researcher
 * 6) What's most important is that the researcher role is being handed over every 10-15 mins.
 * 7) Being the writer make sure you describe what you are trying to do while you write and as an observer make sure you stay engaged and ask questions about things you are unsure about.
 * 8) At any point, people can ask questions and ask for help from the team for looks up things in the docs ask for ideas about what to do next.
 * 9) As the researcher, if there are people in the team that have less experience than you make sure you keep them included by asking little questions: "What should we do next?" or "How can we solve this?"
 * 10) If all of this seems too rigid, skip the recommendations, and do your own thing: meet and show each other your code and talk through it, what matters is that you collaborate in the process.

How to communicate during a session?
As opposed to a workshop the goal of a pairing session is not to present a solution or a technology to your team, but rather to get to a solution together. Therefore specific communication rules apply:
 * refrain from saying things like "obviously" or "simply", because what you are implementing seems simple to you, but rather approach your teammates with empathy, and assume that you have different knowledge of different parts of the codebase
 * when somebody has a question we pause and answer as good as we possibly can
 * rather overcommunicate and talk the others through what you are trying to do
 * when you realise the other one did a mistake, do not interrupt but bring up your concerns when they have finished their point
 * use always only non-judgemental language, saying "you did it wrong" might not be the best way to make your pairs aware of a mistake, rather say: "wouldn't it be better to..."

What's a good way to initiate collaborative programming sessions?
They can be either ad-hoc or once you enjoy them be scheduled sessions a few times a week to make sure you reserved time for it. Some teams do that and call them Collab sessions for example the Platform Engineering Team and the Community Tech Team. If you would be interested in having sessions with your teammates there are several options:
 * 1) Don't hesitate to ask them directly
 * 2) Ask your Engineering Manager to plan a session for you with someone from another team that's up for it
 * 3) Some teams have Code Jams, something like an internal hackathon, feel free to suggest one for your team.
 * 4) You have a big task that you are handing over to another developer to be reviewed, that can be a great moment to offer a session to give them a rough overview of files changed and how they belong together.
 * 5) You are working on a part of the codebase that you really enjoy working with and would love to share your knowledge. Publicly announce that you are open to collaboration!  ( Note: This is different than giving a workshop.)

Great moments to start can be:

 * your team found a small enough bug that you think could be fixed in an hour or two
 * you are working on a feature that has a lot of impact and affects lots of people and want to make sure you do the right thing
 * you feel stuck for more than a day and want to talk through your solution with someone
 * you don't feel ready to design the solution of a ticket and would like some inspiration from your teammates
 * you are working on something and feel like that other teams could have some really valuable knowledge that, if they are willing to share, would help you proceed/begin
 * you are completely sure about how to implement a ticket but it would be interesting to see if others agree

How to facilitate a collaborative programming session?

 * 1) Ask around for some developers that are curious about it.
 * 2) Find a non-urgent bug that you think could be solved in an hour or two.
 * 3) Setup a call, with people in similar time zones. (if timezones are too spread out provide multiple sessions for your team)
 * 4) All jump into the call and ask tons of curious questions

A change of mindset about the way we work together can help:
The point of having a collaborative session is not that you will all be more effective together, the point is to collaborate and learn from each other and get more conscious of anti-patterns and with a bit of practise you will actually write better code.

"Try treating programming as a learning activity that throws off running code as a byproduct" ~@KentBeck


 * 1) Ask around for some developers that are curious.
 * 2) Find a non-urgent bug that you think could be solved in an hour or two.
 * 3) Setup a call, with people in similar time zones. (if timezones are too spread out provide multiple sessions for your team)
 * 4) All jump into the call and ask tons of curious questions.

Recommended Tools

 * one tool that has a lot of potential is https://duckly.com/ because it's working with different editors.
 * Extension for Intellij https://plugins.jetbrains.com/plugin/14225-codetogether
 * Extension for Visual Studio Code https://docs.microsoft.com/en-us/visualstudio/liveshare/use/vscode
 * just sharing your screen with an editor open can be completely fine, as long as you reassing the researcher
 * timer for sessions http://mobster.cc/ to help ensure that the researcher is randomly being reassigned