Should constants and enum follow Scala naming convention?

274 views
Skip to first unread message

Jarek

unread,
Jan 3, 2013, 6:16:17 PM1/3/13
to scala...@googlegroups.com
Currently constants in ScalaFX, like Color.LIGHTGREEN, and enums, like
Pos.BASELINE_LEFT, use Java naming convention (mirroring JavaFX) � all
capital letters with (optional) underscore between words.

In Scala constants are named using CamelCase, for instance,
Double.MaxValue instead ofDouble.MAX_VALUE in Java.

Should constants and enums in ScalaFX also use CamelCase convention, for
instance, Color.LightGreen and Pos.BaselineLeft?

I would lean toward Scala naming convention, but that may mean some
significant changes to the code, though thanks to default implicit
conversion between SFX and JFX it may not mean much incompatibility. It
may also go through a deprecation having both for a while
(Color.LIGHTGREEN and Color.LightGreen).

If there is some consensus on one or the other approach, it should be
documented in ScalaFX Wiki, say on page DevelopersGuide, to help keep
source code and API consistent.

Jarek

Asko Kauppi

unread,
Jan 4, 2013, 12:12:09 AM1/4/13
to scala...@googlegroups.com, jsa...@users.sourceforge.net
My personal opinion on this is to match the Java naming as close as possible. The problem arises from books, documentation etc. These don't exist for ScalaFX. They do exist for JavaFX.

Alain FAGOT BÉAREZ

unread,
Jan 4, 2013, 8:37:42 AM1/4/13
to scala...@googlegroups.com
Em sexta-feira, 4 de janeiro de 2013 02h12min09s UTC-3, Asko Kauppi escreveu:
My personal opinion on this is to match the Java naming as close as possible.

I would prefer to write in Scala, just like any body writing in Scala, meaning "least surprise" for new readers.
 
The problem arises from books, documentation etc. These don't exist for ScalaFX. They do exist for JavaFX.

Please just don't tell that to Jarek, who is currently involved with the complete translation of the examples from the Pro JavaFX2 book. https://github.com/jsacha/ProScalaFX/

Regards,
Alain

Mike Allen

unread,
Jan 4, 2014, 1:27:38 PM1/4/14
to scala...@googlegroups.com, jsa...@users.sourceforge.net
Hi All,

What was the resulting consensus? I've seen some code that names constants Scala-style and some that uses Java-style. We should definitely prefer one over the other (and my vote is the Scala way). As long as we adopt one and employ it consistently, even if it breaks existing code, I don't see a problem as we only have snapshots available right now.

Alternatively, I guess we could use Scala-style going forward and change existing code to have both styles, marking the Java-style constants as @deprecated.

Best Regards,

Mike

Jarek Sacha

unread,
Jan 6, 2014, 11:20:39 PM1/6/14
to scala...@googlegroups.com
ScalaFX intention is to make JavaFX API feel more like Scala, so it would make sense use Scala naming convention: "Constant names should be in upper camel case", and mark existing Java-style constants @deprecated.

Jarek 
 

Best Regards,

Mike


Reply all
Reply to author
Forward
0 new messages