Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

Comment on CamelCase in module names
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 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 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 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.
      <AOL>
      M3 T00!!!11!1!!!
      </AOL>
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.

    TStanley
    --------
    The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://480894]
Approved by friedo
Front-paged by sk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-08-21 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls