This shows you the differences between two versions of the page.
| — |
gnucap:manual:tech:symbol_names_and_scope [2015/12/11 15:39] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Symbol names and scope ====== | ||
| + | |||
| + | ===== Naming conventions ===== | ||
| + | |||
| + | * Local variables are lower case, with words (if any) separated by underscores. | ||
| + | * Class instance variables begin with a single underscore. | ||
| + | * Formal parameters (arguments passed to functions) begin with an Upper case letter, and are otherwise lower case. | ||
| + | * Do not use "using". Instead, explicitly specify the scope with every use. | ||
| + | * Constants are ALL_CAPS. | ||
| + | * Members of an enum set begin with a lower case letter, but are otherwise ALL CAPS. That lower case prefix is the same for all members of the same enum set. | ||
| + | * Class names may be either ALL_CAPS or may be Mixed_Case_With_Words_Capitalized, with Words_Separated_By_Underscore, but be consistent. ALL_CAPS are preferred for base classes, Mixed_Case is preferred for "final" and application classes. | ||
| + | * Do not use CamelCase. | ||
| + | * Avoid single letter names. | ||
| + | * Occasionally, it is ok to insert an un_derscore in a funny place to make it easier to "grep". | ||
| + | * Flag symbols (both variables and methods) begin with "is_", for example "is_empty". | ||
| + | |||
| + | ===== Scope guidelines ===== | ||
| + | |||
| + | * In general, please restrict all names to the narrowest useful scope. | ||
| + | * Avoid globals. If you really must make something global, put it in a namespace so its origin is clear. | ||
| + | * Class instance variables should be private or protected. | ||
| + | |||
| + | |||
| + | |||
| + | |||