|
|
|
|
|
by HarrietJones
5083 days ago
|
|
I don't really understand why people think that copy pasting takes less time than making a new function. Your function may need some refactoring to make sense, but just cutting that block of text out and then calling it in a function can usually be done in seconds. Copy Pasting:
Copy the code. Paste in new place. Change variable names to fit in new place. New Function
Cut the code. Place inside function declaration. create call to function in old and new places. |
|
Copy-pasting and just dropping the useless parts is easier than making a new function, because you have to think about how to make the new function apply to both cases (the easiest way is "well, I'll just put a switch in the parameters and if statements", but it doesn't really lead to better code).