Page-2

[Back][Next] up.gif (995 bytes)

A class is a programming implementation unit: for all instances of that class, it defines the procedural methods and data stored as instance variables. Each method can read and modify the instance variables of that instance, and can communicate with other objects referred to via those instance variables or passed in as parameters to the method.

A type is a modeling and specification construct applicable to OO code, but also to lots of other things. Is abstracts algorithmic or procedural behaviors with specifications of actions; and abstracts data or information representation by attributes. Every method implementation must meet the net result specified by the action specification; and the stored data must represent enough information in some form so that every attribute can be determined from that representation.

A class implements some (number of) types(s). Each type can be implemented by some (number of) class(es).

For example, a class Product may implement the type Sellable, by providing methods for each operation defined on Sellable, and a particular set of stored instance variables to represent the abstract state required by that type. Another class Service can also implement Sellable, with very different implementations of its methods and different instance variables to represent the sale of services.

The same class Product can also implement a different type ReStockable; the class Service is not likely to implement this type.

One type can be defined as an extension of another i.e. as a subtype of another. The subtype has at least all the attributes and action specifications that the supertype has.

One class can have its implementation defined as an extension or modification of another class. The subclass inherits all instance variables and methods from the superclass. It may add more instance variables and methods, and can override selected methods implementations from its superclass with its own.

An abstract class is a partial implementation unit: it cannot be instantiated on its own as it has certain pieces missing (typically, method implementations) that need to be filled in by a subclass.