3 ms·
My mental benchmark for the cost/payoff of indirection is usually > Would this code be easier to read if A) I inlined the code or B) I replaced it with a descr
by DarkWiiPlayer 7y ago
My mental benchmark for the cost/payoff of indirection is usually
> Would this code be easier to read if A) I inlined the code or B) I replaced it with a descriptive function name.
Function could be read as Class or Method if you're dealing with OOP.
One important criterion for this is that other programmers already know the language, not your program. Writing your own function can help to put a meaningful name on a set of behaviors, but it also means the introduction of a new specific set of behaviors the reader needs to keep in the back of their mind. It's kind of similar to Jakob's Law [1] in a way, but applied to source code. (In a way, source code readability in't all that different from UX, if you think about it)
[1] https://lawsofux.com/jakobs-law https://lawsofux.com/jakobs-law