Learn the vocabulary of keeping every piece of knowledge in a single, unambiguous place in a system.
0 / 5 completed
1 / 5
At standup, a dev mentions ensuring that a specific piece of business knowledge, like a tax calculation rule, exists in exactly one place in the codebase, rather than being copy-pasted with slight variations across several files. What principle is this called?
DRY, short for "Don't Repeat Yourself," is exactly this: it is the principle that every piece of knowledge or logic, like a tax calculation rule, should have a single, unambiguous representation in a system, rather than being duplicated with slight variations across multiple files. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This single-source-of-truth-for-each-piece-of-knowledge approach is exactly why DRY prevents duplicated copies from silently drifting out of sync with each other over time.
2 / 5
During a design review, the team consolidates a tax calculation rule that had been copy-pasted into four separate files into a single shared function, specifically because applying DRY means a future tax-rule change now only needs to happen in one place. Which capability does this provide?
Consolidating the rule here provides a single source of truth for the tax rule, since consolidating the duplicated logic into one shared function means a future change is applied consistently everywhere instead of risking the four copies drifting out of sync with each other. Leaving the tax calculation rule copy-pasted across four separate files means a future change to the rule has to be remembered and applied identically in all four places, and any missed copy silently produces a different result. This one-place-updated-consistently behavior is exactly why applying DRY is the standard fix for duplicated business logic.
3 / 5
In a code review, a dev notices a tax calculation rule has been copy-pasted into four separate files with slightly different formatting, and a recent rate change was applied to three of them but missed the fourth, which now silently computes tax using the old rate. What does this represent?
This is a missed opportunity to apply DRY, since consolidating the tax rule into a single shared function would have applied the rate change consistently everywhere instead of missing one of four duplicated copies. A cache eviction policy is an unrelated concept about discarded cache entries. This duplicated-copies-drift-out-of-sync pattern is exactly the kind of risk a reviewer flags once the same piece of business knowledge exists in more than one place.
4 / 5
An incident report shows customers were charged an outdated tax rate in production, because a tax calculation rule had been copy-pasted into four separate files and a recent rate change was applied to three of them but missed the fourth entirely. What practice would prevent this?
Applying DRY by consolidating the tax calculation rule into a single shared function means a future rate change is applied consistently everywhere instead of risking a missed copy among several duplicates. Continuing to copy-paste the tax calculation rule across separate files regardless of how often a future change misses one of the duplicated copies is exactly what caused the outdated charge described in this incident. This consolidate-the-logic approach is the standard fix once duplicated business logic is confirmed to have drifted out of sync.
5 / 5
During a PR review, a teammate asks why the team applies DRY and consolidates the tax rule into one function instead of simply adding a comment above each of the four copies reminding future editors to update all four together whenever the rule changes. What is the reasoning?
Consolidating the rule into one function makes it structurally impossible to update inconsistently, since there's only one copy left to change, while a comment reminding editors to update all four together still depends on every future editor actually finding, reading, and correctly following that reminder, and a single missed copy reproduces the exact same drift risk. This is exactly why applying DRY through actual consolidation is the standard fix, rather than relying on a reminder comment to manage duplicated logic.