DRY, KISS & YAGNI
EasyIn plain terms
DRY (Don't Repeat Yourself) means avoid duplication. If the same logic appears in multiple places, extract it into a function or module and reuse it. Duplication makes bugs and changes harder—you have to update every copy.
KISS (Keep It Simple, Stupid) means prefer the simplest solution that works. Fancy patterns and extra abstraction can wait until you need them.
YAGNI (You Aren't Gonna Need It) means do not add features or complexity "for later." Build what you need now; refactor when requirements appear. Together, these keep code lean and maintainable.
What you need to know
- •DRY: one place for each piece of knowledge
- •KISS: simplest solution
- •YAGNI: no speculative features
Example
Code is language-agnostic in spirit; adapt the idea to your language:
// DRY: extract repeated logic
function fullName(user) {
return user.firstName + " " + user.lastName;
}
// Use fullName() everywhere instead of repeating the string build
// KISS: simple condition
const isAdult = age >= 18;
// YAGNI: don't build "might need" features yetWhy this matters
DRY/KISS/YAGNI are shorthand interview answers for "how do you keep code maintainable?" Senior developers are expected to cite these and give examples.
How it connects
DRY connects to SRP (one place for each piece of logic). KISS and YAGNI prevent over-engineering that violates YAGNI and over-abstraction. They apply to both procedural and OOP code.
Interview focus
Be ready to explain these; they come up often.
- ▸DRY: one place for each piece of knowledge; duplication = multiple places to fix.
- ▸KISS: simplest solution that works; avoid unnecessary complexity.
- ▸YAGNI: do not build "for the future"; add when you need it.
Learn more
Dive deeper with these resources: