4 ms·
> Local variable names should be short It depends on how complex the functions/algorithms are, and what mental references can be assumed. Local variable names
by yobbo 4y ago
> Local variable names should be short
It depends on how complex the functions/algorithms are, and what mental references can be assumed.
Local variable names help explain how/what the function does. Function names and context might only be enough to explain the intended output.
- karmakaze 4y agoYes it depends on context, but you should be able to lean on the existing context to shorten local names. E.g. a lambda param dealing with a collection of xxx_yyy_zzz_items can just be called item or xyz_item (if there are other item-like things nearby). Only lengthen the method body or take up vertical space with long names if it adds more than it detracts from reading and understanding the whole.