Sun 公司代码规范.docxVIP

  • 1
  • 0
  • 约8.38千字
  • 约 10页
  • 2023-01-05 发布于湖北
  • 举报
一般约定 Genaral Principles 1.Adhere to the style of the original. 保持最初的样式。 2.Adhere to the Principle of Least Astonishment. 遵守最小惊奇原则。 3.Do it right the first time. 第一次就应当做好。 4.Document any deviations. 对于任何背离都应当文档注释。 格式约定 Formatting Conventions 5.Indent nested code. 6.Break up long lines. 7.Include white space. 8.Do not use hard tabs. 不要使用 tab 键。 命名约定 Naming Conventions 9.Use meaningful names. 使用有意义的名称。 10.Use familiar names. 使用熟悉的名称。 11.Question excessively long names. 不要使用过长的名称。 12.Join the vowel generation. 13.Capitalize only the first letter in acronyms. 14.Do not use names that differ only in case. 不要使用只依赖于大小写来区分的名称。 包命名 Package Names 15.Use the reversed, lowercase form of your organizations Internet domain name as the root qualifier for your package names. 采用你组织的 Internet 域名的反转、小写形式作为包名称的根限定词。 16.Use a single, lowercase word as the root name of each package. 17.Use the same name for a new version of a package, but only if that new version is still binary compatible with the previous versin, otherwise, use a new name. 只有当包的新版本仍然与旧版本兼容时,对于包的新版本使用相同的名称,否则使用新名称。 类型命名 Type Names 18.Capitalize the first letter of each word that appears in a class or interface name. 对于类和接口名称只对每个单词的第一个字母大写。 类命名 Class Names 19.Use nouns when naming classes. 20.Pluralize the names of classes that group related attributes, static services, or constants. 对于成组的相关属性、静态服务和常量,类名称采用复数形式。 接口命名 Interface Names 21.Use nouns or adjectives when naming interfaces. 使用名词或形容词来命名接口。 方法命名 Method Names 22.Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a method name.] 方法名称中第一个单词小写,后续的每一个单词仅第一个字母大写。 23.Use verbs when naming methods. 24.Follow the JavaBeans conventions for naming property accessor methods. 命名属性访问方法遵守 JavaBeans 约定。 变量命名 Variable Names 25.Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a variable name. 变量名称中第一个单词小写,后续的每一个单词仅第一个字母大写。 26.Use nouns to name fields. 使用名词来命名成员变量。

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档