www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Naming conventions

reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
As far as understand the main stream of [subject] in D is
something close to Java
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

But Java has no such features as struct and unions.
Would it be convenient to recommend to use their names
starting from lowercase letter?
Just to emphasize that you don't need to do allocations of them.

like

struct point
{
   int x, y;
}

struct rect
{
   point origin, corner;
}

class Widget
{
    int type;
    rect place;
   ....
}

What do you think?
Mar 02 2005
next sibling parent reply zwang <nehzgnaw gmail.com> writes:
Andrew Fedoniouk wrote:
 As far as understand the main stream of [subject] in D is
 something close to Java
 http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
 
 But Java has no such features as struct and unions.
 Would it be convenient to recommend to use their names
 starting from lowercase letter?
 Just to emphasize that you don't need to do allocations of them.
 
 like
 
 struct point
 {
    int x, y;
 }
 
 struct rect
 {
    point origin, corner;
 }
 
 class Widget
 {
     int type;
     rect place;
    ....
 }
 
 What do you think?
 
 

I would recommend to UpperCamelCase all type names including structs, and to lowerCamelCase all instance names.
Mar 03 2005
parent reply Dejan Lekic <leka entropy.tmok.com> writes:
I very much dislike JAVA-borrowed methodNameConvention() ... Method names
should be also UpperCamelCase() . No developers won't mix it with class
names because in 99% their code would some something like:
some_object.SomeMethod();
So there is visible distinction between object, and method. Since "." is
before SomeMethod, and "(" after it it cannot be neither class (type) name,
nor constructor...
Anyway Walter has decided and when I saw it i decided to stop thinking so
much about D. I absolutely refuse to use methodNames() like in JAVA. :)

IMHO core D stuff should be written like C++ STL is - method_names() .

Best regards

Dejan

-- 
...........
Dejan Lekic
  http://dejan.lekic.org
  
Mar 03 2005
parent zwang <nehzgnaw gmail.com> writes:
Dejan Lekic wrote:
 I very much dislike JAVA-borrowed methodNameConvention() ... Method names
 should be also UpperCamelCase() . No developers won't mix it with class
 names because in 99% their code would some something like:
 some_object.SomeMethod();
 So there is visible distinction between object, and method. Since "." is
 before SomeMethod, and "(" after it it cannot be neither class (type) name,
 nor constructor...

Not always. Remember we have the nice "with" statement in D.
 Anyway Walter has decided and when I saw it i decided to stop thinking so
 much about D. I absolutely refuse to use methodNames() like in JAVA. :)
 
 IMHO core D stuff should be written like C++ STL is - method_names() .
 
 Best regards
 
 Dejan
 

Mar 03 2005
prev sibling next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Andrew Fedoniouk wrote:

 But Java has no such features as struct and unions.
 Would it be convenient to recommend to use their names
 starting from lowercase letter?
 Just to emphasize that you don't need to do allocations of them.
 
 like
 
 struct point
 {
    int x, y;
 }
 
 struct rect
 {
    point origin, corner;
 }
 
 class Widget
 {
     int type;
     rect place;
    ....
 }
 
 What do you think?

Some people use structs to fake classes (structs with methods), which puts them somewhere inbetween variables and objects... Besides that, it seems OK. However, Walter seems to disagree: http://www.digitalmars.com/d/dstyle.html (Naming Conventions) Even enums and unions have CamelCase, on that official page ? But aliases and typedefs use lowercase still, e.g. "bool". --anders
Mar 03 2005
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
Naming conventions never seem to work, as unless people have a real 
incentive to follow such conventions (such as a company policy), they 
usually won't.

Not to shoot you down or anything, it's just.. I doubt you'll get through to 
many people. 
Mar 03 2005