[Engineering] A Guide to Naming Variables

Kevin Smith ksmith at wikimedia.org
Mon May 16 20:42:39 UTC 2016


I agree with most of that article.

In the section "Move Simple Comments Into Variable Names", I was surprised
the author didn't mention the #1 reason to do so: It's too easy to forget
to update a comment when the meaning of the variable changes. The later
section "Use Longer OTVs to Explain Confusing Code" is another great
example of clearer code reducing/eliminating the need a comment.

I'm not sold on avoiding cliches like "count" and "result", if you're
keeping idioms like "i" and "n".

Sidebar anecdote: In my second-ever paid programming job, we were forced to
use only letter+digit variable names, like A2 and G6, because our
(interpreted) program had to fit in 32K of RAM, and longer variable names
would have consumed precious space. It was an awesome early lesson on the
power of meaningful variable names.



Kevin Smith
Agile Coach, Wikimedia Foundation


On Tue, May 3, 2016 at 4:24 AM, Filippo Giunchedi <fgiunchedi at wikimedia.org>
wrote:

> http://a-nickels-worth.blogspot.ie/2016/04/a-guide-to-naming-variables.html
>
> (full disclosure: from a former colleague)
>
> _______________________________________________
> Engineering mailing list
> Engineering at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/engineering
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.wikimedia.org/pipermail/engineering/attachments/20160516/23b0508b/attachment.html>


More information about the Engineering mailing list