Re:Write code. Not too much. Mostly functions.
by IggleSniggle on Tuesday December 22, 2020 @12:58AM
(#25503376)
Here’s some counter-argument psuedo-code:
// v1, mixing layers of abstraction
x = a if exists, else first()
y = b if exists, else second()
result = third(x,y)
// v2, abstraction
result = getResult(a,b)
In v1, we have the semantics of x and y, so we understand that a “result” is obtained through the acquisition of x and y. Whether we need to understand this is a judgement call. But v2 opens a different “failure to understand” modality: “getResult” is so blackboxed that the only thing it really accomplished is indirection, without improving readability.
I love Clean Code, but I think it sometimes prematurely favors naming a new function and the resultant indirection.
I love Clean Code, but I think it sometimes prematurely favors naming a new function and the resultant indirection.