C++ coding style (for webkit)
2014-04-09 10:11
295 查看
Rename parameter definition according webkit’s renaming style:
1) Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case
the first letter, including all letters in an acronym, in a variable or function name.
2) Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
3) Data members in C++ classes should be private. Static data members should be prefixed by "s_".Other data members should be prefixed by "m_".
4) Prefix Objective-C instance variables with "_".
5) Precede boolean values with words like "is" and "did".
6) Precede setters with the word"set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten.
7) Precede getters that return values through out arguments with the word "get".
8) Use descriptive verbs in function names.
9) Leave meaningless variable names out of function declarations. A good rule of thumb is if the parameter type name contains the parameter name (without
trailing numbers or pluralization),then the parameter name isn't needed. Usually, there should be a parameter name for bools, strings, and numerical types.
10) Prefer enums to bools on function parameters if callers are likely to be passing constants, since named constants are easier to read at the call site.
An exception to this rule is a setter function, where the name of the function already makes clear what the boolean is.
11) Objective-C method names should follow the Cocoa naming guidelines — they should read like a phrase and each piece of the selector should start with
a lowercase letter and use intercaps.
12) Enum members should use InterCapswith an initial capital letter.
13) Prefer const to #define. Prefer inline functions to macros.
14) #defined constants should use all uppercase names with words separated by underscores.
15) Macros that expand to function calls or other non-constant computation: these should be named like functions,and should have parentheses at the end,
even if they take no arguments (with the exception of some special macros like ASSERT). Note that usually it is preferable to use an inline function in such cases instead of a macro.
16) #define, #ifdef "headerguards" should be named exactly the same as the file (including case),replacing the '.' with a '_'.
And the Webkit coding stype link : http://www.webkit.org/coding/coding-style.html
1) Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case
the first letter, including all letters in an acronym, in a variable or function name.
2) Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
3) Data members in C++ classes should be private. Static data members should be prefixed by "s_".Other data members should be prefixed by "m_".
4) Prefix Objective-C instance variables with "_".
5) Precede boolean values with words like "is" and "did".
6) Precede setters with the word"set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten.
7) Precede getters that return values through out arguments with the word "get".
8) Use descriptive verbs in function names.
9) Leave meaningless variable names out of function declarations. A good rule of thumb is if the parameter type name contains the parameter name (without
trailing numbers or pluralization),then the parameter name isn't needed. Usually, there should be a parameter name for bools, strings, and numerical types.
10) Prefer enums to bools on function parameters if callers are likely to be passing constants, since named constants are easier to read at the call site.
An exception to this rule is a setter function, where the name of the function already makes clear what the boolean is.
11) Objective-C method names should follow the Cocoa naming guidelines — they should read like a phrase and each piece of the selector should start with
a lowercase letter and use intercaps.
12) Enum members should use InterCapswith an initial capital letter.
13) Prefer const to #define. Prefer inline functions to macros.
14) #defined constants should use all uppercase names with words separated by underscores.
15) Macros that expand to function calls or other non-constant computation: these should be named like functions,and should have parentheses at the end,
even if they take no arguments (with the exception of some special macros like ASSERT). Note that usually it is preferable to use an inline function in such cases instead of a macro.
16) #define, #ifdef "headerguards" should be named exactly the same as the file (including case),replacing the '.' with a '_'.
And the Webkit coding stype link : http://www.webkit.org/coding/coding-style.html
相关文章推荐
- [C/C++] - Tips for Better Coding Style
- Secure Coding Best Practices for Memory Allocation in C and C++
- Google's C++ coding style
- Google C++ Coding Style:引用参数
- 从Google C++ Coding Style里面抽出一些贴近现实的rule
- Coding Style for python
- Secure Coding Best Practices for Memory Allocation in C and C++
- Secure Coding Best Practices for Memory Allocation in C and C++
- Google C++ Coding Style:右值引用(Rvalue Reference)
- 关于google的C++ coding style
- Web links for coding style
- coding style for the linux kernel
- Google's C++ coding style
- c++ coding style
- coding style for the linux kernel
- Style guidelines for C++
- Secure Coding Best Practices for Memory Allocation in C and C++
- The RightCoding Style for JAVA
- C++ Coding Style
- JavaScript 编码规范(Google Coding-style for JavaScript)