|
|
|
|
|
by asto
5083 days ago
|
|
There is usually an upfront cost of time and/or effort. The choice comes down to copy-pasting what you need everywhere or put effort into making a generic function that you can put in one place. If you are working against an impossible deadline, option 1 seems very enticing. In the long run, you are right, the effort is much less to maintain a well thought out codebase. |
|
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.