in reply to Capitalized subroutine names and packages

It seems to ne there is a lot of "doctor, it hurts when I do this" going on here.

The best workaround here is not to put things in quotes, or use colons; it's to name things properly in the first place. Packages and Classes with a leading uppercase, subroutines and methods without.
Proper use of naming conventions promotes clean code. It also helps multiple developers work together.
It sounds obvious, but I've seen too much code that gives me the willies out there not to restate it.


-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
  • Comment on Re: Capitalized subroutine names and packages

Replies are listed 'Best First'.
Re^2: Capitalized subroutine names and packages (bad package names)
by tye (Sage) on Jan 06, 2003 at 17:29 UTC

    I agree in spirit but disagree on some of the details. The main thing that should not be done is having a package name that doesn't contain "::".

    I'd rather have a subroutine named "Bar" than one named "bar". Consider sub Log versus sub log and then doing log("Error at....") and you'll get "Argument isn't numeric" and "Can't take log of 0".

    I try to use multi-word subroutine names so that I can avoid conflicts with both poorly named modules and with keywords that have slipped my mind (or got created since I wrote the code, etc.) by using initial lower case and capitals in the middle ("logToFile"). But when I get lazy and use a single-word subroutine name, then I try to remember to capitalize (if you don't, then you need to always call it with a leading ampersand, &log(), to be safe).

    Perl has lots of poorly named modules. The worst two are O.pm and B.pm. But CGI.pm and CPAN.pm are also bad names that should be changed. They don't even work well in English because someone says "I'm using CPAN" and I don't know if they are talking about the module or CPAN itself (the Archive Network, ya know, the thing that you'd know I was talking about when I said "CPAN" if it weren't for someone short-sightedly naming a module that).

    All modules should have "::" in their name.

                    - tye