Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

CamelCase in module names

by tlm (Prior)
on Aug 04, 2005 at 15:58 UTC ( #480894=perlquestion: print w/replies, xml ) Need Help??
tlm has asked for the wisdom of the Perl Monks concerning the following question:

In perlmodlib, under "Some simple style guidelines", it says

[non-pragmatic] modules normally begin with a capital letter and use mixed case with no underscores (need to be short and portable).

I hate CamelCase, so I have to ask: what platform is responsible for the "unportability" of underscores in Perl module names?

the lowliest monk

Replies are listed 'Best First'.
Re: CamelCase in module names
by jhourcle (Prior) on Aug 04, 2005 at 16:34 UTC

    I always assumed it was 'short' that was the issue -- so file systems that only allowed 8.3 for the file names. One underscore, and you've just lost 12% of your working space (as the extension is fixed)

Re: CamelCase in module names
by Anonymous Monk on Aug 04, 2005 at 16:34 UTC
    Not using of underscores is not because of the portability requirement, but of the shortness requirement. A case switch don't add to the length - an underscore does.

    But noone is forcing you to use CamelCase - if you don't want to - don't.

Re: CamelCase in module names
by polypompholyx (Chaplain) on Aug 04, 2005 at 19:36 UTC
    One thing that's annoyed me inordinately in the past is Getopt::Long, whose principal function is called GetOptions. I've written use GetOpts::Long; Getoptions(); or similar, so many times that I had to write a script to generate boilerplate just to save my sanity...

      And you think it worked? ;-)

        Mostly. Now I only have to remember the three switches for the boilerplate script. This means I have at least 0.01% more space in my head for The Voices.
      M3 T00!!!11!1!!!
Re: CamelCase in module names
by halley (Prior) on Aug 04, 2005 at 16:43 UTC
    I hate StudlyCaps too, so I always name modules with single words. Nouns, typically.

    In object oriented terms, I have found that if I need an adjective to describe a classname, then there's probably some inheritance of more fundamental features.

    For example, say I want an interactive widget. Thinking about it, I realize that the adjective clues me in on the possibility of other kinds of widgets. I may or may not be better served with a separate namespace like Widget::Inert and Widget::Interactive under the more general Widget namespace and class. But I very rarely would use a name like InteractiveWidget which just looks BuTtTuGly to me.

    One thing to keep in mind: if you're using a lot of other people's modules from CPAN, then you're going to have to accept the names they already have, so you might as well become disabused of your notions of avoiding all StudlyCaps entirely.

    [ e d @ h a l l e y . c c ]

Re: CamelCase in module names
by shiza (Hermit) on Aug 04, 2005 at 18:24 UTC
    I think it is a good standard and feel that it helps visually reinforce code structure.
    use module_name::sub_class; <-yuk
Re: CamelCase in module names
by Tanktalus (Canon) on Aug 05, 2005 at 03:21 UTC

    Historically, that would be anything on a FAT drive: DOS, OS/2. I'm sure that back in '95, '96, some may have included Win95 in the list as well, being a bit scared of the new extentions to the FAT filesystem therein. (I'm just waiting for my last OS/2 machine to die on me ... going on 7 years old :-})

    Today, with DOS a mere memory that is fading, at least for most people, and OS/2 being officially withdrawn from the marketplace (for the fourth or fifth time, I think, if one were to believe the tech-news), or even the very small numbers of OS/2 users that still use FAT (HPFS being far, far superior in every way), I'm not sure what reason is left for short names.

    That said, I still see value in differentiating our 'bare' words: often we use UPPERCASE for constants (or constant subs) and perlish APIs (e.g., DESTROY, BEGIN, END), or lowercase for scope-limited variables. CamelCase for packages, and under_scores for functions works for me.

Re: CamelCase in module names
by TStanley (Canon) on Aug 05, 2005 at 00:33 UTC
    You might be interested in Damian Conway's new book, Perl Best Practices. He covers everything you ever wanted to know about good programming practices.

    The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://480894]
Approved by friedo
Front-paged by sk
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-07-28 11:07 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (428 votes). Check out past polls.