Visual Audit Protocol

Logic & Data Flow

Return to Hangar
2A

The Switchboard

The Concept: Flat Logic

NESTED IF/ELSE
// 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"; }
SWITCH EXPRESSION
// Corrected Code public string GetPower(FlightPhase phase) => phase switch { FlightPhase.Idle => "Low", FlightPhase.Takeoff => "Maximum", _ => "Unknown" // The safety net };
2B

Collections Audit

Check containers.

// Corrected Code (Optimized) public List<GameObject> enemies = new List<GameObject>(50);
// AI-Generated Code (Inefficient) public List<GameObject> enemies = new List<GameObject>(); void SpawnEnemy(GameObject prefab) { enemies.Add(Instantiate(prefab)); }
2C

Iteration Loops

The Concept: Scanning Logic

FOREACH CRASH
REVERSE FOR SAFE
Count-1 0
2D

Method Signatures

Inputs and outputs define the "contract" of a function. Pure Functions: Given the same input, they always return the same output and change nothing else. Side Effects: When a method modifies data outside of its local scope. Parameters: The "Ask." Return Types: The "Answer."

TRAP: The Audit: Spot the "Side Effect" Error
// AI-Generated Code (Impure) public bool CanReachDestination(float distance) { float fuelNeeded = distance * 0.5f; if (currentFuel >= fuelNeeded) { return true; } else { isEmergencyDeclared = true; // SIDE EFFECT: Changing state! return false; } }
2E

Value vs. Reference

Check containers.

// Corrected Code (Type Safe & Fast) public List<int> scores = new List<int>(); void AddScore(int value) { scores.Add(value); // Success: Stays in the pocket! }
// AI-Generated Code (Memory Heavy) public List<object> scores = new List<object>(); void AddScore(int value) { scores.Add(value); // ERROR: Boxing occurs here! }
2F

Static Utilities

The Concept: Global vs. Local


STATIC
Shared (Leak)

INSTANCE
Local (Safe)
CAPSTONE EXAM

The Logic Exam

Your training in Series 2 has focused on the movement and storage of data. A pilot doesn't just need to know which button to press; they must understand the current flowing through the switchboard. In this exam, you are the Lead Auditor. You will be presented with a high-level "Fuel Management System" script that is riddled with logic stutters, memory leaks, and side effects.

Verify Capacity
Check Scope
Audit Efficiency