Repaso
EspaƱol

What does the DRY principle say?

Options

  1. Don't Repeat Yourself: each piece of knowledge lives in one place (Correct option)
  2. Do Refactor Yearly: review and clean the code every year
  3. Delete Redundant Years: remove old versions of the code
  4. Document Right away: write the docs with each commit

Answer

Don't Repeat Yourself: each piece of knowledge should live in one place

Why

If the same logic is copied in five places, a bug fix or rule change must be made five times, and someone will forget one.

DRY says: put that logic in one function, class or constant and reuse it.

But do not merge code that only looks similar by accident; sometimes a little duplication is clearer than the wrong abstraction.

Remember

One rule, one place.

Key terms

Practice this question in Repaso