4.7
Types versus classes
One of the open issues within the object-oriented community is the discussion of type
versus class. Is it the same or should there be a distinction. Traditionally it has been
considered a great advantage that class/subclass relations also define type/subtype relations.
However, as mentioned above, subclassing and redefinition has been used a lot to obtain
code reuse, leading to subclasses without any conceptual relations to their superclasses.
Consequently, it is now more common to distinguish between classes and types. In this
section we shall try to summaries the discussion and some of the various point of views.
The main arguments for distinguishing between type and class are: a type defines the
interface of a set of objects and a class defines its implementation; for a given type there
may be many different implementations; a subclass of a given class does not necessarily
define a subtype of the type implemented by the type of the class; and specification and
interface should be kept separate.
Do'stlaringiz bilan baham: |