3 ms·
Agreed. I’m fine if you want to extract sub-parts of the function “generateId”, “hashX”, “lookupY” and have 2 functions that call 2 out of 3 (different 2) of th
by joshstrange 3y ago
Agreed. I’m fine if you want to extract sub-parts of the function “generateId”, “hashX”, “lookupY” and have 2 functions that call 2 out of 3 (different 2) of the shared helpers/functions, just don’t create a single function that if/else’s the 2 paths.
Better put, if you have logic A, B, C, D and 2 code paths:
Code path 1: ABD
Code path 2: ACD
Then you should have:
Function 1: ABD
Function 2: ACD
Not
MegaFunction: A (if X then B) (if !X then C) D
Too many people see a common “A” and “D” and rush to have a common function that if/else’s the B/C.