Thread overview
Naming conventions
Mar 03, 2005
Andrew Fedoniouk
Mar 03, 2005
zwang
Mar 03, 2005
Dejan Lekic
Mar 04, 2005
zwang
March 03, 2005
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?


March 03, 2005
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.
March 03, 2005
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
March 03, 2005
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

March 04, 2005
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.


March 04, 2005
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
>