www.digitalmars.com         C & C++   DMDScript  

D - naming conventions

reply "imr1984" <imr1984 hotmail.com> writes:
Can someone explain to the me the rationing of the D naming convention,
where names start with a lower case and each new word has a capital, eg:

int lovelyInteger;

I personally think that looks sloppy.
Jan 03 2004
next sibling parent J Anderson <REMOVEanderson badmama.com.au> writes:
imr1984 wrote:

Can someone explain to the me the rationing of the D naming convention,
where names start with a lower case and each new word has a capital, eg:

int lovelyInteger;

I personally think that looks sloppy.
  
Oh, no not a style war. What looks *sloppy* to one person, looks good to another. I think D may have been following the java style (which follows other languages in that style, no doubt). My own reasons for liking this format are: * Because shift requires more button clicks. Underscore is even worse. * To train my brain to know what comes first in D. * Most of my local variables aren't two words (and I don't capital them either). * Most variables aren't nouns (and you type more variables then anything else) * For differentiating classes/struct/union/enum from local variables, without using *ugly* hungarian notation. Personally, I also use this for differenting members (first capital) from local variables. And so on.... But there is no right way, you've just gotta pick one and stick to it. Note that classes/struct/union/enum don't start with lower case, but I guess you know that.
Jan 03 2004
prev sibling parent reply Andy Friesen <andy ikagames.com> writes:
imr1984 wrote:
 Can someone explain to the me the rationing of the D naming convention,
 where names start with a lower case and each new word has a capital, eg:
 
 int lovelyInteger;
 
 I personally think that looks sloppy.
The Java convention is probably the single most widely used convention today. D could do worse. *cough*Hungarian*cough* Besides, you can find someone who detests any given naming convention. Stylistic decisions are like that. It could be much worse. PFNGLARRAYELEMENTARRAYEXTPROC is kind of hard to remember. (pulled from MS's OpenGL header) -- andy
Jan 03 2004
parent reply imr1984 <imr1984_member pathlink.com> writes:
In article <bt84jh$2nfa$1 digitaldaemon.com>, Andy Friesen says...
imr1984 wrote:
 Can someone explain to the me the rationing of the D naming convention,
 where names start with a lower case and each new word has a capital, eg:
 
 int lovelyInteger;
 
 I personally think that looks sloppy.
The Java convention is probably the single most widely used convention today. D could do worse. *cough*Hungarian*cough* Besides, you can find someone who detests any given naming convention. Stylistic decisions are like that. It could be much worse. PFNGLARRAYELEMENTARRAYEXTPROC is kind of hard to remember. (pulled from MS's OpenGL header) -- andy
it says on the style guide, say no to hungarian notation, well what about properties? To distuingish a property from its variable you either have to capitalise one of em, or use hungarian notation. This example is taken from the spec: struct Foo { int data() { return m_data; } // read property int data(int value) { return m_data = value; } // write property private: int m_data; } I think the style guide needs to be more clear on this.
Jan 03 2004
parent reply Andy Friesen <andy ikagames.com> writes:
imr1984 wrote:
 it says on the style guide, say no to hungarian notation, well what about
 properties? To distuingish a property from its variable you either have to
 capitalise one of em, or use hungarian notation. This example is taken from the
 spec:
 
 struct Foo
 {
 int data() { return m_data; }	// read property
 
 int data(int value) { return m_data = value; } // write property
 
 private:
 int m_data;
 }
 
 I think the style guide needs to be more clear on this.
I just prefix private stuff with an underscore. I believe this too is part of the Java convention. Either way, though, it works nicely, as it is very clear, without sucking up eyespace. In the end, though, I don't suppose it matters. It has nothing to do with the public interface. -- andy
Jan 04 2004
parent Mark T <Mark_member pathlink.com> writes:
In article <bt8j3g$bl2$1 digitaldaemon.com>, Andy Friesen says...

In the end, though, I don't suppose it matters.  It has nothing to do 
with the public interface.
excellent comment - if it's not in the public interface then feel free to use whatever style you or your team wants (unless you are writing for a journal or book where unsuspecting newbies may be influenced by too much hungarian, the Cclassname thing drives me nuts)
Jan 04 2004