Duplication is far cheaper than the wrong abstraction
Similarly:
Write code that is easy to delete, not easy to extend.
You can't know the best abstraction up front. When writing code, it's okay to be messy, but you must then clean it up before you consider it 'complete'.
Copy-paste code first, and then [[DRY]] it up after once you fully understand it. Write up a large function, then break it into pieces.
Before adding conditional logic to an abstracted piece of code, try working backwards:
Just because existing code is already there, doesn't mean it's correct, nor the best it could be. [[20221202011240-existing-code]]
Keywords: 'Premature abstraction'
[[20211115112656-rule-of-three]] [[20200307105301-dry]]
https://sandimetz.com/blog/2016/1/20/the-wrong-abstraction https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to https://kentcdodds.com/blog/aha-programming
[[abstraction]] [[concepts]] [[engineering]] [[refactoring]]