SOLID & OOP Principles (50 Qs)•Part 2: Object-Oriented Design, Code Smells & Refactoring (11 - 24)
What is the DRY (Don't Repeat Yourself) principle vs Accidental Duplication?
junior Levelsolid-principlesObject-Oriented Design
In Simple Words: DRY states: Every piece of knowledge must have a single, unambiguous representation within a system.
- Crucial Distinction: Code that looks identical but changes for different business reasons is Accidental Duplication. Coupling them into a shared helper creates premature abstraction and breaks SRP.