Changes for page Expressive Names

Last modified by chrisby on 2023/11/18 17:45

From version 1.2
edited by chrisby
on 2023/11/17 21:53
Change comment: There is no comment for this version
To version 1.5
edited by chrisby
on 2023/11/18 13:27
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,45 +1,35 @@
1 -1.
1 +Names should be chosen as carefully as one would name their firstborn child.
2 2  
3 -**Meaningful and Descriptive Names**
4 - * Choose names carefully, as if naming a child.
5 - * Names should reflect the code's purpose clearly. For example, use unorderedNumbers and orderedNumbers instead of a generic numbers.
6 -1.
3 +**Naming Conventions**
7 7  
8 -**Avoid Misinformation**
9 - * Steer clear of ambiguous, easily confused names or characters (e.g., l vs. 1, O vs. 0).
10 -1.
5 +* **Choose Meaningful and Descriptive Names**
6 + * Names should be descriptive of the purpose, e.g., use `unorderedNumbers` and `orderedNumbers` instead of a generic `numbers`.
7 + * Use names that reflect the solution domain and the problem domain.
8 + * Choose one word per concept (e.g. consistently use 'fetch' for the same concept, rather than mixing 'fetch' and 'retrieve').
9 +* **Clarity and Simplicity in Names**
10 + * Names should be self-evident and avoid mental mappings or translations for clarity.
11 + * Avoid ambiguities, such as confusion with similar names or characters (e.g., l and 1, O and 0).
12 + * Make differences clear and avoid very similar expressions.
13 + * Avoid superfluous or redundant context; shorter names are better as long as they are clear.
14 +* **Practical Aspects of Naming**
15 + * Use pronounceable names so that you can easily talk with others about it.
16 + * Use searchable names, meaning names which prevent search conflicts.
17 + * The length of a name should correspond to the size of its scope. E.g. counters only used locally in loops, could be short or even single letters, but names used in a broad scope should be more descriptive and longer.
18 + * Avoid encodings, such as references to the variable's scope or type in its name.
11 11  
12 -**Clarity in Differences**
13 - * Distinguish names distinctly, avoiding similar expressions and redundant words (e.g., a, an, the, info, data).
14 -1.
20 +**Class and Method Naming**
15 15  
16 -**Pronounceable and Searchable Names**
17 - * Use names that are easy to pronounce and discuss.
18 - * Name length should match its scope: short for local loops, longer for broader usage.
19 -1.
22 +* **Class Names**
23 + * Should consist of nouns or noun phrases.
24 +* **Method Names**
25 + * Should consist of verbs or verb phrases.
26 + * Follow the JavaBean standard for accessors, mutators, and predicates (prefixes: get, set, is, has).
27 + * Use distinct names for overloaded constructors and prefer private constructors with distinct factory methods.
20 20  
21 -**No Encodings or Mental Mappings**
22 - * Avoid including type or scope information in names.
23 - * Names should be clear without requiring mental translation.
24 -1.
29 +**General Coding Practices**
25 25  
26 -**Naming Conventions for Classes and Methods**
27 - * Class names: Use nouns or noun phrases.
28 - * Method names: Use verbs or verb phrases, adhering to standards like JavaBean (get, set, is, has). Utilize descriptive function names instead of overloaded constructors.
29 -1.
30 -
31 -**Avoid Inappropriate Humor and Ambiguities**
32 - * Refrain from humorous names.
33 - * Choose one word per concept to maintain consistency (e.g., always use "get" instead of alternating with "fetch" or "retrieve").
34 - * Avoid puns and ambiguous terms (like "add" for addition or appending).
35 -1.
36 -
37 -**Domain-Specific Naming**
38 - * Use technical terms (solution domain) for clarity among programmers.
39 - * Use terms from the problem domain when no technical equivalents exist, aiding domain experts.
40 -1.
41 -
42 -**Context and Simplicity in Naming**
43 - * Provide meaningful context through combined variable and method names.
44 - * Avoid unnecessary context; opt for shorter, meaningful names.
45 - * Be open to renaming for clarity and improvement.
31 +* **Avoiding Confusion and Misinformation**
32 + * Avoid humorous names, puns, and any names that might cause confusion.
33 +* **Contextual Naming**
34 + * Add meaningful context that complements other variable and method names.
35 + * Dare to rename things for clarity and improvement; colleagues should appreciate these enhancements.