#atom

Evaluating when code duplication might be preferable to premature abstraction

Core Idea: Code duplication, while traditionally discouraged, can sometimes be less harmful than forcing inappropriate abstractions that don't correctly model the problem domain.

Key Elements

Decision Factors

Practical Approach

  1. When in doubt, prefer duplication initially
  2. Look for patterns across 3+ examples before abstracting
  3. Be willing to revert to duplication if an abstraction proves incorrect
  4. Use duplication as a tool to reveal better abstractions

Connections

References

  1. Metz, Sandi. "The Wrong Abstraction." Blog post. Originally from Chainline Newsletter.
  2. Metz, Sandi. RailsConf 2014 "All the Little Things" talk.

#programming #software_design #refactoring #dry_principle


Connections:


Sources: