Thursday, April 23, 2009

On Naming

Good naming is the key to good design. Here is the best discussion of naming (in programming) that I have ever come across. It comes from a 1996 book called Smalltalk With Style. The authors have generously made their book freely available.

It takes a while to download, so here are the good bits (20 images). I'm a fan of Guideline 11: "Use predicate clauses or adjectives for Boolean objects or states". For example, motorRunning is a great name for a boolean field.





















6 comments:

  1. Nice recommendation.
    thanks
    Michele

    ReplyDelete
  2. Beck and Cunningham say "searching for just the right words is a valuable use of time while designing". Amen!

    ReplyDelete
  3. Another good guide: http://journal.stuffwithstuff.com/2009/06/05/naming-things-in-code/

    ReplyDelete
  4. Thanks John! I'll check it out.

    I also like the "Naming Classes" chapter starting on p.178 of the Hacknot book. You can download the free PDF version here

    http://www.lulu.com/content/517813

    ReplyDelete
  5. Thanks, David—Hacknot looks interesting

    ReplyDelete