Significant increases in productivity and understandability can result when data primitives are combined to create new, higher-abstraction data types. These higher-abstraction types add to the set of available types, and are then used syntactically in the same manner as the original primitive types.
For example, naval architecture applications could benefit from creation of new data types representing the hull characteristics and hull geometry of a ship. Such data types might be represented in pseudo-code as follows:
type HullCharacteristics {
float lbp; // length between perpendiculars
float lwl; // waterline length
float loa; // overall length
float b, h, d; // beam, draft, depth
float cb; // block coefficient
float cp; // prismatic coefficient
}
type HullGeometry {
float ss; // station spacing
float[] stations; // array of station numbers
float[][] y_offsets; // offset beam coordinates
float[][] z_offsets; // offset depth coordinates
}
Note that "float [ ] [ ]" represents a double-subscripted array
of floats.Given such type definitions, variables of these data types may then be declared in a manner analogous to that of declaring variables of primitve types:
Data Type Variable Variable
HullCharacteristics hull_1_char, hull_2_char;
HullGeometry hull_1_geom, hull_2_geom;
The individual variables, or "fields," comprising the abstract types
may be referenced using "dot notation:"
hull_1_char.lbp // LBP for hull 1 hull_2_char.lwl // LWL for hull 2 hull_1_geom.ss // station spacing for hull 1Arrays of the higher-abstraction types may also be created in the same manner as arrays of primitive types:
Array Data Type Variable Variable
HullCharacteristics[] series60_char, taylor_series_char;
HullGeometry[] series60_geom, taylor_series_geom;
The above two declarations using arrays of the abstract types define
variables representing all hull characteristics and geometry of both
Series60 and Taylor series hulls, yet with no more effort than that
required to declare four variables of primitive type. The productivity
benefit of data abstraction is clear, as is the readability of the
succinct code that accomplishes such a non-trivial task.