in reply to Naming convention for variables, subroutines, modules, etc.. and variable declaration
There are many naming conventions and naming styles. Basic styles are camelCase, unixalllowercase and underscore_seperated. unixalllowercase seems to be used less now (andadamngoodthingtoo). camelCase has the small advantage that iw uses fewer characters and the small disadvantage that it can be slightly harder to read if you are not acustomed to it compared with underscore_seperated.
A number of conventions exist concerning use of case. BLOCK_UPPERCASE is pretty much reserved for file handles in Perl. MixedCase is generally ony used for camelCase identifiers. Sometimes an uppercase First_letter is used to denote a subroutine call. However, at the end of the day, adopt a convention and stick with it. Consistency is much more important than the particular style chosen.
In the case of where to declare variables however the matter is much clearer. Declare them in as small a scope as you can so there is less chance that they will be misused and their intended use is more evident. Especially this is true if you initialise the variable where it is declared. Using strictures of course helps a lot with managing variables.
Update: s/hyphen/underscore/g
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Naming convention for variables, subroutines, modules, etc.. and variable declaration
by johngg (Canon) on Nov 24, 2006 at 09:49 UTC | |
|
subroutine scope vs. tightest scope
by doom (Deacon) on Nov 24, 2006 at 19:56 UTC | |
by Tanktalus (Canon) on Nov 24, 2006 at 21:04 UTC | |
|
Re^2: Naming convention for variables, subroutines, modules, etc.. and variable declaration
by Anonymous Monk on Nov 24, 2006 at 15:57 UTC | |
by shotgunefx (Parson) on Nov 25, 2006 at 02:21 UTC |