8.2 Working in teams
The daily reality for most developers is that they are collaborating on solutions as part of a team. There are many tools and techniques that can help you to more successfully manage that collaboration, especially when team members are working remotely.
# Pair Programming
Software development requires you to frequently alternate your attention from the broader solution structure to the syntactical details of the current function you are writing. The idea of pair programming, is to divide these roles between two developer working in tandem.
From Wikipedia ...
Pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer or navigator, reviews each line of code as it is typed in. The two programmers switch roles frequently.
While reviewing, the observer also considers the "strategic" direction of the work, coming up with ideas for improvements and likely future problems to address. This is intended to free the driver to focus all of their attention on the "tactical" aspects of completing the current task, using the observer as a safety net and guide.
This can be a tremendously effective technique, but it takes practice to do it well.
Tip
Pair programming is sometimes used in technical interviews.
# Read this guide
The article On Pair Programming published at martinFowler.com provides an excellent primer on how to do pair programming well. Take some time, right now, to read this article and discuss it with your partner.
# Pull requests and code-review
Another common practice in team development comes from the use of git for source code control. GitHub, Gitlab and BitBucket all support the pull-request/merge-request code review workflow. This provides a safe mechanism for the team to review and discuss proposed code changes from a working branch before they are merged into the main branch.
# Resources
- The (written) unwritten guide to pull requests
- Best practices for pull requests
- Proposing changes to your work with pull requests
# Protecting the main branch
One important step is to turn-on some protections on your GitHub main branch. In particular you want to ensure that no code is allowed to be directly merged into the main branch without a pull-request. Secondly, in a team you should require at least one other team member to approve the pull-request before it can be merged.
# Lab activity
- Select a lab partner
- Add your lab partner as a collaborator on your GitHub repo for Project 1 - React CRUD.
- Add branch protections for the main branch.
- Practice pull-request:
- make a new feature branch in your local (on your laptop) git repo
- make some code changes
- make a commit
- push the commit(s) for that branch to GitHub
- create a pull request
- have your partner review the pull-request
- use the comments section of the pull-request to ask questions or make suggestions
- approve the pull-request
- merge the changes into the main branch.
- Practice pair programming
TODO
Learn more about Pair Programming with these videos