LearnViz CompSci
Home / Learn / Software Engineering / DRY, KISS and YAGNI

Intermediate Topic 19 of 50 Software Engineering

DRY, KISS and YAGNI

Heuristics against duplication, complexity and speculation.

How it works

DRY, do not repeat yourself, says every piece of knowledge should have a single authoritative representation in the system, so a change needs to be made in one place. KISS, keep it simple, favors the simplest solution that works. YAGNI, you aren't gonna need it, warns against building features or generality for hypothetical future needs. Together they steer designs away from duplication, over-engineering and speculation.

Step-by-step walkthrough

  1. DRY: do not repeat yourself, keep each piece of knowledge in one place.
  2. KISS: keep it simple, the simplest solution that works.
  3. YAGNI: you are not going to need it, do not build features speculatively.
  4. They fight duplication, complexity and waste.
  5. Use judgment, too much DRY can couple unrelated code.

Where it is used

Developers apply them when deciding to extract a function, whether to add a configuration option or when to introduce an abstraction, and in code reviews.

Common pitfall

DRY applied too eagerly merges code that merely looks alike but changes for different reasons, creating tangled abstractions; some duplication is cheaper than the wrong abstraction. Simplicity does not mean sloppy. YAGNI does not forbid planning for known requirements. Wait until duplication appears a few times before abstracting.

Where it fits in the course

DRY, KISS and YAGNI is topic 19 of 50 in Software Engineering, rated Intermediate. It follows SOLID Principles. The next topic is Design Patterns.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Software Engineering quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is DRY, KISS and YAGNI?
Heuristics against duplication, complexity and speculation. It belongs to Software Engineering and is an intermediate-level topic.
Where do people use DRY, KISS and YAGNI?
Developers apply them when deciding to extract a function, whether to add a configuration option or when to introduce an abstraction, and in code reviews.
What is the most common mistake with DRY, KISS and YAGNI?
DRY applied too eagerly merges code that merely looks alike but changes for different reasons, creating tangled abstractions; some duplication is cheaper than the wrong abstraction.
What should I learn before this topic?
Start with SOLID Principles, the topic just before it in Software Engineering.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Software Engineering quiz.
Is DRY, KISS and YAGNI hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn DRY, KISS and YAGNI?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to DRY, KISS and YAGNI?
SOLID Principles, Design Patterns, Software Maintenance are closely connected. The full list is in the related topics section of this page.
What should I study after DRY, KISS and YAGNI?
Continue with Design Patterns, the next topic in Software Engineering.

Related topics