AI reviewed · sources pending. Book associations have not been verified.

DRY principle

Concept

The DRY principle aims to give each piece of system knowledge one authoritative representation.

Explanation or usage

Duplicated rules can drift when they are changed in several places. Similar-looking code does not always encode the same knowledge, so removing duplication requires understanding meaning. A shared representation should reduce inconsistency without creating an inappropriate dependency.

Common misunderstandings

Every visually similar line must be merged, even if its business meanings differ.

In The Pragmatic Programmer

General context reviewed · book attribution and sources pending

Proposed Chapter 2 context: distinguish duplication of a rule from incidental similarity in code.

Linked books

Practice this item

Two functions look similar but encode rules owned by different domains that are expected to change independently. What should guide a decision to merge them? Two services separately encode the same discount rule and now disagree. What is the central DRY problem?