Copy + Paste More Code
June 03, 2019
When is it the right decision to copy and paste a block of code?
-
Only two, slightly differing use cases for that block (when the third occurs, consider refactoring all three)
-
The originating block is working and cost of failure is high
-
Bringing a piece of an external library into your codebase
-
Refactoring would create an unnecessary, heavy abstraction
-
Prototyping or writing throwaway code.
Copy and paste doesn’t create bad code. Bad programmers create bad code.
Jeff Atwood
Written by Brent Baumgartner. He lives and works in Charlottesville at TwinThread, building data-driven products. You should follow him on Twitter