Posts

Showing posts from April, 2018

#13. Organize your code in classes

The minimal unit of code is a statement . The minimal unit of code which can be tested and reused is a function . Functions are rarely practical all by themselves; they are usually organized in modules which offer a set of operations which make as a whole. The class is the main semantical unit in object oriented programming. A class is an abstract data type with an associated implementation. As Bertrand Meyer puts it in Object Oriented Software Construction, 2nd Edition : Classes should be the only modules. These concepts will not be obvious in the integrated development environment you use to create your code. Usually, these IDEs let you create projects, and inside them, they let you add units or files. You know, of course, the C++ syntax; you know there are two keywords, class and struct , that let you define a type with its associated data members (fields) and operations (functions). You are probably aware of the difference between class and struct : the default visibili...