正在加载图片...
174 THE STATIC STRUCTURE:CLASSES $7.5 Some features will be represented by time,that is to say by defining a certain computation (an algorithm)applicable to all instances of the class.They will be called routines.For points,rho and theta are routines in cartesian representation;x and y are routines in polar representation. A further distinction affects routines (the second of these categories).Some routines will return a result,they are called functions.Herex andy in polar representation,as well as rho and theta in cartesian representation,are functions since they return a result,of type REAL.Routines which do not return a result correspond to the commands of an ADT specification and are called procedures.For example the class PO/NT will include procedures translate,rotate and scale. Be sure not to confuse the use of"function"to denote result-returning routines in classes with the earlier use of this word to denote the mathematical specifications of operations in abstract data types.This conflict is unfortunate,but follows from well-established usage of the word in both the mathematics and software fields. The following tree helps visualize this classification of features: Feature Feature classification, No result:Command Returns result:Ouery by role Arguments, No argument Procedure Computation, Memory Function Function Attribute ROUTINE This is an extemal classification,in which the principal question is how a feature will look to its clients (its users). We can also take a more internal view,using as primary criterion how each feature is implemented in the class,and leading to a different classification:174 THE STATIC STRUCTURE: CLASSES §7.5 • Some features will be represented by time, that is to say by defining a certain computation (an algorithm) applicable to all instances of the class. They will be called routines. For points, rho and theta are routines in cartesian representation; x and y are routines in polar representation. A further distinction affects routines (the second of these categories). Some routines will return a result; they are called functions. Here x and y in polar representation, as well as rho and theta in cartesian representation, are functions since they return a result, of type REAL. Routines which do not return a result correspond to the commands of an ADT specification and are called procedures. For example the class POINT will include procedures translate, rotate and scale. Be sure not to confuse the use of “function” to denote result-returning routines in classes with the earlier use of this word to denote the mathematical specifications of operations in abstract data types. This conflict is unfortunate, but follows from well-established usage of the word in both the mathematics and software fields. The following tree helps visualize this classification of features: This is an external classification, in which the principal question is how a feature will look to its clients (its users). We can also take a more internal view, using as primary criterion how each feature is implemented in the class, and leading to a different classification: Feature classification, by role Procedure Function Function Attribute No result: Command Returns result: Query Arguments No argument Computation Memory Feature ROUTINE
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有