News for hackers. Stuff that matters.
Re:It's probably time to stop recommending Clean Code (2020) by Chris2048 on Tuesday May 25, 2021 @01:01PM (#27279349)
> figure out the abstraction after you need something a 3rd time

That's still too much of a "rule".

Whenever I feel (or know) two functions are similar, the factors that determine if I should merge them:

- I see significant benefit too doing so, usually the benefit of a utility that saves writing the same thing in the future, or debugging the same/similar code repeatedly.

- How likely the code is to diverge. Sometimes I just mark things for de-duping, but leave it around a while to see if one of the functions change.

- The function is big enough it cannot just be in-lined where it is called, and the benefit of de-duplication is not outweighed by added complexity to the call stack.

There are no comments on this comment yet.