[Grace-core] Naming conventions in grace

Kim Bruce kim at cs.pomona.edu
Sat Jun 8 15:22:47 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.

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.

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.  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.

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).  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).

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?

Kim





More information about the Grace-core mailing list