[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More Coding Convention



Bjarke Hammersholt Roune wrote:

>In the coding convention doc, it says that it is free for people to
>indicate that variables are member variables either by prefixing "m_", or
>making the first letter of the variable upper case.

Not the first letter. The entire symbol should be in
lowercase_with_underscores as opposed to StartAllWordsWithCaps.
The requirement is that members and locals should be clearly
distinguishable.

>IMHO, that's not a very good idea. That way, you'd have to check all the
>time what convention was used by the guy who first wrote the class. That's
>not very cool for readability.

There won't be more than one style of this in a given library. Official
coding standard or not, people who work on the same piece of code do settle
on a common basic style. No need for further regulation here.

>-Suppose I write this "ThisIsSomething" in my code. Now, is this a
>member-variable, or is it a function or a method? I can't tell you, I'll

Functions and methods have () brackets after the symbol. No problem.

>- Try and find the 4 variables in in these variable that are non-member
>functions:
>
>someVariable someVariable someVariable someVariable someVariable
>someVariable
>   someVariable someVariable someVariable someVariable SomeVariable
[...]


>Now try and do the same for this:
>
>someVariable someVariable someVariable someVariable someVariable
>someVariable
>   someVariable someVariable someVariable someVariable m_someVariable
[...]


And for this:

>SomeVariable SomeVariable SomeVariable SomeVariable SomeVariable
>SomeVariable
>   SomeVariable some_variable SomeVariable SomeVariable SomeVariable

It's clear enough IMO.


>-Try look at this and spot the variable declaration
>
>class ppSomeClass
>{
>    int SomeMemberThatReallyIsAMethod();
>    int SomeMemberThatIsSomething();
>    int SomeMemberThatsSomething;
>    int SomeMemberThatsSomethingReally()
>}
>
>Now do the same for this:
>
>class ppSomeClass
>{
>    int SomeMemberThatReallyIsAMethod();
>    int SomeMemberThatIsSomething();
>    int m_someMemberThatsSomething;
>    int SomeMemberThatsSomethingReally()
>}
>
>See what I mean? 

No ;)
I know that I have to distinguish vars from functions, so I automatically
search for round brackets. Actually I didn't realize that the two examples
were different until I was done. ;)


	Christian
--

Drive A: not responding...Formatting C: instead