C++ Class Construct  «Prev  

Orthogonal Class Design

An orthogonal class design is an attempt to build a minimal set of operations that gives a user a complete interface to the class. For example, you would not normally have two volume controls on a radio. Also, on a radio with multiple bands, you are given a control to switch between bands and a separate control to position within a band.
This is an orthogonal design, and it would be possible to have separate controls for each band, but that would proliferate the number of controls unnecessarily. Prefer a design that favors the client over the class implementor. The client must be sold on the class. If a client of a class needs a highly efficient runtime class, then that requires a complex implementation. The class implementor must meet that requirement or the class will not be used.

Orthogonal Data Object

In computer terminology, a programming language or a data object is orthogonal if it can be used without consideration as to how its use will affect something else. A programming language is orthogonal if its features can be used without thinking about how that usage will affect other features. C++ is considered to be a non-orthogonal language.

Orthogonality Programming Language

Orthogonality in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language. The term is most-frequently used regarding assembly instruction sets, as orthogonal instruction set.
Features of a program that is compatible with its own earlier versions - this is called backward compatible, have an orthogonal relationship with the features of the earlier version, because they are mutually independent; you don't have to worry about how the use of one version's features will cause an unintended effect because of an interaction with those of the other version. Both the features and the programs can be said to be mutually orthogonal.

Big C++

Orthogonal persistence

The length of time data is kept in storage in a computer system is known as its persistence. Orthogonal persistence is the quality of a programming system that allows a programmer to treat data similarly without regard to the length of time the data is kept in storage. Data is stored for varying lengths of time; some is stored very briefly and some is stored relatively permanently. Frequently, a programmer must use different approaches and separate coding to access data depending on whether it is stored for a long time or a short time. Using a programming system with orthogonal data persistence allows the programmer to treat data the same way regardless of its persistence characteristic, saving programming time and making it easier to enforce referential integrity (a type of constraint applied to ensure correct data validity).

Class Hierarchy of Rectangular Box

The defining properties of a Box object are just the three orthogonal dimensions. You can apply this basic definition to the many different kinds of rectangular boxes that you find in the real world: cardboard cartons, wooden crates, candy boxes, and cereal boxes. All these have three orthogonal dimensions, and in this way they are just like generic Box objects. However, each of them has other properties such as the things they are designed to hold, or the material from which they are made. You could describe them as specialized kinds of Box objects. For example, a Carton class could have the same properties as a Box object(namely three dimensions) plus the additional property of its composite material. You could then specialize even further by using the Carton definition to describe a FoodCarton class, which is a special kind of Carton that is designed to hold food. A FoodCarton object will have all the properties of a Carton object and an additional member to model the contents. A Carton object has the properties of a Box object so a FoodCarton object will have those as well.

Class Carton inherits from class Box, class FoodCarton inherits from ClassCarton.
Class Carton inherits from class Box, class FoodCarton inherits from ClassCarton.
The connections between classes that express these relationships are shown in Figure 3-12. The Carton class is an extension of the Box class. You might say that the Carton class is derived from the Box class. In a similar way, the FoodCarton class has been derived from the Carton class. It is common to indicate this relationship diagrammatically by using an arrow pointing toward the more general class in the hierarchy. This notation is called UML (Universal Modelling Language) and which is used in Figure 3-12.