YAGNI — You Aren’t Gonna Need It asks a team to avoid speculative features and abstractions until a real requirement justifies their cost. It is a prioritization rule, not an excuse to ignore known security, reliability, or migration work.

The Problem

Many developers are guilty of over-engineering, trying to add all sorts of features that might not even be needed. As you start coding, you might think “Oh, I could add this cool feature” or “I should probably build in the option to do this.” Stop right there! Before you go down that rabbit hole, ask yourself if you really need it.

The Solution: YAGNI

The YAGNI principle suggests that you only implement what you absolutely need at the moment. Don’t waste your time and energy building something that might never be used. Save yourself from the headache of maintaining unnecessary code.

Case Study

Let’s say you’re creating a simple app for ordering food online. Your first instinct might be to build in functionality for adding multiple addresses, tips, and advanced filtering options. But hold on a second, that’s not the main purpose of the app!

Instead, focus on the core functionality- allowing users to place an order with delivery method and payment. Everything else can come later when you know it is necessary.

Remember, less is more. Keep your codebase clean, lean, and mean. You’ll be thankful for it later.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Bad example
function calculateTotal(order: Order): number {
  // ...calculate subtotal
  const TAX_RATE = 0.1;
  const TIP_PERCENTAGE = 0.2;
  let tip = order.tipPercentage || TIP_PERCENTAGE;
  const TAX = (subtotal + tip) * TAX_RATE;
  let total = subtotal + tip + TAX;
  if (order.isPickup === false) {
    const DELIVERY_FEE = 10;
    total += DELIVERY_FEE;
  }
  if (order.isVIP === true) {
    total -= TIP_PERCENTAGE * subtotal;
  }
  return total;
}

// Good example
function calculateTotal(
  subtotal: number,
  tip: number,
  taxRate: number,
  isPickup: boolean
): number {
  let total = subtotal + tip + subtotal * taxRate;
  if (!isPickup) {
    const DELIVERY_FEE = 10;
    total += DELIVERY_FEE;
  }
  return total;
}

So next time you hear a voice in your head telling you to add a bunch of features to your codebase, take a deep breath and remember- YAGNI! Your future self will thank you (0f course, and me).

Use YAGNI alongside evidence and risk assessment. A small reversible feature can wait for demand; an irreversible data choice or known compliance requirement may need deliberate preparation before it becomes urgent.