Sunday, October 13, 2013


There's some notes about "Naming" which I learned from "The Practice of Programming" by Brian W. Kernighan and Rob Pike. It's base on the book "The C Programming Language".
  • use descriptive names for globals, short names for locals
  • local variable
    • i and j for loop indices
    • p and q for pointers
    • s and t for strings
  • Programmers are often encourage to use long variable names regardless of context. This is a mistake: clarity is often achieved through brevity. (清楚與否需要透果簡潔以實現)
  • initial capital letters for Globals, all capitals for CONSTANTS
  • be consistent
  • use active names for functions
    • ex. getTime(), putChat()
    • bool functions: isoctal()
  • be accurate