[Cosmo-dev] Commit 5847

Travis Vachon travis at osafoundation.org
Mon Oct 8 11:11:32 PDT 2007


Hi Matthew

Thanks for the reply!

On Oct 8, 2007, at 10:31 AM, Matthew Eernisse wrote:

>
>
> I guess to someone who really prefers longer, descriptive variable  
> names it makes good sense, but to me it seemed only to create more  
> typing, and actually made it harder to understand. It was easier  
> for me to read before the refactoring, to see that "d" represented  
> in each case "the DOM node container for the current layout item."

For me the problem with terse variable names usually isn't local  
readability, it's the extra layer of difficulty they add to any  
attempt to get a larger picture of the code. I understand that most  
of these short variable names are used as function local variables,  
but since we haven't been terribly principled about concise functions  
that fit in one editor screen this can still be a problem. The dom  
manipulation stuff in general tends to lead to long functions which,  
combined with the changing meaning of "d" can be pretty fragile,  
especially in the face of refactoring.

>
> The searchability/regex argument also makes a fair bit of sense,  
> because regexes can be pretty irritating and tweaky.
>
> In this case though, it doesn't really seem like a trip through the  
> Swamps of Sadness. Unless I'm missing something totally obvious, I  
> think it's actually pretty easy to search for even a terse variable  
> name like "reg," at least in Vim or grep:
>
> Vim:
>
> /reg\W
>
> Grep:
>
> grep -r "reg\W"

The trouble, of course, is formulating the regex. Your example is  
instructive, since it misses several possible uses of "reg":

var x = reg;
if (reg){...}
reg+=1;

While at least one of these violates our coding standards I don't  
think I would be comfortable enough that every contributor has  
followed these to the letter to rule them out when refactoring/  
trying to understand how the code works, especially as that list  
grows. While I'm sure we could come up with a regex that found every  
possible use of "reg" in a Javascript module (it's a formal language  
after all!) I'm not sure it's quite so trivial.

Overall I don't think any of these are giant issues, they just  
happened to combine in a bit of a perfect storm last Friday.

Thanks again for the discussion!

-Travis




More information about the cosmo-dev mailing list