🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Programming Concepts Beginner

What is DRY (Don't Repeat Yourself)?

A software development principle that aims to reduce code duplication by abstracting common patterns into reusable components.

DRY states that every piece of knowledge should have a single, unambiguous representation in a system. Duplicate code means duplicate bugs and duplicate maintenance effort. Extract common logic into functions, classes, or modules.

However, premature abstraction can be worse than duplication. The "Rule of Three" suggests abstracting only after seeing the same pattern three times. WET (Write Everything Twice) and AHA (Avoid Hasty Abstractions) are counterbalancing principles that warn against over-abstraction.

Related Terms

Garbage Collection
An automatic memory management process that identifies and reclaims memory no longer in use by a program.
Data Structure
A way of organizing and storing data in a computer so it can be accessed and modified efficiently.
Twelve-Factor App
A methodology of twelve best practices for building modern, scalable, maintainable software-as-a-service applications.
Algorithm
A step-by-step procedure for solving a problem or performing a computation, defined as a finite sequence of instructions.
Unit Testing
Testing individual components or functions of a program in isolation to verify they work correctly.
Composition over Inheritance
A design principle favoring object composition (has-a relationships) over class inheritance (is-a relationships) for code reuse.
View All Programming Concepts Terms →