Pair Programming
A collaborative coding practice where two developers work together on the same task at the same time, usually at one workstation, to write and improve code.
Key Points
- Two roles: one developer types (driver) while the other reviews and guides (navigator).
- Roles switch frequently to balance focus, learning, and quality.
- Delivers continuous code review, reducing defects and improving design.
- Enables rapid knowledge sharing; effective in both co-located and remote setups.
Example
During a sprint, the team pairs a senior and a junior developer to implement a risky authentication feature. The senior starts as navigator, reviewing each line and proposing test cases while the junior drives at the keyboard. They swap roles every 20 minutes and finish with cleaner code and fewer defects, shortening review and rework time.
PMP Example Question
Two developers share one workstation to implement a complex feature, with one typing and the other reviewing and guiding. They switch roles regularly. What practice is being used?
- Pair programming
- Mob programming
- Formal code inspection after commit
- Swarming across multiple backlog items
Correct Answer: A — Pair programming
Explanation: Pair programming involves two developers working together at the same time on the same code, typically with driver and navigator roles that rotate.
HKSM