Re:Ask HN: If your code no longer makes sense to you, do you...
by extasia on Sunday July 02, 2023 @06:29PM
(#36566469)
Interesting. I'm quite the opposite in that I'll try pretty hard to avoid unnecessary allocations. In the case of your example I'd do something like:
variable = foo(bar(baz(stuff)));
// baz stuff
// then bar the result
// which we finally foo.
I primarily write python which can't optimize out the allocations so that might influence this.
I sometimes code out "in long' if I feel it is necessary. That is, I deliberately add extra lines to 'show my working'. As in, perhaps:
might possibly be laid out as to show how and why a particular result is generated, if I feel the original code is too abstruse to see quickly why it is so.Yes, there is a (usually) negligible time cost in the running of the program that might even be fixed by an optimising compiler. But I will save a lot more time than that for myself and any other programmer in the future when maintenance time comes around.