From: ptkwt@... (Phil Tomson) Date: 2004-03-24T08:14:29+09:00 Subject: Re: Need some advice on PickAxe II In article , Simon Strandgaard wrote: >On Wed, 24 Mar 2004 02:27:23 +0900, Ben Giddings wrote: >> Simon Strandgaard wrote: >>> I _avoid_ libraries which uses camelCase, luckily many of them >>> provide underscore aliases. Thus it would be really nice if Ruby2 enforced >>> underscores for varnames + methodnames. I know this may be a religious >>> subject... >> >> Trying to understand your religion here. If both methods and variables >> are named with underscores, not camel case how do you distinguish beween >> a method that instructs something to read a certain number, and a >> variable which keeps track of how many times something was read. >> read_number vs. read_number. >> >> If you name the method "readNumber" it is clear that it's a method, and >> that "read_number" is the variable. That's why I think >> camelCaseWithLeadingLowercase is better for methods. >> > >In Ruby I don't feel a need to distinguish between methods and variables. >However in C++ I do use CamelCase to identify functions and under_scores to >identify variables, but thats because functions in C++ needs to be >supplied a (); suffix. > >In Ruby there is no need for a (); suffix. A few times I have found myself >changing a variable into a method. I didn't have to change anything, >it made me relieved. Not only that, but the attr_* methods turn variables into methods, so that if you decide to use CamelCase for method names and under_score for variables you'll eventually run into a conflict in your convention when you need an accessor for your variable_name. > >Why distinguish between methods and variables ? Probably shouldn't, however we do tend to use CamelCase for ClassNames (which I do prefer) and ClassNames are constants so maybe we should just distinguish between Constants and everything else. Phil