Home Segments Index Top Previous Next

259: Mainline

When it comes to class implementation, you should adhere to a principle that applies not only to class implementation, but also to programming in general:

The modularity principle: Generally, you should divide your large programs into logically coherent modules, each of which occupies its own file. A first step to take in this direction is to separate your class definitions from your ordinary functions. A second step is to separate your class definitions along family lines.

As it stands, the program in Segment 239 is so short, many programmers would keep all of it in one file. On the other hand, were it to grow much larger, most programmers would divide the functions and class definitions of the program into files devoted to, say, the following program elements:

You learn about how to do such a division, using header files, in the hardcopy version of this book.