Developer Dictionary
DRY
Definition
Don't Repeat Yourself; a principle of software development aimed at reducing repetition of software patterns.
Deep Dive
DRY, an acronym for "Don't Repeat Yourself," is a fundamental principle of software development aimed at reducing the repetition of information, logic, and functionality within a system. The essence of DRY is that "every piece of knowledge must have a single, unambiguous, authoritative representation within a system." Instead of duplicating code or data structures, developers are encouraged to abstract common elements into reusable components, functions, or modules that can be referenced from multiple places.
Examples & Use Cases
- 1Creating a shared utility function for input validation instead of duplicating the logic in multiple forms
- 2Defining a common CSS class for button styling to ensure consistent appearance
- 3Using a database migration script to define schema changes rather than manually updating multiple environments
Related Terms
RefactoringCode ReusabilityAbstraction