{
    "slug": "pair_programming",
    "term": "Pair Programming",
    "category": "general",
    "difficulty": "beginner",
    "short": "Two developers work together at one workstation — one writing code (driver), one reviewing and guiding (navigator).",
    "long": "Pair programming (from Extreme Programming) has the driver write code while the navigator reviews, considers the bigger picture, and catches mistakes in real time. Pairs switch roles regularly. Benefits include: immediate code review, shared knowledge preventing silos, higher design quality from continuous discussion, and faster onboarding. Studies show it produces fewer defects at a modest productivity cost. Remote pairing tools (VS Code Live Share, JetBrains Code With Me) make it viable for distributed teams. Not all tasks benefit equally — exploratory or complex tasks see the most gain.",
    "aliases": [
        "pair coding",
        "paired programming",
        "driver navigator"
    ],
    "tags": [
        "general",
        "team-process",
        "quality",
        "agile"
    ],
    "misconception": "Pair programming halves productivity because two people do one person's work. Studies consistently show pairs produce fewer bugs, onboard new developers faster, and spread knowledge more effectively — the total cost per feature is often lower despite appearing slower by lines-of-code metrics.",
    "why_it_matters": "Pair programming produces code with fewer defects, spreads knowledge across the team, and reduces bus factor — two minds catch each other's mistakes and produce better designs than either alone.",
    "common_mistakes": [
        "One person driving while the other passively watches — both must be actively engaged.",
        "Not switching driver/navigator roles frequently enough — one person dominates.",
        "Pairing as a productivity metric tool — it is a quality and knowledge-sharing tool, not an output maximiser.",
        "Never pairing — lone developer silos cause knowledge concentration and missed design opportunities."
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "code_review",
        "test_driven_development"
    ],
    "prerequisites": [
        "code_review",
        "test_driven_development",
        "mob_programming"
    ],
    "refs": [
        "https://www.extremeprogramming.org/rules/pair.html"
    ],
    "bad_code": "// Pairing anti-pattern — one person types, other watches:\nDeveloper A: [typing intensely]\nDeveloper B: [watching YouTube on phone]\n// No knowledge transfer, no second perspective, no benefit\n\n// Productive pairing:\nDeveloper A (navigator): 'We should validate the email before saving'\nDeveloper B (driver): [typing validation] 'Good catch — should we also check uniqueness?'\nDeveloper A: 'Yes, let's add that test first'",
    "good_code": "# Pair programming patterns for PHP teams\n\n# Driver-Navigator:\n# Driver: writes code\n# Navigator: reviews in real-time, thinks ahead, spots issues\n# Switch every 25 minutes (Pomodoro)\n\n# Ping-Pong (TDD pairing):\n# Dev A writes a failing test\n# Dev B makes it pass, then writes next failing test\n# Dev A makes it pass → repeat\n\n# Tools for remote pairing:\n# VS Code Live Share — shared editing, terminals, debugging\n# JetBrains Code With Me — PhpStorm native\n# tmux + Vim — terminal-based, ultra-low latency\n\n# Benefits:\n# - Knowledge transfer (no bus factor for critical paths)\n# - Real-time code review (fewer PR back-and-forths)\n# - Architecture decisions made together (fewer rewrites)\n\n# Start with 20% of dev time — high-complexity or high-risk work",
    "quick_fix": "Switch driver/navigator roles every 25 minutes (Pomodoro rhythm) — the navigator thinks ahead while the driver focuses on implementation",
    "severity": "info",
    "effort": "medium",
    "created": "2026-03-15",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/pair_programming",
        "html_url": "https://codeclaritylab.com/glossary/pair_programming",
        "json_url": "https://codeclaritylab.com/glossary/pair_programming.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Pair Programming](https://codeclaritylab.com/glossary/pair_programming) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/pair_programming"
            }
        }
    }
}