Hybrid Loops: Combining Both Models

Module 14: OODA vs REPL Development Loops | Expansion Guide

Back to Module 14

The Problem

You started with REPL exploration. After 20 iterations, you have working code but it's a mess and you're stuck. Or: you planned with OODA for an hour, but now you're paralyzed - you need to just try something. Neither pure REPL nor pure OODA fits every moment.

Real development requires switching between modes.

The best developers are fluid. They REPL when exploring, OODA when stuck, and know exactly when to switch. This isn't indecision - it's adaptive strategy.

The Core Insight

OODA and REPL aren't competing - they're complementary modes you switch between based on signals.

Think of gears in a car: REPL is high speed low torque (fast iteration, low structure). OODA is low speed high torque (slow deliberate thinking, high structure). You shift gears based on terrain.

The skill: recognizing when to shift and executing the transition smoothly.

The Walkthrough

Transition Signal 1: REPL → OODA (Stuck in Chaos)

You're REPLing fast but...

Signal: Switch to OODA. You need structure.

# REPL Mode (chaotic)
Iteration 12: "Try caching the result"
Iteration 13: "Maybe async will help?"
Iteration 14: "What if we batch requests?"
[Nothing working, just guessing]

# Transition: Stop and Observe
"Wait. Let me document what I've tried and what the actual problem is."

# OODA Mode (structured)
Observe: Performance is slow because API calls are sequential
Orient: Three possible approaches - caching, async, batching
Decide: Test async first (most impact, least code change)
Act: Implement async with proper measurement

[Problem solved in 2 deliberate iterations vs 10 chaotic ones]

Transition Signal 2: OODA → REPL (Paralyzed by Planning)

You're in OODA but...

Signal: Switch to REPL. You need to build intuition through doing.

# OODA Mode (overthinking)
Observe: Need to add pagination
Orient: Could do cursor-based, offset-based, or keyset...
        Cursor handles edge cases but complex to implement...
        Offset is simpler but has consistency issues...
[30 minutes of analysis paralysis]

# Transition: Just try something
"I'm overthinking. Let me REPL the simplest version."

# REPL Mode (doing)
Iteration 1: "Implement offset pagination"
[2 minutes later] Works! Test it.

Iteration 2: "Add page size limit"
[1 minute later] Works!

Iteration 3: "What breaks if data changes during pagination?"
[Test reveals the actual edge case, not theoretical ones]

[10 minutes of REPLing beats 30 minutes of planning]

Hybrid Workflow Pattern

Most real work alternates between modes:

Phase Mode Duration Output
Understand problem OODA Observe 5 min Problem statement
Explore solutions REPL 15 min 3 working prototypes
Evaluate approaches OODA Orient 5 min Decision on best approach
Implement chosen approach REPL 20 min Working implementation
Hit edge case bug OODA Debug 10 min Root cause identified
Fix and iterate REPL 5 min Bug fixed

Total: 1 hour, 6 mode switches. That's normal and healthy.

Real Example: Building a Feature

Task: Add rate limiting to an API.

Phase 1: OODA Start (5 min)

Observe:
- API has no rate limiting
- Getting abuse from scrapers
- Need to limit to 100 req/hour per API key

Orient:
- Could use Redis for distributed counting
- Or in-memory for simplicity
- Redis makes sense for multi-server setup

Decide: Start with Redis, fall back to in-memory if too complex

Phase 2: REPL Exploration (10 min)

Iteration 1: "Show me basic Redis rate limiting in Python"
→ Simple counter with expiry. Works!

Iteration 2: "Add sliding window instead of fixed window"
→ More complex but fairer. Test shows it works.

Iteration 3: "What if Redis is down?"
→ Try/except added. Falls back to allowing request.

Phase 3: OODA Review (3 min)

Observe: Working implementation, but fallback allows unlimited requests if Redis fails

Orient: Three options:
1. Block all requests if Redis down (too harsh)
2. Allow unlimited (current, too permissive)
3. Use in-memory fallback (best of both)

Decide: Implement #3

Phase 4: REPL Implementation (5 min)

Iteration 1: "Add in-memory fallback with same interface"
→ Works locally.

Iteration 2: "Test Redis failure scenario"
→ Switches to in-memory correctly!

Phase 5: OODA Validation (2 min)

Observe: Feature complete and tested

Orient: Edge cases to verify:
- Multiple servers (in-memory will have different counts) ← Need to document
- Clock skew ← Redis handles this
- Key expiry edge cases ← Tested

Decide: Ship with documentation about multi-server limitation

