Project specific coding conventions
来源:互联网 发布:28网络用语啥意思 编辑:程序博客网 时间:2024/06/02 18:46
Project specific coding conventions
1. Brackets
All brackets (class, method, if, try, etc) must begin and end on a new line. Example :
public class SomeClass{ public void someMethod() { if (xxx) { } }}
Brackets are mandatory, even for single line statements !
// Incorrectif (expression) // some code// Correctif (expression){ // some code}
2. Blank Spaces
keywords followed by a parenthesis should be separated by a space. Example :
while (true){ // some code}
Blank space should appear after commas in argument lists. Binary operators should be separated from their operands by spaces :
a += c + d;a = (a + b) / (c * d);while (d++ = s++){ n++;}printSize("size is " + foo + "/n");
3. Indentations
4 spaces. NO tabs . Period. We understand that a lot of you like to use tabs, but the fact of the matter is that in a distributed development environment, when the cvs commit messages get sent to a mailing list, they are almost impossible to read if you use tabs.
4. Comments
Javadoc SHOULD exist on all your class members (methods + class variables), including the private ones. Also, if you are working on existing code and there currently isn't a javadoc for that method/class/variable or whatever, then you should contribute and add it. This will improve the project as a whole.
Also add code comments when you think it's necessary (like assumptions), especially when the code is not obvious.
5. Author references
If you contribute to a file (code or documentation), add yourself to the top of the file (below the existing authors). For java files the preferred Javadoc format is:
@author devnickname
7. Class variables
Class variables should not have any prefix and must be referenced using the this
object. Example :
public class SomeClass{ private String someString;[...] public void someMethod() { logger.debug("Value = " + this.someString); }}
8. Parameter names
Method parameters should not have any prefix. For example :
public void someMethod(String className){}
10. Versioning
All .java files should have a @version
tag like the one below.
@version $Revision$ ($Author$)
11. Qualified imports
All import
statements should containing the full class name of classes to import and should not use the "*"
notation :
An example :
// Correctimport java.util.Date;import java.net.HttpURLConnection;// Not correctimport java.util.*;import java.net.*;
- Project specific coding conventions
- Coding Style Conventions
- WEB Coding Conventions
- Qt Coding Conventions
- RTEMS 源文件coding conventions
- Kotlin Reference (三) Coding Conventions
- windows编程之一Windows Coding Conventions
- Conventions
- Conventions
- Flex SDK coding conventions and best practices(官方)
- QML官方系列教程——QML Coding Conventions
- 史上最全代码风格大全!!!Coding Style Conventions and Standards
- Kotlin-03.编码规范/代码风格(Coding Conventions)
- Project Hard Coder *************Coding 硬汉*************
- eclipse配置:save action-->enable project specific settings
- Kotlin学习(五): 惯用语法和代码风格(Idioms And Coding Conventions)
- Project in C++ Coding Practice(zz)
- Calling conventions
- 三层结构中DBGridEh实现点击列Title排序
- 网页上地区选择的炮制方法
- 在Linux下访问MS SQL Server数据库
- 一个javabean轻松实现对数据库的各种操作
- sql server7.0数据库恢复
- Project specific coding conventions
- Java变量类型间的相互转换
- JSP与Servlets的区别
- 如何在linux下查看tomcat的错误信息!
- linux下mysql的卸载
- 给年轻工程师的十大忠告
- 一个javabean轻松实现对数据库的各种操作
- Linux命令集
- 如何学好J2ME