Attribute naming for Java attributes, snake_case or CamelCase?


#1

Java stuff all uses CamelCase while ruby uses snake_case

tomcat “liferay” do
jvm do
Xms '256m’
Xmx '512m’
MaxPermSize '256m’
end
end

Should the attributes be named MaxPermSize or max_perm_size? Even harder,
Xmx or xmx (max jvm heap size)?


#2

Hi,

I would think that it would be best to keep with ruby conventions
while in ruby files. All the java-ish cookbooks I work on try to
follow snake_case where possible

On Thu, Apr 12, 2012 at 5:51 PM, Bryan Berry bryan.berry@gmail.com wrote:

Java stuff all uses CamelCase while ruby uses snake_case

tomcat “liferay” do
jvm do
Xms '256m’
Xmx '512m’
MaxPermSize '256m’
end
end

Should the attributes be named MaxPermSize or max_perm_size? Even harder,
Xmx or xmx (max jvm heap size)?


Cheers,

Peter Donald


#3

On Thu, Apr 12, 2012 at 5:51 PM, Bryan Berry bryan.berry@gmail.com wrote:

Java stuff all uses CamelCase while ruby uses snake_case

Should the attributes be named MaxPermSize or max_perm_size? Even harder,
Xmx or xmx (max jvm heap size)?

On Thu, Apr 12, 2012 at 10:07 AM, Peter Donald peter@realityforge.org wrote:

Hi,

I would think that it would be best to keep with ruby conventions
while in ruby files. All the java-ish cookbooks I work on try to
follow snake_case where possible

+1


#4

thanks guys, that’s very helpful

On Thu, Apr 12, 2012 at 10:08 AM, Andrea Campi <andrea.campi@zephirworks.com

wrote:

On Thu, Apr 12, 2012 at 5:51 PM, Bryan Berry bryan.berry@gmail.com
wrote:

Java stuff all uses CamelCase while ruby uses snake_case

Should the attributes be named MaxPermSize or max_perm_size? Even
harder,

Xmx or xmx (max jvm heap size)?

On Thu, Apr 12, 2012 at 10:07 AM, Peter Donald peter@realityforge.org
wrote:

Hi,

I would think that it would be best to keep with ruby conventions
while in ruby files. All the java-ish cookbooks I work on try to
follow snake_case where possible

+1


#5

Hiya,

I’d like to argue the other position :slight_smile:

On Thu, Apr 12, 2012 at 8:51 AM, Bryan Berry bryan.berry@gmail.com wrote:

Java stuff all uses CamelCase while ruby uses snake_case

tomcat “liferay” do
jvm do
Xms '256m’
Xmx '512m’
MaxPermSize '256m’
end
end

Should the attributes be named MaxPermSize or max_perm_size? Even harder,
Xmx or xmx (max jvm heap size)?

I’d suggest sticking with the naming in your example - ie, they should
match the options passed to Java.

Rationale: the DSL should match the expectations of the user.

While this generally calls for consistency, in this case I’d argue
that a user looking to specify the MaxPermSize option will expect the
attribute to be called MaxPermSize. Requiring max_perm_size for the
sake of consistency means that the user will need to refer to the
documentation to translate terms from the domain of the software
they’re configuring (Java) into the domain of the tool they’re using
to do so (Chef).

On the other hand, if your “jvm” block has other attributes which
don’t correspond directly to Java options, I’d use snake case for
them. Keeping everything consistent may be more confusing, as the
user couldn’t reliably infer whether an attribute directly controlled
a Java option, or whether there was some other behaviour they needed
to be aware of. In other words, inappropriate consistency can make it
more difficult for the user to form a mental model on which to work.

There’s no right or wrong answer to your question. Imagine a typical
user of your DSL, and ask yourself what would be least surprising.

Zac


#6

Hi,
I would tend to agree with Zac. Being a sysadmin who does java, then I would tend to be looking for Xmx, and not xmx.

                                    Sc0tt...

From: Zac Stevens [zts@cryptocracy.com]
Sent: 12 April 2012 13:33
To: chef@lists.opscode.com
Subject: [chef] Re: attribute naming for Java attributes, snake_case or CamelCase?

Hiya,

I’d like to argue the other position :slight_smile:

On Thu, Apr 12, 2012 at 8:51 AM, Bryan Berry bryan.berry@gmail.com wrote:

Java stuff all uses CamelCase while ruby uses snake_case

tomcat “liferay” do
jvm do
Xms '256m’
Xmx '512m’
MaxPermSize '256m’
end
end

Should the attributes be named MaxPermSize or max_perm_size? Even harder,
Xmx or xmx (max jvm heap size)?

I’d suggest sticking with the naming in your example - ie, they should
match the options passed to Java.

Rationale: the DSL should match the expectations of the user.

While this generally calls for consistency, in this case I’d argue
that a user looking to specify the MaxPermSize option will expect the
attribute to be called MaxPermSize. Requiring max_perm_size for the
sake of consistency means that the user will need to refer to the
documentation to translate terms from the domain of the software
they’re configuring (Java) into the domain of the tool they’re using
to do so (Chef).

On the other hand, if your “jvm” block has other attributes which
don’t correspond directly to Java options, I’d use snake case for
them. Keeping everything consistent may be more confusing, as the
user couldn’t reliably infer whether an attribute directly controlled
a Java option, or whether there was some other behaviour they needed
to be aware of. In other words, inappropriate consistency can make it
more difficult for the user to form a mental model on which to work.

There’s no right or wrong answer to your question. Imagine a typical
user of your DSL, and ask yourself what would be least surprising.

Zac


#7

On Thursday, April 12, 2012 at 4:17 AM, RUSSELL Scott wrote:

Hi,
I would tend to agree with Zac. Being a sysadmin who does java, then I would tend to be looking for Xmx, and not xmx.

Sc0tt…


From: Zac Stevens [zts@cryptocracy.com (mailto:zts@cryptocracy.com)]
Sent: 12 April 2012 13:33
To: chef@lists.opscode.com (mailto:chef@lists.opscode.com)
Subject: [chef] Re: attribute naming for Java attributes, snake_case or CamelCase?

Hiya,

I’d like to argue the other position :slight_smile:

On Thu, Apr 12, 2012 at 8:51 AM, Bryan Berry <bryan.berry@gmail.com (mailto:bryan.berry@gmail.com)> wrote:

Java stuff all uses CamelCase while ruby uses snake_case

tomcat “liferay” do
jvm do
Xms '256m’
Xmx '512m’
MaxPermSize '256m’
end
end

Should the attributes be named MaxPermSize or max_perm_size? Even harder,
Xmx or xmx (max jvm heap size)?

I’d suggest sticking with the naming in your example - ie, they should
match the options passed to Java.

Rationale: the DSL should match the expectations of the user.

Depending on the user’s background they may be expecting either style. For maximum do-what-I-mean value, you can use method aliasing to make both styles valid.


Dan DeLeo