Pair Programming Exercises¶
Week 1 (September 2nd - September 7th)
Exercise 1¶
The purpose of this exercise is to help you ease into the course flow for the
semester. You will learn where to find the homework assignments and how to
correctly set up your git
repo for this course.
Tasks¶
- Do problem #2 on Homework 1 https://harvard-iacs.github.io/2021-CS107/category/homework.html
Exercise 2¶
By the end of this exercise, you will be ready to use tmate
for pair
programming.
Tasks¶
- Create a new directory called
pair_programming/PP1
in your personalgit
repository Install
tmate
(https://tmate.io/) on your system. If you use Ubuntu, you could accomplish this withsudo apt-get install tmate
Alternatively, you could install
docker
and usedocker pull cs107sysdev/ubuntu
to pull the Ubuntu image we have prepared for you. For installing
docker
see these references:- Mac: https://docs.docker.com/desktop/mac/install/
- Windows: https://docs.docker.com/desktop/windows/install/ (requires WSL 2, see System Requirements)
- Linux: Use your repository package manager. E.g. for Ubuntu
https://phoenixnap.com/kb/install-docker-on-ubuntu-20-04. Alternatively,
you can install podman which is a rootless alternative to docker
(https://podman.io/)
The additional benefit of using a
docker
image is that the working environment that you share with your pair-programming mates is isolated from your personal system. You can run the docker image by using
this helper script.
You can copy this script into your~/bin
directory and then run the following (assuming you are inside your personal GitHub repository andrun_cs107_docker.sh
is in your$PATH
variable):
run_cs107_docker.sh pair_programming/PP1
If the
run_cs107_docker.sh
is not in your$PATH
or the above fails, you can just copy the script in your current directory and run:bash run_cs107_docker.sh pair_programming/PP1
This will launch the Ubuntu container and drop you inside your
PP1
directory. You can then simply launchtmate
and share the session with your mates. They will only have access to the container but not your personal computer.
Exercise 3¶
All work on PP exercises should be committed to your
master
ormain
branch. If you have begun to work on HW1, please switch to theHW1-dev
branch and commit that work on this branch before checking outmaster
ormain
and continuing with this exercise. Feel free to ask your TF if you have any issues. The 'Example Homework Workflow' section on the course flow page provides the details as well.
You will be assigned a random group and sent to a breakout room. Please wait for
your TF. This exercise will be performed in the PP1
directory that you just
created.
By the end of this exercise, you will have gone through your first pair
programming workflow! We will check that you successfully pushed the README.md
file to your repo.
Tasks¶
- Start a
tmate
session inside yourPP1
directory (either directly or via docker) and invite your PP team members by sharing the link to your session, eitherssh
or the web link (you can share the read-only link for this session). Create a
README.md
file. Choose an editor of your choice, examples are:nano
(easy)pico
(easy)vim
(advanced but recommended)neovim
(behaves the same asvim
but code has been rewritten from scratch)emacs
(advanced)ne
(easy, comes with a TUI, https://ne.di.unimi.it/)tilde
(easy, also with a TUI, https://os.ghalkes.nl/tilde/) All these editors are available in the cs107sysdev docker image. You can put anything you want inside yourREADME.md
file. A good choice would be something like the example below.
# Pair-Programming Week 1 Hello [`tmate`](https://tmate.io/)
You may do this one after the others, while your team mates watch what you are doing in their read-only session.
- Inside the terminal, from the command line, play around with some of the Linux
commands you started to learn in lecture. At the very least, try to use
ls
and some of its options. - Now commit the
README.md
file you have just created on yourmaster
ormain
branch. It should be on this pathpair_programming/PP1/README.md
. When you are done, you can push your contribution withgit push
and verify that everything is fine by checking on your GitHub account.
A few comments¶
- The tasks above are not necessarily connected. The main goal is to help you get familiar with the correct workflow.
- For example, you can choose to share your code with your partners or not for this session. In the future, you will be required to share code.
- You can open the editor by passing a filename as an argument. For example,
nano README.md
would opennano
with an emptyREADME.md
file. You can then edit the file to your liking and save the contents by pressingCtrl-O
and hittingEnter
to confirm that you want to save. You can then exitnano
by pressingCtrl-X
. vim
is a modal editor which means you can not start typing text right away. If you want to play withvim
, these are the steps:- Open a new file:
vim README.md
- Press
i
, this will enterINSERT
mode - You can now enter text as you like
- To exit
INSERT
mode and enterNORMAL
mode, press theESC
key - To save your work and exit
vim
at the same time, press:wq
followed byEnter
. This will write (w
) and then quit (q
).
- Open a new file: