news.volyx.in

Don't DRY Your Code Prematurely (testing.googleblog.com)

777 points by thunderbong · 805 days ago · 395 comments on HN

Article summary

The article discusses the concept of Don't Repeat Yourself (DRY) in coding and argues that premature application of this principle can lead to more harm than good. It suggests that consolidating code too early can make it harder to maintain and understand, and that duplicated code is not always a problem. The article encourages developers to consider the trade-offs and not apply DRY dogmatically. The discussion that follows explores the pros and cons of DRY and its application in different contexts.

Main themes

  • Don't Repeat Yourself principle
  • Code maintenance and readability
  • Premature optimization
  • Code duplication and abstraction
  • Best practices in coding

What commenters say

  • Over-application of DRY can lead to more problems than under-application, as it can make code harder to understand and maintain.
  • Duplicated code is not always a significant issue, and the effort to consolidate it may not be worth the cost.
  • Some argue that DRY is not a hard and fast rule, and that its application depends on the specific context and goals of the project.
  • Others believe that DRY is essential for maintaining clean and efficient code, and that the benefits outweigh the potential drawbacks.
  • The decision to apply DRY should be based on a careful consideration of the trade-offs, rather than a dogmatic adherence to the principle.
  • Experience and anecdotes suggest that both over-application and under-application of DRY can have negative consequences, and that a balanced approach is necessary.