This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
howtos:toolcoding:good_practices [2010/11/08 16:30] marcus.williams |
howtos:toolcoding:good_practices [2010/11/08 17:03] marcus.williams |
||
---|---|---|---|
Line 43: | Line 43: | ||
Stub: best practices for variable naming, esp. locals FIXME | Stub: best practices for variable naming, esp. locals FIXME | ||
- | In general, variable description modifiers should be used as suffixes, rather than prefixes (e.g. //dwelling unit share// rather than //share of dwelling units//). The same is true for variable names | + | It is generally recommended that variable names use the [[http://en.wikipedia.org/wiki/CamelCase|lowerCamelCase]] convention. However, in some cases the use of underscores in conjunction with lowerCamelCase for coding clarity is appropriate (especially for procedures, views and source datasets). |
+ | |||
+ | Variable description modifiers should be used as suffixes, rather than prefixes (e.g. //dwelling unit share// rather than //share of dwelling units//). The same is true for variable names, but for these modifier abbreviations are recommended to keep name lengths manageable (e.g. ''dwellUnitShr''). A table of suggested abbreviations is provided below: | ||
^ Descriptor ^ Abbreviation ^ | ^ Descriptor ^ Abbreviation ^ | ||
Line 59: | Line 61: | ||
local population_tot[ts] = sum (population[s,ts,a]; dim1=sex, dim2=age) | local population_tot[ts] = sum (population[s,ts,a]; dim1=sex, dim2=age) | ||
</code> | </code> | ||
+ | |||
+ | Using underscores can also improve code readability when dealing with raw datasets, especially in calibrator frameworks (e.g. ''CANSIM_Manitoba_imm_1991_2006''). | ||