|
|
|
|
|
by TeMPOraL
5090 days ago
|
|
> New Function Cut the code. Place inside function declaration. create call to function in old and new places. And also: decouple code from it's context. Rename variables. Rename the function. Possibly add a new module for it. Moving repeated code to a function rarely just about relocating a piece of code. Quite often (especially if you have cross-file code repetition) you identify abstraction, which is a Serious Business (TM), requiring at least to think about where to introduce it, how to fit it into existing mental model of the program, and while we're at it, how to make it useful for code that you'll be writing next week, because it would be a waste not to do that now. It's not that difficult and it's quite rewarding, but it also takes significantly more time than just copy-pasting and carrying on. |
|