Naming is the core of program planning. The ancients believed that as long as they knew the real name of a person, they would gain incredible power over that person. As long as you give things a correct name, it will give you and people later more powerful than the code. Don't laugh!
The name is a long-term and profound result of a thing in its ecological environment. In general, only programmers who know the system can obtain the most appropriate name for the system. If all the names are suitable for their nature, the relationship is clear, and the meaning can be deduced. The assumption of the average person can also be expected.
If you find that only a few of your names can match their corresponding items, you 'd better look at your design again.
Class Name
In;
}
--------------------------------------------------------------------------------
Function Name
The function name follows the c gnu Convention. All letters Use lowercase letters and '_' to separate words.
Reason
This makes it easier to distinguish the names of associated classes.
For example
Function some_bloody_function ()
{
}
--------------------------------------------------------------------------------
Error return detection rules
Check all system call errors unless you want to ignore them.
Define the system error text for each system error message to include.
--------------------------------------------------------------------------------
Braces {} rules
Two of the three main braces are acceptable, and the first is the best:
Place braces in the same column below the keywords:
If ($ condition) while ($ condition)
{{
......
}}
The traditional brackets of UNIX are the same as the keywords, And the ending brackets are the same as the keywords:
If ($ condition) {while ($ condition ){
......
}}
Reason
Non-principled issues that have aroused heated debate can be solved through a compromise. either of the two methods is acceptable, but most people prefer the first one. The reason is the scope of psychological research.
There are more reasons to prefer the first one. If the character editor you are using supports the bracket matching function (for example, vi), the most important thing is to have a good style. Why? We say that when you have a large program and want to know where it ends. Move the brackets to the beginning, and press the button editor to find the ending brackets. For example:
If ($ very_long_condition & $ second_very_long_condition)
{
...
}
Else if (...)
{
...
}
To move a block from one block to another, you only need to use the cursor to match your brackets. You do not need to move back and forth to the end of the line to find matching brackets.