Comment on monumentale

<- View Parent
kryptonianCodeMonkey@lemmy.world ⁨2⁩ ⁨days⁩ ago

Concise readability is usually my goal. Like if I have 12 lines of code with a loop and some nested conditionals that takes a bit of thought to parse, it probably is better to move that to a function with a descriptive name like, “size, depth = get_directory_size_and_depth(filepath)”, that way the function name itself functions as it’s own comment/documentation, and, if you don’t really care about how the size and depth is aggregated, it abstracts that process onto one line of code that the reader can instantly understand without parsing anything. That goes doubly so when the function is generic like get_directory_size_and_depth(filepath) would be, and can be put in its own shared utilities file.

source
Sort:hotnewtop