2 ms·
We have a tendency sometimes to prematurely abstract pieces of code. I am okay with copy-pasting code but after the second or third copy-paste, you should prob
by hk1337 4y ago
We have a tendency sometimes to prematurely abstract pieces of code.
I am okay with copy-pasting code but after the second or third copy-paste, you should probably at least consider asking, “Should I abstract this into its own function?”
- WorldMaker 4y agoOne way this is formulated is the "Rule of 3 for Abstractions": One copy of something is YAGNI. You aren't going to need it (an abstraction). Two copies of something are coincidence. It's fine to copy and paste and leave it that way. Three copies of something are finally a pattern. At least three copies are when you start to really see what sort of abstraction that you need to handle the pattern.