How many kinds of existing naming methods are there? Please illustrate.
The existing naming methods are mainly Hungarian nomenclature, camel Nomenclature, Pascal Nomenclature, underline nomenclature
- Hungarian nomenclature: Basic principles: Variable name = attribute + Type + object description. Each object's name requires a clear meaning and can take the full name of the object or part of the name.
For example, if the name of the form is a form, then the Hungarian nomenclature can be abbreviated as FRM, then the full name of the variable should be frmswitchboard when the form variable is named switchboard.
Refer to the following links:
Http://www.blogbus.com/ekwtpksm-logs/203213339.html
2. Camel nomenclature: Mix and write names of variables and functions using uppercase and lowercase letters
Small Hump Method: In addition to the first word, other words capitalized, for example, in Java, variable names and method names using the small hump method, where the variable name is a noun, the method named verb
Big Hump Method: The first letter of each word is capitalized, for example, in Java, the class name uses the big hump method, the class name is the noun
3. Pascal nomenclature: The first letter of each word is capitalized, the same as the big hump nomenclature.
4. Underline naming method: All letters are lowercase, each word is divided by an underscore, the underscore is the emergence of C after the advent of popular, in many old programs and UNIX environment, it is very common use.
In general, a language requires only a naming method, so that programmers communicate more conveniently, regardless of which naming method, there must be a principle, that is to-see the name of righteousness. A good naming method can
Reduce the amount of code comments, in general, a good code should be 70% code +30% of the comments, if the name is too bad, and each name needs to indicate its purpose, then will greatly increase the amount of comments, and increase
The programmer's own burden, but also increased the burden of subsequent code readers, resulting in inefficiency. Of course, can not be able to know the name of the meaning of the variable name function name and so write a long string, too much.
In this way, the naming should be through the life of the programmer, code writing, should not just for the sake of drawing their own convenience, but also should consider reading the code of other people, for follow-up maintenance update lay a good foundation.
From the perspective of a company or organization, a good code can reduce the cost of human and material resources and increase productivity. So to speak, naming is a science
Second week homework