Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: camelCase vs snake_case

by Athanasius (Canon)
on Aug 29, 2012 at 07:20 UTC ( #990394=note: print w/ replies, xml ) Need Help??

in reply to camelCase vs snake_case

Here is a summary of the advice offered by the Camel Book (4th Edition, p. 704) on the naming of identifiers in Perl:

Identifier Variable Subroutine
Non-lexical filehandle FILE
Package-wide global $Some_Caps_Here
Package name CamelCase
Lexicals and subs $no_caps_here process_data
Private to a package $_leading_underscore _frobnicate

I do not advocate this style merely because it happens to be the one recommended in the language’s definitive reference. (I personally dislike the K&R style it recommends for brace placement, pp. 701–2.) But in this case I think the advice is useful, because the different naming conventions aid the reader in distinguishing the different ways in which identifiers are used in code.

As sundialsvc4 and Tux have said, consistency is the key. In a coding environment where programmers are likely to ignore style guidelines, a single one-case-fits-all style may be preferable (because easier to enforce). But in the general case, the visual distinctions provided by the various naming styles listed above aid comprehension and are worth learning, IMO.

Athanasius <°(((><contra mundum

Comment on Re: camelCase vs snake_case

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990394]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2016-04-29 14:28 GMT
Find Nodes?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW

    Results (441 votes). Check out past polls.