Tier 3 Series 203

203C: The View Controller

Pilot Record
Student Profile
"The fuel tank (Data) should not know about the fuel gauge (UI). If the tank tries to set `gauge.text`, you can never change the UI without breaking the engine. A Pilot uses the MVC Pattern to keep them separate."

The Concept: MVC (Model-View-Controller)

A separation of concerns:

* **Model:** The raw data (Health = 100).
* **View:** The UI (The red bar).
* **Controller:** The script that listens to the Model and updates the View.
Red Flag Detected

The AI Trap: "The Tightly Coupled UI"

You ask the AI: "Update the health bar when I take damage."

// AI-Generated Code: Bad Dependency
class Player {
    public Text healthText; // Dependency
    void TakeDamage() {
        health--;
        healthText.text = health.ToString();
    }
}

This is "Hard Wiring." The Player script now depends on the UI engine. You cannot test the player logic without the UI present.

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: Decoupled
// Player Script:
public Action<int> OnHealthChanged;
// UI Controller Script:
player.OnHealthChanged += (h) => label.text = h.ToString();
Your Pilot Command
> A skilled Pilot directs the AI to use Events. You command: "Fire a OnHealthChanged event. Let a separate UIController script listen and update the label."
Next Mission
The Event Dial