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

Laying Out Classes

This section presents guidelines for laying out code in classes. The first subsection describes how to lay out the class interface. The second subsection describes how to lay out the class implementations. The final subsection discusses laying out files and programs.

Laying Out Class Interfaces

In laying out class interfaces, the convention is to present the class members in the following order:


For details on documenting classes, see "Commenting Classes, Files, and Programs" in Commenting Techniques. For a discussion of the differences between good and bad classes, see Chapter 6.

  1. Header comment that describes the class and provides any notes about the overall usage of the class

  2. Constructors and destructors

  3. Public routines ...

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