各种语言代码规范

来源:互联网 发布:miss男装淘宝店 编辑:程序博客网 时间:2024/06/06 03:39

1. C

  • http://wiki.nginx.org/CodingStyle

  • http://tengine.taobao.org/book/appendix_a.html


2.C++

  • http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
  • 中文版:http://zh-google-styleguide.readthedocs.org/en/latest/google-cpp-styleguide/contents/


3.Java

  • https://sites.google.com/a/android.com/opensource/submit-patches/code-style-guide
  • http://www.oracle.com/technetwork/java/codeconvtoc-136057.html

4.Python

  • http://google-styleguide.googlecode.com/svn/trunk/pyguide.html
  • 中文版: http://zh-google-styleguide.readthedocs.org/en/latest/google-python-styleguide/

5.JavaScript

  • http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml


6.PHP

  • http://framework.zend.com/wiki/display/ZFDEV/PHP+Coding+Standard+%28draft%29

7.Objective-C

  • http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml

8.JSON

  • http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml
  • 中文版:https://github.com/darcyliu/google-styleguide/blob/master/JSONStyleGuide.md

9.Shell

  • http://google-styleguide.googlecode.com/svn/trunk/shell.xml

10.SQL

1). 所有的关键字大写

2). 关键字SELECT、FROM、JOIN、ON、WHERE、GROUP BY、LIMIT,都应该组成独立的block,有合适的缩进格式

3). 使用4个空格缩进,避免使用TAB键

4). 嵌套查询、嵌套条件,需要使用(),并组成独立的block,有合适的缩进格式

5). 每一行最多有一个关键字(IF等除外)

样例:
SELECT    TBL_TEMP1.COL_A AS A,    TBL_EXAMPLE.COL_B - TBL_EXAMPLE.COL_C AS DIFFFROM    (        SELECT            COL_ID,            COL_X * COL_X AS COL_A        FROM            TBL_NUMBER        WHERE            COL_ID > 100            AND COL_ID <= 1000    ) TBL_TEMP1JOIN    TBL_EXAMPLEON    TBL_TEMP1.COL_ID = TBL_EXAMPLE.COL_IDWHERE    TBL_TEMP1.COL_A <= 10000    AND (        TBL_EXAMPLE.COL_B > 0        OR TBL_EXAMPLE.COL_C < 0    )GROUP BY    TBL_EXAMPLE.COL_IDLIMIT    10; 



Author:忆之独秀

Email:leaguenew@qq.com

注明出处:http://blog.csdn.net/lavorange/article/details/51441695





0 0