|
|
|
|
|
by mosburger
56 days ago
|
|
I think there is often tension between DRY and "thing should do only one thing." E.g., I've found myself guilty of DRYing up a function, but the use is slightly different in a couple places, so... I know, I'll just add a flag/additional function argument. And you keep doing that and soon you have a messed up function with lots of conditional logic. The key is to avoid the temptation to DRY when things are only slightly different and find a balance between reuse and "one function/class should only do one thing." |
|
One of my favorite things as a software engineer is when you see the third example of a thing, it shows you the problem from a different angle, and you can finally see the perfect abstraction that was hiding there the whole time.