3 ms·
> the top function is fairly obviously harder to understand What? It’s one conditional branch, and in that branch there are three “high-level” operations, all
by jagged-chisel 3y ago
> the top function is fairly obviously harder to understand
What? It’s one conditional branch, and in that branch there are three “high-level” operations, all named very well (assuming they’re correct names.) What’s harder to understand here?
I spent much longer understanding what was going on in the second function.
Further, the variable name “paid_today” is terrible because the result of the condition does not tell us that the employee was indeed paid, but rather that they should be paid. They’re not paid until after the code in the conditional branch runs.
Extracting this information to its own function is certainly an improvement (even if the function name still isn’t great.)
I would have liked the article to spend more time making the second function take less time to understand.