Clean Code Naming Principles: Lessons from Robert C. Martin

5 min read

Robert C. Martin's "Clean Code" dedicates an entire chapter to naming. Here are the key principles.

Core Rules

  • Use intention-revealing names: The name should answer why it exists and what it does
  • Avoid disinformation: Don't call something a "list" if it's not a list
  • Make meaningful distinctions: source and destination not a1 and a2
  • Use pronounceable names: generationTimestamp not genymdhms
  • Use searchable names: Named constants instead of magic numbers
  • Avoid encodings: No Hungarian notation, no member prefixes
  • Class names are nouns: Customer, Account, AddressParser
  • Method names are verbs: save(), deletePage(), postPayment()

Convert Names

Use the case converter hub to format names for any convention.