digitalmars.D - Naming conventions
- Andrew Fedoniouk (23/23) Mar 02 2005 As far as understand the main stream of [subject] in D is
- zwang (3/34) Mar 03 2005 I would recommend to UpperCamelCase all type names including structs,
- Dejan Lekic (17/17) Mar 03 2005 I very much dislike JAVA-borrowed methodNameConvention() ... Method name...
- zwang (2/18) Mar 03 2005
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (8/33) Mar 03 2005 Some people use structs to fake classes (structs with methods),
- Jarrett Billingsley (5/5) Mar 03 2005 Naming conventions never seem to work, as unless people have a real
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
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
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
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
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
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