Skip to content

Meaning Full Names

  • Use Intention-Revealing Names
  • Do not refer to a grouping of accounts as an accountList unless it’s actually a List . Because List as a different intent.
  • Do not use Lower case L and Upper Case O especially in combination
  • Make Meaningful Distinctions

    Do not Use like this the truly hideous practice of creating a variable named klass just because the name class was used for something else.

  • Use Pronounceable Names
  • Use Searchable Names

    single-letter names can ONLY be used as local variables inside short methods.

    Avoid Encodings:

    do not use encoding names because they are not esay to pronounceable.

  • Do not use Hungarian Notations
  • don’t need to prefix member variables with m_ anymore.
  • Do not write IshapeFactory and CshapeFactory we no need to tell which is interface and class.
  • Avoid Mental Mapping:

  • do not take like this using the name c than because a and b were already taken.
  • single-letter names for loop counters are traditional.
  • Classes and objects should have noun or noun phrase names like Customer.
  • Methods should have verb or verb phrase names like postPayment , deletePage.
  • don’t use the name whack() to mean kill() .
  • Pick One Word per Concept:

    add method performs add a value to the list and also add two numbers. Do not write like this.

    Don’t Pun

    Avoid using the same word for two purposes

    Use Solution Domain Names

    use computer science (CS) terms, algorithm names, pattern names, math terms, and so forth.

    Use Problem Domain Names

    Separating solution and problem domain concepts is part of the job of a good programmer and designer.

    Add Meaningful Context

    Imagine that you have variables named firstName , lastName , street , houseNumber , city , state , and zip code instead of this take like this addrFirstName , addrLastName , addrState , and so on.

    Don’t Add Gratuitous Context

    If I need to differentiate between MAC addresses, port addresses, and Web addresses, I might consider PostalAddress , MAC , and URI.