Tier 1 Series 2

2A: The Switchboard

Pilot Record
Student Profile
"Imagine a pilot entering a crowded airspace. They receive multiple radio calls: 'Landing gear status?', 'Fuel level?', 'Current altitude?'. If the pilot checks every single instrument manually one-by-one before answering, the cockpit becomes a bottleneck.

In programming, deep if-else chains are like that manual check. A Switchboard approach allows the AI to jump directly to the correct answer, reducing cognitive load."

The Concept: Flat Logic

Based on Chapters 1-3, we learn to transition from basic comparisons to pattern matching. We want to replace nested checks with high-speed delivery.

Switch Expressions: Modern C# syntax for returning values instantly based on input.
The Discard (_): A safety net that handles every unexpected case in one line.
Red Flag Detected

The Audit: Spot the "Arrow Code" Error

You ask the AI: "Check the flight phase and return the engine power level."

// AI-Generated Code (Nested Mess)
public string GetPower(FlightPhase phase) {
    if (phase == FlightPhase.Idle) {
        return "Low";
    } else {
        if (phase == FlightPhase.Takeoff) {
            return "Maximum";
        }
    }
    return "Unknown";
}

This is "Arrow Code." While it works, it is mathematically "heavy" to read. As you add more phases (Taxi, Flight, Landing), the nesting becomes a maze where bugs hide.

Elite Telemetry

Research shows "Elite" teams achieve 15% faster lead times by keeping AI on a "very tight leash."

  • Small Batches Solving one problem at a time prevents logic drift.
  • Modular Design Localizing the "blast radius" of AI changes.
  • Tight Loops Rapid iteration with constant code review.

The Pilot's Correction

Corrective Protocol
// Corrected Code
public string GetPower(FlightPhase phase) => phase switch
{
    FlightPhase.Idle    => "Low",
    FlightPhase.Takeoff => "Maximum",
    _                   => "Unknown" // The safety net
};
Your Pilot Command
> Physics-based movements belong inside the FixedUpdate method.
Next Mission
Collections Audit