联盟首页 协同开发 共创软件 开放源码 软件工程 共创论坛 关于联盟
  您的位置 » 2004年08月22日  
通过SSL登录
新用户通过SSL注册

完全匹配   
项目摘要

项目维护

软件分类表
新发布软件
代码片断

项目名称: LinQ:
文档管理: 显示文档


摘要| 管理| 首页| 论坛| 跟踪| 错误| 支持| 补丁| 电子邮件| 任务| 文档 |  调查| 新闻| CVS| 软件包|

提交新文档 | 查看文档 | 管理
                                  MyICQ coding style
                                ----------------------

In General, the coding style for MyICQ is the mixture of the coding styles for Linux kernel and Sun Java.

1. Spaces. For example:
  Use
for (int i = 0; i < 10; i++) {
...
}
  Instead of
for(int i=0;i<10;i++){
}

  Pay much attention to the space after the 'for' keyword and the space before the opening braces.

2. Do not encode the type of a variable into its name (so-called Hungarian notation)
  just use variable 'count', instead of 'dwCount', eg.

3. Do not name a local variable as ThisVariableIsATemporaryCounter, just call it "tmp"

4. Use a more descriptive name for a global variable or a global function.

5. Use 'fooBar' instead of 'foo_bar', or 'FooBar' as the name of a variable or a function.

6. Indentations are 4 characters

7. Put the opening brace last on the line, and put the closing brace first, thusly:

if (x == y) {
..
} else if (x > y) {
...
} else {
....
}

do {
body of do-loop
} while (condition);

class A {
public:
void inlineFunction() {
}
private:
int memberVariable;
};

  However, there is one special case, namely functions: they have the opening brace at the beginning of the next line, thus:

int function(int x)
{
body of function
}

8. NERVER try to explain HOW your code works in a comment: it's much better to write the code so that the _working_ is obvious, and it's a waste of time to explain badly written code. Generally, you want your comments to tell WHAT your code does, not HOW. You'd better put the comments at the head of the function, telling people what it does, and possibly WHY it does it.

9. Structure names and macros are all uppercases.


  » 合 作 伙 伴