7 ms·
Isn't this a bit of a strawman, though? All too often, you instead get the likes of: a = subOperationA(a, b, c, d, e, f, g, h, i) b = subOperationB(a,
by taeric 10y ago
Isn't this a bit of a strawman, though? All too often, you instead get the likes of:
a = subOperationA(a, b, c, d, e, f, g, h, i)
b = subOperationB(a, d, e, f, g, h, i, j, k)
c = subOperationC(d, e, f, g, h, i, j, k, l)
return c
And then some poor fool breaks each of those up into about 8 functions each. So, you click into subOperationA to find it is subOperationAa chaining to subOperationAb,....
My gripe is when we argue against having the full solution in your mind as you work the pieces. Logically, it makes sense to reduce everything down to named things. Cognitively, that is expensive.
And yes, I'm responding with an equally opposing strawman. I am beginning to reject that there is a "one true answer."
- saynsedit 10y agoThis is not really about subroutines, it's about abstractions. Good abstractions decrease cognitive load, bad ones increase it. The one true answer is to aim for good abstractions, and not factor code into subroutines at arbitrary boundaries. For example, adding two n-length vectors is a good abstraction ("vector_add"). Adding two n-length vectors then multiplying the magnitude of the result by 3 is a bad abstraction.
- sbov 10y ago> I am beginning to reject that there is a "one true answer." There are basically no guidelines that always apply. Novices should stick to them, and people with more experience can recognize when they don't apply.
- Retra 10y agoIt's usually very safe and convenient to not inline pure functions. At least while debugging.
- jschwartzi 10y agoThe sooner you learn that there are no hard and fast rules, the easier life will be for your teammates and for anyone you try to lead. Most of the conflicts I have with my lead boil down to him wanting to resolve a decision using a hard always/never dichotomy, and me wanting to use my best judgement.