|
|
|
|
|
by bioneuralnet
847 days ago
|
|
My experience exactly. I think the DRK (Don’t Repeat Knowledge) acronym (not my invention) is a better target. Too often people mistake similar structures of code as “repetition”. Instead, if you focus on not repeating the important “knowledge” of your code (algorithms, business rules, etc), it’s easier to avoid the trap of over-abstracting. |
|
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.