You are previewing Code Complete, Second Edition.

Code Complete, Second Edition

Cover of Code Complete, Second Edition by Steve McConnell Published by Microsoft Press
O'Reilly logo

Good Routine Names

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


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. ...

The best content for your career. Discover unlimited learning on demand for around $1/day.