YAGNI — Explained with Examples
YAGNI (You Aren’t Gonna Need It) is an extreme programming principle that discourages adding functionality until it is actually needed.
YAGNI stands for You Aren’t Gonna Need It, a core principle of Extreme Programming (XP) coined by Ron Jeffries. It warns against building features based on speculation about future requirements — only implement what the current requirements demand.
Why YAGNI Matters
Speculative features consume development time, add complexity, and often end up unused. Studies suggest 60% of built features are rarely or never used. Each unused feature adds maintenance cost, testing burden, and cognitive overhead for future developers. YAGNI saves time and reduces waste.
Real-World Analogy
You’re packing for a weekend trip. You don’t pack winter boots, a wetsuit, and a formal gown “just in case.” You pack for the weather forecast and planned activities. If it suddenly snows, you buy boots there. Similarly, add features when (and if) the need arises.
Example: YAGNI Violation vs Fix
# Violating YAGNI — premature generalization
class PaymentProcessor:
def process(self, payment, currency="USD", locale="en",
discount=None, tax=None, invoice=False, receipt=False):
# 6 parameters, most unused for basic payments
pass
# Following YAGNI — start minimal, extend later
class PaymentProcessor:
def process(self, amount):
# Just process the payment
pass
# When you need currency support:
def process(self, amount, currency="USD"):
# Add only what you need now
passRelated Terms
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro