🎁 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

Big O Notation
A mathematical notation that describes the worst-case performance of an algorithm as input size grows.
Singleton Pattern
A design pattern that restricts a class to a single instance and provides a global point of access to that instance.
SOLID Principles
Five design principles for writing maintainable, flexible object-oriented code: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.
Queue
A data structure that follows First-In-First-Out (FIFO) ordering, where elements are added at the rear and removed from the front.
Event-Driven Architecture
A software design pattern where components communicate by producing and consuming events rather than direct method calls.
Design Pattern
A reusable solution template for commonly occurring problems in software design.
View All Programming Concepts Terms →