When you program, you create a concrete representation of the ideas in your solution to someproblem. Let the structure of the program reflect those ideas as directly as possible:
If you can think of ‘‘it’’ as a separate idea, make it a class.
If you can think of ‘‘it’’ as a separate entity, make it an object of some class.
If two classes have a common interface, make that interface an abstract class.
If the implementations of two classes have something significant in common, make that commonality a base class.
If a class is a container of objects, make it a template.
If a function implements an algorithm for a container, make it a template function implementing the algorithm for a family of containers.
If a set of classes, templates, etc., are logically related, place them in a common namespace.
When you define either a class that does not implement a mathematical entity like a matrix or acomplex number or a low-level type such as a linked list: