[Grace-core] Naming conventions in grace

James Noble kjx at ecs.vuw.ac.nz
Sun Jun 9 15:43:26 PDT 2013


> I've been writing a number of Grace programs testing the objectdraw library and now feel like I've been getting enough written that I should adopt some reasonable naming/orthography conventions.

good!

> I don't see any problem with having all types start with capital letters.  That's conventional in Java and doesn't seem to cause any problems.  I also don't see any problem with adopting the Java camelCase convention for variables and method names:  names start with lower case and include capitals to start each new word:  thisIsAnIdentifier.

all seems to make sense.

> The two places that I have issues with Java conventions is with definitions (constants) and class names.  Because Grace pushes you to use more definitions than Java, I'm less happy with the all-caps convention for constants from Java.  I find MY_CONSTANT to be annoying (like shouting!), so have just been using camelCase for definitions.

I'm quite happy with this.

>  This has the disadvantage of not highlighting the difference between definitions and variables.  However, I'm inclined to stick with this unless someone wants to make a case for a different convention.

the distinction between definitions, variables, and methods is one I am very happy to blur
(on the client side, that is).  We have one namespace and ideally should have one rule
for binding names that does not depend upon the resulting binding. 

> I've been all over the place with naming and orthography for classes (as you can see if you've looked at the objectdraw code).

yep. me too.

>  I've used Java conventions:  FramedRect, Java convention with prefix to distinguish from types:  MkFramedRect, or the same as other definitions/variables: aFramedRect.  In the end, I think I'm more comfortable with the last (which I believe was suggested by Andrew). It is consistent with the notion that we are understanding classes as special objects with factory methods and, when combined with constructor names, suggests what is actually happening:  aFramedRect.at(posn)size(width,height)on(canvas).

I've certainly found Grace's separation of class and type makes for interesting naming too.
(then again, ASTs in particular turn out to work very well with *nominal* types.)

I've stuck with Java style names, typically
 Foo - for the type
 AbstractFoo - for a superclass
 ConcreteFoo or (ideally)  XXXFoo - for particular classes 

perhaps I should try the "aFoo" convention to see how that feels - 
I haven't tried it much yet. The Parser combinators are mostly named
in the Java style...  

> However, before I go back and change everything in objectdraw I thought I would check to make sure that no one has any major objections (or strong preferences).  What do you think?

I like most of it, but I'm still not convinced about the "aFoo" convention, 
although I do understand why...

James 


More information about the Grace-core mailing list