Class/Module Naming Best Practice for Acronyms

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.

On Aug 14, 11:17 am, Intransition [email protected] wrote:

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

Intransition wrote:

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.

Hi –

On Sat, 15 Aug 2009, Joel VanderWerf wrote:

Intransition wrote:

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.

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

David

(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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs