Skip to the guide

DRY, KISS and YAGNI: when simple beats clever

BeginnerConcept6 pages

These are three short rules for keeping a design small. DRY, "don't repeat yourself", says each piece of knowledge lives in one place. KISS, "keep it simple", says choose the simplest design that meets the requirement. YAGNI, "you aren't gonna need it", says don't build what nobody asked for. Interviewers want to see you apply them with judgement, including the cases where each one points the wrong way.

The shelf label and the till

Think of a small corner shop. Every price is written twice: on the label on the shelf, and in the till. One morning the owner raises the price of a cereal box in the till and forgets the label. All day, customers pick up a box marked $3 and pay $3.50 at the counter. A better shop prints its shelf labels from the till's price list, so the price lives in one place.

A notebook and a pack of pens both cost $4, but they keep separate labels. When pens go up, notebooks don't. The owner also writes her labels by hand instead of buying screens she would have to program. She doesn't print labels in three currencies for tourists who might visit one day.