DRY 00:00:00 Make a prediction You will tell duplicated knowledge from coincidentally similar code and identify the owner of a discount threshold. Preview grants a discount at three items. Checkout starts requiring four. A basket has exactly three. What will the customer see? A discounted preview and a different final price. Both copies claim to answer one business question, so one owner should calculate both results. 00:00:29 Noor and the painted hours Two signs on a shop door list opening times. A new Sunday schedule gets painted on only one sign. The disagreement matters because both signs claim to state the same hours. Duplicate text becomes dangerous when it represents one fact. Two different shops open at nine for unrelated reasons; tying those schedules to one variable would create a new mistake. DRY means don't repeat yourself. Andy Hunt and Dave Thomas wrote it as a rule about knowledge: each piece of it should have one clear, trusted place in the system. A copy does no harm on the day it is made. The harm comes with the first change. Somebody must remember every copy, find it, edit it in the same way and test it. One forgotten copy is a bug, and the program now gives two answers to one question. 00:01:21 Remove a duplicated business rule The cart preview gives ten percent off when three items qualify. Checkout has an independent copy of the condition. A change to four qualifying items reaches checkout first. Both screens now show different totals for the same basket. Give the discount threshold one owner and ask it to calculate both quotes. Test the third and fourth qualifying items at both entry points. Send the same three-unit basket through preview and checkout. Both must agree that it misses a four-unit threshold. If only one component changes after a policy update, the displayed total and charged total diverge. A single policy used by both paths closes this gap. 00:02:05 Similar code can mean different rules A birthday discount and damaged-stock discount may both start at ten percent. Marketing and warehouse teams can change them independently. Sharing a constant just because the numbers match makes an unrelated change propagate. Share a piece of knowledge only when its meaning is shared. Imagine finance cuts the early-payment discount to five percent while marketing keeps its seasonal offer at ten. Editing one shared constant would quietly change both prices. Write two named rules and test them separately until the business explicitly makes them one policy. Two independent discounts can currently have the same number without sharing a reason to change. A shared constant makes the next independent decision harder. Duplicate a little mechanical code temporarily if the underlying business meanings have not yet proved to be the same. Ruby on Rails. The Rails guide names Don't Repeat Yourself as one of its two guiding principles, beside Convention over Configuration. Django. Its design philosophies say that every distinct concept or piece of data should live in one place. A model class drives the table, the forms and the admin pages. 00:03:18 Try an interview follow-up Two functions have the same three lines. Do you merge them? Only if one reason would change both. A password length and a voucher length may both be 8, with different owners. I ask who would ask for a change, and whether the other should follow. If not, I keep both. Shipping and refunds both use a thirty-day constant today. Tomorrow refunds change to fourteen days. If both constants represent one shared policy, one edit belongs in one place. Here two owners can change the rules independently. Keep two named policies so the refund change cannot silently alter shipping. 00:04:00 What to take with you DRY is about knowledge. Ask: if this fact changes, how many places do I edit by hand? One is the goal. Same text is only a hint. Merge two pieces if one reason changes both. Keep them apart if they only look alike today.