Class/Module Naming Best Practice for Acronyms

I

Intransition

If you are encapsulating something that is generally referred to by an
acronym, is it better to use all caps, even though in Ruby that
usually indicates a constant value of some sort other than a class or
module. Or is better to capitalize the term so it conforms to the
typical look of class/module names.

Eg.

XML::Document -or- Xml::Document

POM::Metadata -or- Pom::Metadata

ANSI::Code -or- Ansi::Code

I can't seem to ever make up my mind about this, so I thought I'd ask
and see if there is some sort of general consensus or if someone else
has some sort of concrete basis on which to decide.
 
P

pharrington

If you are encapsulating something that is generally referred to by an
acronym, is it better to use all caps, even though in Ruby that
usually indicates a constant value of some sort other than a class or
module. Or is better to capitalize the term so it conforms to the
typical look of class/module names.

Eg.

  XML::Document  -or-  Xml::Document

  POM::Metadata  -or-  Pom::Metadata

  ANSI::Code     -or-  Ansi::Code

I can't seem to ever make up my mind about this, so I thought I'd ask
and see if there is some sort of general consensus or if someone else
has some sort of concrete basis on which to decide.

POM is delicious.

so POM should be capitalized.

(but I myself use all caps for module/class names when such matches
the actual spelling, and libraries such as Nokogiri and JSON seem to
do this too, so that seems like the expected way of doing?)
 
J

Joel VanderWerf

Intransition said:
XML::Document -or- Xml::Document

It's actually hard for me to type Xml rather than XML or xml.

I prefer the former style. Doesn't bother me that it looks like
non-module constants.
 
F

Fabian Streitel

[Note: parts of this message were removed to make it a legal post.]
(but I myself use all caps for module/class names when such matches
the actual spelling, and libraries such as Nokogiri and JSON seem to
do this too, so that seems like the expected way of doing?)

I second that. If you'd write it all caps in a text document, why not in
source code?

Greetz!
 
D

David A. Black

Hi --

It's actually hard for me to type Xml rather than XML or xml.

I prefer the former style. Doesn't bother me that it looks like non-module
constants.

I agree, and it seems to be standard practice in the standard library
(YAML, Net::HTTP, ERB, etc.).


David

--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Q: What's the best way to get a really solid knowledge of Ruby?
A: Come to our Ruby training in Edison, New Jersey, September 14-17!
Instructors: David A. Black and Erik Kastner
More info and registration: http://rubyurl.com/vmzN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top