RichardOnRails wrote: [...] > As far as underscoring vs. Camel-case goes, I know Rubyists' > preference, but I bow to Shakespeare's notion that "a rose by any > other name is just as sweet." It doesn't work that way in programming. Good naming practices are an important part of readable code. This is particularly so in a language like Ruby, in which "literate" interfaces are common. I spent a couple decades writing/ > maintaining Window's application for clients using C and C++, so I've > a fondness for Polish notation (at least that's what I think it was > called.) Polish Notation is ¥Ê¡Ökasiewicz-style prefix notation, rather like what's used in Lisp. You mean Hungarian Notation. But in any case, *you've been had*. Hungarian Notation as developed by Charles Simonyi is extremely useful in non-OO code (I've used it in PHP with great success). Hungarian Notation as the term is usually understood is a very stupid thing indeed, which has unfortunately been foisted by Microsoft on huge numbers of Windows programmers who really should know better. :) It is (at best) marginally useful in statically typed languages like C, and downright misleading in dynamically typed languages like Ruby. The difference is that Simonyi's original concept encodes information *outside the scope* of the variable's type (which, after all, the interpreter or compiler already knows about). For example, in a mapping system, you might have kmDistance and ftCorrection. It's entirely clear from those names that kmDistance + ftCorrection would be adding kilometers and feet without a conversion, and thus it's immediately clear that that operation is wrong. OTOH, legions of misled Windows developers would simply call those two variables intDistance and intCorrection, incorporating no new useful information and making the names harder to read. For more on the misuse of Hungarian Notation, please see http://www.joelonsoftware.com/articles/Wrong.html (Simonyi's original is there called Apps Hungarian, while the popular perversion is called Systems Hungarian). There's also some interesting discussion at http://c2.com/cgi/wiki?HungarianNotation , if you can wade through the disorganization. Systems Hungarian, BTW, is bad enough in C, where you should be able to refer to your variable declarations. If your functions are so long that you can't refer easily to declarations, then you need to refactor to shorter methods for overall readability anyway -- methods should be short. Systems Hungarian has no use at all in Ruby, since although objects are typed, variables are not, so it's perfectly possible to do intValue = 1 # later intValue = {:foo => 'bar'} Even Apps Hungarian is not a great idea in OO code. Instead, just use the type system, so that distance would be a Kilometer object and correction would be a Foot object. Kilometer.+(foot) could then either raise an exception or invoke a conversion. In summary, then, Hungarian Notation of either sort is inappropriate in Ruby. Drop the habit. > Typing extra hyphens vs pressing the shift key lets me write > code faster, and the a/s/h prefix for arrays/strings/hashes helps me > avoid a lot of interpreter complaints. If you care about removing characters from variable names, start with removing the Hungarian warts. As I explained above, they serve no useful purpose in Ruby at all. And I have to say, I don't find wordsRunTogether as easy to read as words_with_underscores -- the underscores look more like spaces and delineate the words better to my eye. WouldYouRatherReadThisClauseHere, or would_you_rather_read_this_clause_here? In any case, "snake_case" is the prevailing style in Ruby, and virtually every Ruby library uses it (including the standard library and Rails) -- your code will look strange if you don't follow suit. The examples in Programming Ruby tend to use camelCase, but that's more of a flaw in the book than an indicator of Ruby practice. > And fellow programmers of > almost any stripe knows what I mean. Finally, I retired curmudgeon, > and you know how we old folks are :-) Age is not an excuse. If you're going to learn a language, take the time to learn the idioms and the "spirit" of the language, not just the bare essentials of syntax. I've seen far too many people try to write C, Java, or PHP in Ruby -- avoid the temptation! > > Seriously, your insight was very helpful and will help me avoid a > bunch of wasteful code. > > Best wishes, > Richard Best, -- Marnen Laibow-Koser http://www.marnen.org marnen / marnen.org -- Posted via http://www.ruby-forum.com/.