Good Routine Names

A good name for a routine clearly describes everything the routine does. Here are guidelines for creating effective routine names:

Cross-Reference

For details on naming variables, see Chapter 11.

Describe everything the routine does. In the routine's name, describe all the outputs and side effects. If a routine computes report totals and opens an output file, ComputeReportTotals() is not an adequate name for the routine. ComputeReportTotalsAndOpen-OutputFile() is an adequate name but is too long and silly. If you have routines with side effects, you'll have many long, silly names. The cure is not to use less-descriptive routine names; the cure is to program so that you cause things to happen directly rather than with side effects. ...

Get Code Complete, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.