Naming

  • Use names that show what your code does.int d could be int day

  • Avoid misinformation. if accountsList. is not a list, it should have a better name.

  • Make a good distinction of your variables. CustomerData, Costumer and CostumerInfo. What's the difference between then?

  • Use names that you can pronounce. If you pair, you don't need to refer to a variable as wpdw. A workDaysPerWeek sounds better.

  • Use searchable names. Have you tried to search for a variable called f?

  • Avoid prefixes. If the variables start with icsd, like icsd_name or icsd_date we'll have a hard time to find what we are looking for.

  • Avoid mind mapping. When we use a huge quantity of variables that don't make much sense, we need to memorize what they are meanwhile we are trying to figure out what the code does.

  • Class names. Should be nouns, and not verbs, because classes represent concrete objects. They are the representation of things.

  • Methods names. Should be verbs, and not nouns, because methods represent actions that objects must do.

  • Add context. If you bump on a variable state alone, probably will have a hard time to figure out what it means. street and number it's easier to understand what it does.

  • Add context, but not for free. We are working on a project called chocolate ice cream. We don't need to add CIC in front of all variables. User class, we don't need to call all the variables userAdress, userAge or userFavoriteColor.

Last updated

Was this helpful?