#atom

When code abstractions become harmful over time

Core Idea: Code abstractions can evolve from helpful simplifications into harmful complexity as requirements change and conditional logic accumulates.

Key Elements

Evolution Pattern

  1. Initial abstraction created to eliminate duplication
  2. New requirements emerge that don't perfectly match the abstraction
  3. Parameters and conditionals added to handle exceptions
  4. Additional requirements lead to more parameters and conditionals
  5. Code becomes complex and difficult to maintain

Recovery Process

  1. Re-introduce duplication by inlining abstracted code back into every caller
  2. Within each caller, preserve only the code needed for that specific use case
  3. Delete unnecessary code from each caller
  4. Examine the resulting code for new, more appropriate 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 #refactoring #software_design #technical_debt


Connections:


Sources: