Software developers have a reputation for being loners, but they don’t always code by themselves. Pair programming is used by many programmers to
Pair programming intuitively sounds like it would be inefficient: after all, the two developers could instead be working on different projects simultaneously. But on top of catching more bugs, two people working together often display more creativity as well. You might think of an idea based on something your buddy said that wouldn’t have come to you alone.
If you have a friend handy, work through this tutorial together to gain real pair programming experience. If you’re alone, fire up two browsers (or use incognito mode) to sign into two Repl.it accounts simultaneously.
Imagine that you are a developer who has come across the previous tutorial on plotting and graphing. You want to adapt the graphs shown a bit, but you haven’t used Python much, so you decide to ask your friend for help.
In this scenario, you are “@Lean3Viljoen94” and the friend that you’re asking for help is “@GarethDwyer1”.
Start by forking the data science repl and making sure that you can run it.
Now from your own fork, press the
share button, as shown below.
Copy the invite link, and note that this is different from the normal link to your repl. If you copy the link from your URL bar, you can give people read access to your repl, but by copying the invite link you’ll give them write access.
If you knew your friend’s Repl.it username or the email associated with the Repl.it account, you could instead use the
Invite box at the top. Share the link with your friend and wait for them to join.
As soon as they do, you will see that a chat box pops up in the bottom right corner. Their profile picture or letter will be at the top of the chat box, so you can always know who is currently active.
Remember, you forked the repl in a previous step, so you are the owner of this fork and the “host” of this multiplayer session. If you invite multiple people and then leave, they can continue collaborating without you, but they won’t be able to rejoin if the host is no longer in the session.
You can use the team chat feature, as shown below.
In the previous tutorial, we looked at GDP by country. Imagine that you are now interested in how this is broken down by continent too. You still want to plot each country as a separate data point, but you want them in different colours, one for each continent. You’re not sure how to do this, so you ask for help.
You can see a typing indicator to help decide if you should wait around for a reply or go make coffee.
Your friend tells you about the
hue argument and points out that you already have this data in the
continent column in your data frame. You add
hue="continent" to the graph and re-run it, but it doesn’t quite work out how you expect.
Your friend suggests maybe a scatter plot without the correlation line might look better, but when you try that it results in an error. The error message is hidden by the chat box, so you move it to the other side of the screen.
This is getting a bit more complicated than you bargained for. Sometimes showing is easier than telling, so your friend starts editing the code directly instead of telling you how to do so using chat. The code
sns.scatterplot( "gdpPercap", "lifeExp", df, hue="continent" ).set_axis_labels("GDP per capita", "Life expectancy")
ax = sns.scatterplot(` "gdpPercap", "lifeExp", df, hue="continent" ) ax.set(xlabel="GDP per capita", ylabel="Life expectancy")
If you followed along, you’ll already have your own version of the repl to extend. If not, start from ours. Fork it from the embed below.
Getting help on a single file in a program is only one use for multiplayer, but there are many scenarios where it can be useful to see your teammates’ changes in real time. For example, if you’re a back-end developer you could work closely with a front-end developer, ironing out any issues with data communication between the back- and front-end in real time, instead of waiting for multiple iterations of several days.
That brings us to the end of part 1 of this series and you should now be familiar with all of the basic features of Repl.it.
In part 2, we’ll cover more advanced features, such as running projects from GitHub, storing secrets securely, and productivity hacks.