3 ms·
No, you're talking about Hungarian notation, the guide is talking about standardised one-letter names for certain variables.
by baha_man 15y ago
No, you're talking about Hungarian notation, the guide is talking about standardised one-letter names for certain variables.
- michaelchisari 15y agoThe way I'm reading it, they're casting a wider net than Hungarian notation, but it's similar to it.
- pbreit 15y agoIt seems pretty clear to me: "Use one-letter variables"
- michaelchisari 15y agoOn re-reading, you're right. My fault for giving them the benefit of the doubt. One letter variables? I'm a little bit speechless. I don't recommend one letter variables. I don't know if I've ever seen an official style guide that has.
- adbge 15y ago> I don't recommend one letter variables. I don't know if I've ever seen an official style guide that has. Not that familiar with idiomatic Ruby, but using one letter variables as iterators in for loops (and some other things) is pretty idiomatic C: int i; for (i = 0; i < queue_size; i++) queue[i] = get_rarest_peer(t->peer_list);
- kshipley 15y agoThe key modifying phrase was "for short block/method parameters." The authors aren't advocating one letter variables throughout your code, only in situations like: [1, 2, 3].each { |e| puts e } Object.methods.each { |m| "Method is: #{m}" }
- michaelchisari 15y agoEven as such, using full words is barely any more typing, and more readable. [1, 2, 3].each { |value| puts value } Object.methods.each { |method| "Method is: #{method}" } I consider that a better habit to have than using single-character variables. And style guides should be about encouraging the best habits possible.