1. Loosely speaking, naming conventions fall into two categories: typographical and grammatical.
2. Package names should be hierarchical with the components separated by periods. Components should consist of lowercase alphabetic characters and, rarely, digits. The name of any package that will be used outside your organization should begin with your organization’s Internet domain name with the top-level domain first. Users must not create packages whose names begin with java or javax. The remainder of a package name should consist of one or more components describing the package. Components should be short, generally eight or fewer characters. Meaningful abbreviations are encouraged.
3. Class and interface names, including enum and annotation type names, should consist of one or more words, with the first letter of each word capitalized. Abbreviations are to be avoided, except for acronyms and certain common abbreviations. If multiple acronyms occur back-to-back, you can still tell where one word starts and the next word ends when you capitalize only the first letter of the acronyms.
4. Method and field names follow the same typographical conventions as class and interface names, except that the first letter of a method or field name should be lowercase.
5. A constant field is a static final field whose value is immutable, whose names should consist of one or more uppercase words separated by the underscore character.
6. Local variable names have similar typographical naming conventions to member names, except that abbreviations are permitted, as are individual characters and short sequences of characters whose meaning depends on the context in which the local variable occurs.
7. Type parameter names usually consist of a single letter. Most commonly it is one of these five: T for an arbitrary type, E for the element type of a collection, K and V for the key and value types of a map, and X for an exception. A sequence of arbitrary types can be T, U, V or T1, T2, T3.
8. For quick reference, the following table shows examples of typographical conventions:
9. There are no grammatical naming conventions to speak of for packages. Classes, including enum types, are generally named with a singular noun or noun phrase. Interfaces are named like classes, or with an adjective ending in able or ible.
10. Because annotation types have so many uses, no part of speech predominates. Nouns, verbs, prepositions, and adjectives are all common.
11. Methods that perform some action are generally named with a verb or verb phrase (including object). Methods that return a boolean value usually have names that begin with the word is or, less commonly, has, followed by a noun, noun phrase, or any word or phrase that functions as an adjective. Methods that return a non-boolean function or attribute of the object on which they’re invoked are usually named with a noun, a noun phrase, or a verb phrase beginning with the verb get. The form beginning with get is mandatory if the class containing the method is a Bean, and it’s advisable if you’re considering turning the class into a Bean at a later time. Also, there is strong precedent for this form if the class contains a method to set the same attribute.
12. Methods that convert the type of an object, returning an independent object of a different type, are often called toType.
13. Methods that return a view whose type differs from that of the receiving object are often called asType.
14. Methods that return a primitive with the same value as the object on which they’re invoked are often called typeValue.
15. Common names for static factories are valueOf, of, getInstance, newInstance, getType, and newType.
16. Grammatical conventions for field names are less well established and less important than those for class, interface, and method names, as well-designed APIs contain few if any exposed fields. Fields of type boolean are often named like boolean accessor methods with the initial is omitted. Fields of other types are usually named with nouns or noun phrases.
17. Grammatical conventions for local variables are similar to those for fields, but even weaker.
相关推荐
Item 68: Adhere to generally accepted naming conventions 10 Exceptions Item 69: Use exceptions only for exceptional conditions Item 70: Use checked exceptions for recoverable conditions and runtime ...
This includes guidelines on naming conventions, documentation, and performance optimization. #### Licensing and Distribution The book is licensed under a Creative Commons Attribution-NonCommercial-...
例句:Adhere to your own principle. (坚持你自己的原则) 10. adverse(不利的,有害的):形容词,常用于描述对某人或某事有负面影响的情况。 例句:Adverse circumstances can test a person’s wisdom and ...
4. adhere - 表示“粘附”或“遵守”,在法律、协议等语境中常指遵守规则,如:adhere to the contract terms (遵守合同条款)。 5. adjust - 意为“调整”或“调节”,常见于描述改变事物以达到最佳状态的情况,如...
- **The Common Type System (CTS)**: The CTS defines the types and structures that all .NET languages must adhere to, ensuring interoperability between different languages. - **The Common Language ...
例如:We must adhere to the deadlines set by the project manager. 27. adjacent:毗邻的。例如:The park is adjacent to the school, providing easy access for students. 28. adjust...to:调整以适应。例如...
16. **adhere to**:坚持,遵循,例如:adhere to my opinion(坚持我的观点)。 17. **adjust to**:调节,适应,例如:adjust to the new life(适应新生活)。 18. **take advantage of**:欺骗,利用,例如:...
This style of teaching is conducive to learning how to build real-world products that adhere to industry best practices. Additionally, Jordan has published multiple books on programming and computer...
3. adhere to - 坚持遵循,例如:We must adhere to the schedule. 4. ahead of - 在...之前,例如:She finished the project ahead of time. B部分: 1. bear upon - 对...施加影响,例如:The news will bear ...
例如:We should adhere to the principles of fairness and honesty. 26. adjacent:毗邻的,临近的。如:Our office is adjacent to the library. 27. adjust...to:调节,适应。例如:She quickly adjusted ...
例如:Adhere to your own principle. (坚持自己的原则) 10. adverse(不利的,有害的):形容词,常用来描述对人或事产生负面影响的情况。例如:Adverse circumstances can test a person’s wisdom and courage...
- **Conformance**: Chapter 3 details conformance, ensuring that implementations adhere to the standards set out by the specification. - **Normative References**: Chapter 4 lists normative references, ...
例如:We should adhere to the rules.(我们应该遵守规则。) 27. adjacent:毗邻的、临近的。例如:The two cities are adjacent.(两个城市毗邻。) 28. adjust:调节、适应。例如:I need to adjust the ...
26. `adhere to` 坚持,如:We need to adhere to our principles. 27. `adjacent` 临近的,如:The park is adjacent to the school. 28. `adjust...to` 适应,如:It takes time to adjust to a new job. 29. `...
此存储库已废弃 坚持 坚持是一个简单的基于模式的数据验证器,并努力实现合规性。 然而,与 JSONSchema 规范不同的是,坚持在类型定义的关键字强制方面非常自以为是。 坚持允许根据声明的模式直接验证原始数据类型...
例句:We must adhere to the principles of fairness and justice. 24. adjacent:毗邻的,临近的。 例句:The library is adjacent to the classroom building. 25. adjust…(to):调节,适应。 例句:He's ...
Take advantage of Angular Material, a UI component framework that works out of the box to design web pages that adapt to various screen sizes and adhere to Material Design specifications. This book ...
14. `adhere to`: 坚持,遵守 15. `after all`: 毕竟 16. `agree on`: 对……达成一致 17. `agree to`: 同意 18. `agree with sb.`: 同意某人的观点 19. `along with`: 和……一起 20. `alternate (with)`: 交替 21....