Total time: 25 minutes. 4 mode switches. Clean result.

The Power of Fluid Switching

Pure REPL would have missed edge cases. Pure OODA would have taken an hour of planning. Hybrid approach gets best of both: speed AND rigor.

Mode Selection Decision Tree

if problem_is_clear and solution_is_obvious:
    REPL  # Just do it

elif stuck_after_N_repl_iterations:  # N ≈ 5-10
    OODA  # Need to step back and think

elif planning_for_more_than_15_minutes:
    REPL  # Stop thinking, start doing

elif bug_is_complex_and_mysterious:
    OODA  # Need systematic debugging

elif exploring_new_library_or_api:
    REPL  # Learn by doing

elif making_architectural_decision:
    OODA  # Need deliberate evaluation

elif refactoring_messy_code:
    OODA first (plan approach) → REPL (execute changes)

elif implementing_well_defined_spec:
    REPL  # Spec provides structure

else:
    Start with REPL, switch to OODA when stuck

Failure Patterns

1. Mode Thrashing

Symptom: Switching modes every 2 minutes. Never staying in either long enough.

Fix: Set minimum time in mode - at least 5 minutes before switching.

2. Stuck in REPL

Symptom: 50 iterations, no progress, but you keep trying random things.

Fix: Hard rule: After 10 failed iterations, mandatory OODA switch.

repl_iteration_count = 0
failed_iterations = 0

while working:
    result = repl_iteration()
    repl_iteration_count += 1

    if not result.improved:
        failed_iterations += 1

    if failed_iterations >= 10:
        print("STOP. Switching to OODA mode.")
        force_ooda_analysis()
        failed_iterations = 0

3. Stuck in OODA

Symptom: Debating hypothetical edge cases, never writing code.

Fix: Time box OODA - if over 15 minutes in Orient phase, force a Decide and Act.

4. Not Documenting Transitions

Symptom: You REPL'd a solution but forgot why you chose that approach.

Fix: Log your mode switches and decisions.

# Keep a session log
[10:15 REPL] Trying Redis for rate limiting
[10:20 REPL] Basic version works
[10:23 OODA] Evaluating fallback strategies
[10:26 OODA] Decision: in-memory fallback
[10:27 REPL] Implementing fallback
[10:32 DONE] Feature complete

Signs You Need a Mode Switch

REPL → OODA:

OODA → REPL:

Advanced Hybrid Patterns

The Spike-Then-Structure Pattern

# Phase 1: REPL Spike (time-boxed to 30 min)
"Let me try 3 different approaches quickly"
[REPL iteration: approach A]
[REPL iteration: approach B]
[REPL iteration: approach C]

# Phase 2: OODA Evaluation (10 min)
Observe: A is fastest, B is most maintainable, C has best error handling
Orient: For this use case, maintainability > speed
Decide: Implement B properly

# Phase 3: REPL Implementation (20 min)
[Clean implementation of approach B with lessons from A and C]

The Test-Driven Hybrid

# Phase 1: OODA Planning
Observe: Need user authentication
Orient: JWT tokens, session-based, or OAuth
Decide: JWT for stateless API

# Phase 2: REPL Test Writing
"Write test cases for JWT authentication"
[REPL through test scenarios]

# Phase 3: OODA Review Tests
Orient: Do these tests cover all cases?
[Add missing edge case tests]

# Phase 4: REPL Implementation
[REPL until all tests pass]

The Debug-Fix-Validate Cycle

# Bug appears
→ OODA: Observe, Orient, form hypothesis
→ REPL: Quick test of hypothesis
→ OODA: Interpret results, update mental model
→ REPL: Implement fix
→ OODA: Validate fix doesn't break anything
→ Done

Quick Reference

Mode Switch Triggers:

Situation Switch To Why
Starting new feature OODA Orient Understand problem first
Exploring API REPL Learn by doing
Stuck after 10 tries OODA Need strategy
Planning >15 min REPL Analysis paralysis
Complex bug OODA Systematic debugging
Simple change REPL Don't overthink

Hybrid Workflow Template:

# 1. Start with OODA to understand (5-10 min)
Observe: What's the problem?
Orient: What are possible approaches?

# 2. REPL to explore (10-20 min)
Rapidly prototype 2-3 approaches

# 3. OODA to evaluate (5 min)
Decide: Which approach is best?

# 4. REPL to implement (varies)
Build out chosen approach

# 5. OODA to validate (5 min)
Observe: Does it work correctly?
Orient: What edge cases remain?

# 6. REPL to polish (10 min)
Handle edge cases, clean up code

Daily Practice: