type HullCharacteristics {
// Field Access Methods
method setLBP (float lbp_value) {
if (lbp_value > 0.0) {
lbp = lbp_value;
}
}
float method getLBP( ) {
return (lbp);
}
}
The method definitions are comprised of two parts - a specification
and a body.
Method Specification Method Body
method setLBP (float lbp_value) { if (lbp_value > 0.0) {
lbp = lbp_value;
}
}
float method getLBP( ) { return (lbp);
}
The specification declares the method name, input arguments and
return type. The body defines the executable code of the method.
From a design standpoint, the specification is the most important
part of the method as it defines the invocation protocol.
The invocation protocols of all methods of the abstract
data type define the "interface" to the abstract type.Changes to the program after it is first released inevitably require changing either the data fields of the abstract type, its method bodies, or both. However, by investing adequate thought and design up front, the interface to the abstract data type will not change. Such a well-designed abstract type is said to have a "stable interface," i.e., method invocation protocols that do not change when the data fields and method bodies of the data type change.
Designing a stable interface for an abstract data type can be challenging, but is well worth the invested design effort. This is because a stable interface, combined with information-hiding and data encapsulation, help ensure that no part of the program outside of the affected abstract data type will be aware of changes to the abstract type. Thus, the impact of changes is limited to the abstract data type itself. The code for other abstract types will be unaffected since they only see the interface which, being stable, does not change. This simplifies maintenance of the program, which in turn significantly reduces overall cost of the software.