Changes for page Expressive Names
Last modified by chrisby on 2023/11/18 17:45
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -13,10 +13,10 @@ 13 13 #### Do's 14 14 15 15 * **Names describe purpose.** For example, it's better to have a variable `unorderedNumbers` which is sorted and then stored in `orderedNumbers` than to have a variable `numbers` to which the lists are assigned before and after sorting. 16 +* **Make differences clear.** Avoid very similar expressions and redundant empty words (a, an, the, info, data). 16 16 * **Use pronounceable names.** Programming is a social activity that people talk about with others, so use names that are easy to use in conversation. 17 17 * **Use searchable names.** Searchable means avoiding search conflicts with other independent things with the same name. The length of a name should match the size of its scope. For local counting loops, one letter is sufficient; if the variable is used in multiple places in the code, it needs a longer name. 18 18 * **Dare to rename things.** Your colleagues should be grateful for improvements. 19 -* **Add meaningful context.** By including the names of other variables and methods, this context can be created to make its purpose clearer than without context. Names can be chosen to work well with others. 20 20 21 21 #### Don'ts 22 22 ... ... @@ -25,6 +25,6 @@ 25 25 * **Avoid mental mappings.** The name of a variable should not require mental effort to understand. For example, unusual abbreviations should be avoided. 26 26 * **No puns or humorous names.** 27 27 * **Avoid ambiguities** such as the word "add", which could have the meaning of "addition" or " adding". 28 -* **Avoid very similar expressions** to make differences clear.29 -* **A voidredundant emptywords**(a,an,the,info,data).28 +* 29 +* **Add meaningful context.** By including the names of other variables and methods, this context can be created to make its purpose clearer than without context. Names can be chosen to work well with others. 30 30 * **Do not add unnecessary context.** Shorter names are better than longer ones, as long as they are clear.