Skip to content

Instantly share code, notes, and snippets.

View davegonzalez's full-sized avatar
:shipit:

David Gonzalez davegonzalez

:shipit:
View GitHub Profile

Selections from Clean Code: A Handbook of Agile Software Craftmanship

Chapter 2: Meaniningful Names

  • Avoid disinformation
  • Make meaninful distinctions
    • Imagine that you have a Product class. If you have another called ProductInfo or ProductData, you have made the names different without making them mean anything different. Info and Data are indistinct noise words as well.
    • Noise words are redundant. How is NameString better than Name? Would a Name ever be a floating point number? Doing so would cause disinformation.
    • Imagine finding one class named Customer and another named CustomerObject - what should you understand as the distinction?
  • Class names
    • Classes and objects should have noun or noun phrase names like Customer, Wikipage, Account, and AddressParser. Avoid words like Manager, Processor, Data, or Info in the name of a class.