← Notes
DRY Principle
DRY stands for “Don’t Repeat Yourself” - a software engineering principle that encourages uniqueness by introducing abstractions such as variables and functions to avoid redundancy in code.
Core Idea
The DRY principle aims to reduce repetition by:
- Creating reusable abstractions
- Extracting common patterns into functions or variables
- Maintaining a single source of truth for each piece of knowledge
When DRY Works Well
DRY is effective for:
- Application code that is tested
- Logic that truly represents the same concept
- Reducing maintenance burden through centralization
When DRY May Not Apply
Not all repetition is bad. Consider [[DAMP]] for:
- Configuration files
- Test code
- Cases where readability matters more than uniqueness
Related Concepts
- [[DAMP Principle]] - Alternative approach for configuration
- [[Source: Bazel BUILD Style Guide]]
- Code maintainability
- Software design principles
Linked References
- [[Bazel BUILD Style Guide]]
Official Bazel style guide recommending DAMP over DRY for BUILD files.
- [[DAMP Principle]]
Descriptive and Meaningful Phrases - a principle encouraging readability over uniqueness.