news.volyx.in

Prefer duplication over the wrong abstraction (2016) (sandimetz.com)

541 points by rafaepta · 21 days ago · 354 comments on HN

Article summary

The article discusses the concept of the 'wrong abstraction' in software development, where an abstraction that was once useful becomes outdated and causes more problems than it solves. The author argues that in such cases, it's better to reintroduce duplication and start anew, rather than trying to preserve the existing abstraction. This approach can lead to simpler and more maintainable code. The author also notes that the pressure to preserve existing code can be driven by the 'sunk cost fallacy', where the effort invested in the code makes it harder to abandon.

Main themes

  • Wrong abstraction
  • Code duplication
  • Software maintainability
  • Sunk cost fallacy
  • Refactoring

What commenters say

  • Some developers believe that microservices can help avoid the problem of wrong abstractions, but others argue that this approach can lead to a distributed monolith.
  • The use of trendy frameworks and libraries can lead to wrong abstractions and make code maintenance more difficult.
  • Code duplication is not always a bad thing, and in some cases, it can be preferable to a wrong abstraction.
  • The right abstraction can be far cheaper than code duplication, but it's not always easy to determine what the right abstraction is.
  • Some developers think that functional programming can help reduce code duplication and abstraction issues.
  • The pressure to preserve existing code can come from the desire to avoid wasting the effort invested in it, rather than a genuine need to keep it.
  • Refactoring can be a difficult and risky process, especially when dealing with large and complex codebases.
  • The use of large language models to generate code can lead to issues with maintainability and abstraction, and requires careful scrutiny and review.