Chapter 4. Names


Chapter 4. Names

The creation of a good mental model is one of the key challenges in developing software. There are several tools people use to help with this:

  • Project dictionaries

  • Domain vocabularies, ontologies, languages

  • XP-style metaphors

How we name things is important. Good names perform several functions:

  • They provide a vocabulary for discussing our domain.

  • They communicate intent.

  • They support subtle expectations about how the system works.

  • They support each other in a system of names.

It's hard to pick good names, but it's worth the effort. Ward Cunningham describes using a thesaurus to get just the right sense (see http://c2.com/cgi/wiki?SystemOfNames ).

Some teams have coding standards and naming standards that affect how names are chosen . I generally follow these guidelines:

  • Use verbs for manipulators and nouns and/or adjectives for accessors.

  • Use the same word for similar things and different words for different things.

  • Prefer one-word names.

  • Value communication most.

Especially with tool support, it's not that hard to change a name when you realize there's a better one. It's worth investing energy in improving names as you modify code.



Refactoring Workbook
Refactoring Workbook
ISBN: 0321109295
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net