DEV Community

Discussion on: Copy And Paste is violation law of DRY?

Collapse
 
lloydfranklinsmith profile image
Lloyd Franklin Smith

No, but also yes,
2 pieces of code could be doing the same thing for different reasons and we might not want changes to the way our first piece of code to change how our second piece of code behaves. Writing the same code multiple times but for different reasons isnt repeating yourself.

If however, we find ourselves reusing a piece of code that would have to be changed at all the places we pasted it into for the same reason we are violating dry and making our work more difficult and our code harder to change/maintain.