This is an ignorant question to pose, but here I go anyway.
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ? Since Ruby is big with "Duck Typing", would
using Hungarian Case be more of a verbal obstacle than a more
descriptive variable. What about varying degrees, such as for integers,
doubles, strings, and o for Objects, but not exhaustive?
(For those who don't know about Hungarian typing, it would similar to an
integer you would name "counter" being named "iCounter" or a variable
you would normally name "duck" be "oDuck" because it is an object)
I know this is a rather old topic to be bringing into a newer
technology, but I'm curious on what your all's take is on this.
This is an ignorant question to pose, but here I go anyway.
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ? Since Ruby is big with "Duck Typing", would
using Hungarian Case be more of a verbal obstacle than a more
descriptive variable. What about varying degrees, such as for integers,
doubles, strings, and o for Objects, but not exhaustive?
(For those who don't know about Hungarian typing, it would similar to an
integer you would name "counter" being named "iCounter" or a variable
you would normally name "duck" be "oDuck" because it is an object)
I know this is a rather old topic to be bringing into a newer
technology, but I'm curious on what your all's take is on this.
Tagging variables based on the class of the objects to which they
refer seems to me to be aggressively anti-duck-typing. It's also ugly I think I'll stick with the traditional style.
David
--
David A. Black
dblack@wobblini.net
"Ruby for Rails", from Manning Publications, coming April 2006!
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ? Since Ruby is big with "Duck Typing", would
using Hungarian Case be more of a verbal obstacle than a more
descriptive variable. What about varying degrees, such as for integers,
doubles, strings, and o for Objects, but not exhaustive?
IMHO, I've never seen the use for it. As far as I know, variable names should be able to tell you what it holds at a glance. I am however of the old school of programming and hence, might not be the best person to give my opinion but none the less, I still find that Hungarian Notation is a big waste of time.
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ? Since Ruby is big with "Duck Typing", would
using Hungarian Case be more of a verbal obstacle than a more
descriptive variable. What about varying degrees, such as for integers,
doubles, strings, and o for Objects, but not exhaustive?
(For those who don't know about Hungarian typing, it would similar to an
integer you would name "counter" being named "iCounter" or a variable
you would normally name "duck" be "oDuck" because it is an object)
See this article on what Hungarian notation really was meant to help
with (it was meant to provide semantic type (this value is used for X)
not data type (this value is an int)).
I assume you know this, but just to be sure, Joel on Software has a semi-famous article about the virtues of Hungarian Notation:
If you make it all the way to the end of that, it talks about how the notation is intended to show a "kind", not "type". When used that way, I can't decide if it interferes with Duck Typing or not... A great example is escaping me.
It may indeed be useful, but it is hard to argue that it isn't ugly.
James Edward Gray II
···
On Jan 20, 2006, at 12:21 PM, Zach wrote:
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ?
The term is actually Apps Hungarian and System Hungarian naming. What
you show (iCounter) is System Hungarian and is not what the originator
of Hungarian naming wanted, promulgated improperly through (primarily)
Charles Petzold and Microsoft MSDN documentation.
More useful would be something like "cbCounter" which means "count of
bytes called Counter". It encodes the purpose of the variable instead of
the type of the variables. However, in Ruby, it'd probably be more
idiomatic to simply use "byte_counter".
-austin
···
On 20/01/06, Zach <zacharooni@comcast.net> wrote:
This is an ignorant question to pose, but here I go anyway.
Does anyone see advantages to using Hungarian Case to variable names
in Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ? Since Ruby is big with "Duck Typing",
would using Hungarian Case be more of a verbal obstacle than a more
descriptive variable. What about varying degrees, such as for
integers, doubles, strings, and o for Objects, but not exhaustive?
(For those who don't know about Hungarian typing, it would similar to
an integer you would name "counter" being named "iCounter" or a
variable you would normally name "duck" be "oDuck" because it is an
object)
I know this is a rather old topic to be bringing into a newer
technology, but I'm curious on what your all's take is on this.
Tagging variables based on the class of the objects to which they
refer seems to me to be aggressively anti-duck-typing. It's also ugly I think I'll stick with the traditional style.
Class and object names should be clear enough to reflect what that are and what they are for. Ideally no one is still trying to conserve space or finger power by naming things 'c' or 'x' or 'ssn' except for very targeted use (e.g., short-scoped disposable values).
If you have a variable that refers, say, to an instance of a class representing a hotel reservation, name it as such:
current_hotel_reservation. Not hr_curr or the like.
Actually I hadn't read this article, but I've heard of Joel. Thanks to the both of you for pointing it out.
-Zach
"I assume you know this, but just to be sure, Joel on Software has a semi-famous article about the virtues of Hungarian Notation:
If you make it all the way to the end of that, it talks about how the notation is intended to show a "kind", not "type". When used that way, I can't decide if it interferes with Duck Typing or not... A great example is escaping me.
It may indeed be useful, but it is hard to argue that it isn't ugly.
James Edward Gray II "
Mike Fletcher wrote:
···
Zach wrote:
[...]
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ? Since Ruby is big with "Duck Typing", would
using Hungarian Case be more of a verbal obstacle than a more
descriptive variable. What about varying degrees, such as for integers,
doubles, strings, and o for Objects, but not exhaustive?
(For those who don't know about Hungarian typing, it would similar to an
integer you would name "counter" being named "iCounter" or a variable
you would normally name "duck" be "oDuck" because it is an object)
See this article on what Hungarian notation really was meant to help with (it was meant to provide semantic type (this value is used for X) not data type (this value is an int)).
I've another question I'd like to pose the Ruby community. Coming from a Java background, so I'm rather used to "camelCase" as opposed to what looks to be the standard "ruby_case". (For those who don't know, If a method is java was named "DoSomething" it would be called "doSomething" in Java, and likewise "do_something" in Ruby.)
Arguments I've personally witnessed against Camel Case is Acronyms. If I have an "ABC" in Camel Case it I'd have to would be to break up the acronym like "aBC" if it appears at the beginning of the word. A lot of people try to push the word to the end, others say to have the whole acronym as lowercase "abc", but I think that is just a workaround for the problem not a solution.
Once I started programming in ruby, I was a little surprised at the use of the underscore, but I'm wondering the sentiments of the programmers out there. Do you prefer word breaks by underscore or case? Does is look more readable? Does anything else irk you with Camel Case and/or Ruby's preference?
Not trying to incite flame_wars or the like, looking for honest opinions.
Now the compiler is tracking all this junk for you. I realize this is the land of duck-typing, but I think if the type-inference is good enough, you can have your cake and eat it too.
···
On Jan 20, 2006, at 2:13 PM, James Edward Gray II wrote:
On Jan 20, 2006, at 12:21 PM, Zach wrote:
Does anyone see advantages to using Hungarian Case to variable names in
Ruby, or do you think it may hinder as some people call "accidental
abstraction" [Bill Davis] ?
I assume you know this, but just to be sure, Joel on Software has a semi-famous article about the virtues of Hungarian Notation:
If you make it all the way to the end of that, it talks about how the notation is intended to show a "kind", not "type". When used that way, I can't decide if it interferes with Duck Typing or not... A great example is escaping me.
It may indeed be useful, but it is hard to argue that it isn't ugly.
I thought there was another issue. Getters/Setters like getBlah(), setBlah(). If it's getABC() or setABC(), frameworks like Java Server Faces require you to just use the relevant information, so you end up entering. "obj.aBC".
-Zach
Zach wrote:
···
Alrighty,
I've another question I'd like to pose the Ruby community. Coming from a Java background, so I'm rather used to "camelCase" as opposed to what looks to be the standard "ruby_case". (For those who don't know, If a method is java was named "DoSomething" it would be called "doSomething" in Java, and likewise "do_something" in Ruby.)
Arguments I've personally witnessed against Camel Case is Acronyms. If I have an "ABC" in Camel Case it I'd have to would be to break up the acronym like "aBC" if it appears at the beginning of the word. A lot of people try to push the word to the end, others say to have the whole acronym as lowercase "abc", but I think that is just a workaround for the problem not a solution.
Once I started programming in ruby, I was a little surprised at the use of the underscore, but I'm wondering the sentiments of the programmers out there. Do you prefer word breaks by underscore or case? Does is look more readable? Does anything else irk you with Camel Case and/or Ruby's preference?
Not trying to incite flame_wars or the like, looking for honest opinions.
Once I started programming in ruby, I was a little surprised at the use of the underscore, but I'm wondering the sentiments of the programmers out there. Do you prefer word breaks by underscore or case? Does is look more readable? Does anything else irk you with Camel Case and/or Ruby's preference?
I used to do camelCase, mainly when I programmed mostly in Python. A while ago I switched over to ruby_case, and I prefer it over camelCase. To me, the underscore just makes method names and variable names easier to read.
HTH,
Jamey Cribbs
Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.
Once I started programming in ruby, I was a little surprised at the
use of the underscore, but I'm wondering the sentiments of the
programmers out there. Do you prefer word breaks by underscore or
case? Does is look more readable? Does anything else irk you with
Camel Case and/or Ruby's preference?
Not trying to incite flame_wars or the like, looking for honest opinions.
Under_scoring is the best thing after using-hyphens, which is not
possible in Ruby without dirty tricks.
Well, I started out as a C programmer many years ago, and after
several other languages, I ended up doing Java for much of the last 5
years and adopted the Sun Java coding conventions. When I started
learning Ruby, its idioms, and its coding conventions, I was very
happy to see "ruby_case" which is what I did in C as far back as 16
years ago.
···
On 1/20/06, Zach <zacharooni@comcast.net> wrote:
Alrighty,
I've another question I'd like to pose the Ruby community. Coming
from a Java background, so I'm rather used to "camelCase" as opposed to
what looks to be the standard "ruby_case". (For those who don't know, If
a method is java was named "DoSomething" it would be called
"doSomething" in Java, and likewise "do_something" in Ruby.)
Arguments I've personally witnessed against Camel Case is Acronyms. If I
have an "ABC" in Camel Case it I'd have to would be to break up the
acronym like "aBC" if it appears at the beginning of the word. A lot of
people try to push the word to the end, others say to have the whole
acronym as lowercase "abc", but I think that is just a workaround for
the problem not a solution.
Once I started programming in ruby, I was a little surprised at the use
of the underscore, but I'm wondering the sentiments of the programmers
out there. Do you prefer word breaks by underscore or case? Does is look
more readable? Does anything else irk you with Camel Case and/or Ruby's
preference?
Not trying to incite flame_wars or the like, looking for honest opinions.
I've another question I'd like to pose the Ruby community. Coming from a Java background, so I'm rather used to "camelCase" as opposed to what looks to be the standard "ruby_case". (For those who don't know, If a method is java was named "DoSomething" it would be called "doSomething" in Java, and likewise "do_something" in Ruby.)
Arguments I've personally witnessed against Camel Case is Acronyms. If I have an "ABC" in Camel Case it I'd have to would be to break up the acronym like "aBC" if it appears at the beginning of the word. A lot of people try to push the word to the end, others say to have the whole acronym as lowercase "abc", but I think that is just a workaround for the problem not a solution.
Once I started programming in ruby, I was a little surprised at the use of the underscore, but I'm wondering the sentiments of the programmers out there. Do you prefer word breaks by underscore or case? Does is look more readable? Does anything else irk you with Camel Case and/or Ruby's preference?
Not trying to incite flame_wars or the like, looking for honest opinions.
-Zach
I use a somewhat modified version of the camelCase to fit my needs. It's not that I don't like other methods, I've just been used to this one and that's it. I'm sure other methods are just as good, but the thing is, no matter what language I use, my styling is always the same. Even when I'm web programming. It's just a matter of pref, as usual.
I've another question I'd like to pose the Ruby community. Coming
from a Java background, so I'm rather used to "camelCase" as opposed to
what looks to be the standard "ruby_case". (For those who don't know, If
a method is java was named "DoSomething" it would be called
"doSomething" in Java, and likewise "do_something" in Ruby.)
Arguments I've personally witnessed against Camel Case is Acronyms. If I
have an "ABC" in Camel Case it I'd have to would be to break up the
acronym like "aBC" if it appears at the beginning of the word. A lot of
people try to push the word to the end, others say to have the whole
acronym as lowercase "abc", but I think that is just a workaround for
the problem not a solution.
Once I started programming in ruby, I was a little surprised at the use
of the underscore, but I'm wondering the sentiments of the programmers
out there. Do you prefer word breaks by underscore or case? Does is look
more readable? Does anything else irk you with Camel Case and/or Ruby's
preference?
Not trying to incite flame_wars or the like, looking for honest
opinions.
The big thing is that Ruby attaches semantic meaning to the naming
scheme: all constants must start with an uppercase letter, so your
classes and modules have CamelCaseNames. Because of this, seeing
something like obj.MethodName or even obj.methodName causes a ruby
programmer an involuntary double-take to ensure it indeed refers to
a method, not a constant. For this reason (and others that have been
battled over pretty much since the keyboard was invented), it is
preferred that the following is used:
* Classes and modules use CamelCase
* Constants use ALL_CAPS
* Methods and variables use underscored_names
Japanese readers find the underscore more readable. I prefer
snake_case, personally.
-austin
···
On 20/01/06, Zach <zacharooni@comcast.net> wrote:
Once I started programming in ruby, I was a little surprised at the use
of the underscore, but I'm wondering the sentiments of the programmers
out there. Do you prefer word breaks by underscore or case? Does is look
more readable? Does anything else irk you with Camel Case and/or Ruby's
preference?
If you have a variable that refers, say, to an instance of a class representing a hotel reservation, name it as such:
current_hotel_reservation. Not hr_curr or the like.
Personally, I think that there is a place for short names as I find them much more readable. Verbosity can be a real impediment to readability.
···
--
-mark.
----------------------------------------------------
Mark Probert probertm at acm dot org
----------------------------------------------------