Friday, May 16, 2014

Agile in a Flash 43

Agile in a Flash by Jeff Langr and Tim Ottinger (card #43)

> Are accurate
> Are purposeful
> Are pronounceable
> Begin well
> Are simple
> Depend on context
> Match name length to scope

--

Are accurate. Do not mislead the reader. Naming a user’s postal code birthDate might infuriate co-workers! Characters like O and l can fool readers into seeing the digits 0 and 1.
Are purposeful. Describe the intended use of a thing, not its origin or composition. Variable names like text and psz lack intention.
Are pronounceable. Pronounceable names are easily recognized and discussed. We want to talk about the code without sounding crazy.
Begin well . Leading differences stand out, but differences in the middle or end of names can be hard to spot.
Are simple. Long names are more descriptive but less distinct than short ones. Encoded prefixes and suffixes make differences between names subtle. Don’t try to cram too much meaning into a name.
Depend on context. The fully qualified name is the real name. The local name is just the nickname.
Relate name length to scope. Names in very small scope (short loops, closures) can be small. Names visible from many places must be extra descriptive.
See Clean Code [Mar08] for Tim’s exhaustive guide to naming.

"What's in a name? That which we call a rose

By any other name would smell as sweet." ~Juliet (Shakespeare)

No comments:

Post a Comment