11. Common Mistakes
MODULE 11

Common Mistakes


11.1: The "Just Make It Work" Trap

The mistake: Accepting AI code without understanding it. It compiles, it runs, ship it.

Why it's dangerous: You now own code you can't debug, can't extend, and can't explain. When it breaks at 2am in production, you're stuck.

The fix: Read every function. Ask AI to explain unclear parts. If you can't explain what the code does, don't ship it.

11.2: The Infinite Fix Loop

The mistake: AI keeps generating similar wrong solutions. You've been going back and forth for 20 minutes.

Signs you're stuck:

  • Same error keeps appearing
  • AI apologizes and makes the same mistake
  • You're saying "no, try this instead" for the third time

The fix: Stop. Use the oneshot restart from Module 6. Fresh prompt with everything you've learned. Or write the tricky part yourself.

11.3: Over-Engineering

The mistake: AI loves adding abstractions, design patterns, and layers of indirection you don't need.

Example: You ask for a simple function to format a date. AI creates a DateFormatterFactory with a Strategy pattern and an AbstractDateProvider.

The fix: Explicitly ask for simplicity:

"Give me the simplest possible implementation.
No abstractions. No design patterns.
I can refactor later if needed."

11.4: Dependency Bloat

The mistake: AI adds npm packages for things you could do in 10 lines of code.

// AI suggests:
import { formatDate } from 'date-fns';
import { debounce } from 'lodash';
import { v4 as uuid } from 'uuid';
 
// What you actually need:
const formatDate = (d) => d.toLocaleDateString();
const debounce = (fn, ms) => { let t; return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), ms); }; };
const uuid = () => crypto.randomUUID();

Each dependency is a security risk, a maintenance burden, and a bundle size increase. Ask: "Can this be done without adding a library?"

11.5: God Functions

The mistake: AI creates massive functions that do everything.

// AI might generate this 200-line monster
function handleUserRegistration(data) {
  // validate input
  // hash password
  // save to database
  // send welcome email
  // log analytics event
  // update leaderboard
  // ... 200 lines of everything
}

The fix: Ask for focused functions:

"Split this into smaller functions. Each function should do ONE thing.
I want: validateInput, hashPassword, saveUser, sendWelcomeEmail."
Single responsibility principle

Small, focused functions are testable, debuggable, and reusable. God-functions are none of these. Always ask AI to decompose large functions.

11.6: Context Contamination

The mistake: Long conversations where AI "forgets" decisions from earlier in the chat.

After 15-20 back-and-forth messages, AI's context window is full. It starts contradicting itself, forgetting your architecture decisions, and using wrong patterns.

The fix: Start fresh for new features. Summarize decisions when starting a new chat. Reference files directly instead of describing them.

11.7: Blind Copy-Paste

The mistake: Accepting AI output without reading it line by line.

AI makes subtle errors:

  • Wrong variable names that happen to compile
  • Incorrect imports that fail at runtime
  • Missing error handling for edge cases
  • Security vulnerabilities that look like normal code

The fix: Read. Every. Line. Trust but verify. If something looks suspicious, ask AI to explain it.

🧠
Module Checkpoint
Test your understanding -- try to answer from memory before looking
What should you do if you can't explain what AI code does?

How do you prevent AI from over-engineering?

What is the 'god function' problem?

When does context contamination happen?