|
|
|
|
|
by spion
2012 days ago
|
|
I would omit most information that can be inferred from context so long as context locality is good. Single-letter names are OK for context smaller than 1 line (like lambdas), type information can be omitted for context up to 10 lines (lists etc) and generic functions (filter, concat, inner_join) are better over custom domain functions when the audience consists of other programmers. Abbreviations are best avoided unless they are extremely common and familiar in the specific domain / industry. If they are only ever used within that team and company, that's probably bad. Example here: https://news.ycombinator.com/item?id=25477495 |
|
context also changes with time as other people edit your code. Your single variable name with simple context can balloon in complexity and move around. Don't assume locality is fixed.
Additionally locality wastes precious time. It is preferable to read a variable name and not even need to touch context.
>generic functions (filter, concat, inner_join) are better over custom domain functions when the audience consists of other programmers.
Not true. For filter and innter_join especially the predicate or inner lambda can be intricately complicated and hard to decipher, better to wrap all that complexity in an english name. You save programmer time by having the programmer read an english over deciphering even simple code.
Rule of thumb: It is far easier to read one line of english then it is to read a one line of code. So it is better to allow readers to ascertain meaning from naming over context. You are wasting the programmers time otherwise.