Data Names

xiaoxiao2021-03-06  61

1. Express exact meaning.2. As Short As Possible.

Naming loop Indexesin Common, We can use the names such as i, j and k; but when loop is long and complex, we would recording

Naming status variablesthink of a better name than flag for status variables.

Naming Temporary VriablesIn one way or another, most of the variables in your program are temporary. Calling a few of them temporary may indicate that you are not sure of their real purpose. So also give it a meaningful name.

Naming Boolean VariableGive Boolean Variables Names That Imply True of False, Such as .... Use Positive Boolean Variable Names.

Naming Enumerated TypeSgive a Group Prefix To these Variables.

Conventions for names1. Differentiate between variable and routine name.variable name is begin with lower case and routine name with upper case.2. Differentiate bwtween clases and objectsDifferentiating them via initial Capitalization.3. Identify global variablesuse g_ prefix.4. Identify member variables .use m_ prefix.5. Identify type definitionsprefix the type names before the variable.6. Format names to enhance readability.Two common techiniques for increasing readability are using capitalization and spacing characters to separate words.

Comments on Abbreviations1. Do not abbreviate by removing one characters from a word.2. Abbreviate consistenly.3. Create names that you can pronounce.4. Avoid combinations that result in mispronunciation.5. Use a thesaurus to resolve naming collisions.6 . Document Extreme Tables in the code.7. Document All Abbreviations in a project-level "standard abbreviations" document.

转载请注明原文地址:https://www.9cbs.com/read-111289.html

New Post(0)