Design Patterns · Middle · Question 34 of 75
Why do people say "duplication is cheaper than the wrong abstraction"?
- ✓Correct answer: Premature generalization accumulates flags and couples unrelated cases
- 2Copied code runs faster because there are no function calls
- 3JavaScript engines don't optimize abstractions well
Explanation
A shared component for two similar screens gradually gets isAdmin, variant, hideFooter… and becomes worse than copies. The AHA principle (Avoid Hasty Abstractions) and the "rule of three": generalize when the repetition has become obvious.