| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (16 out of 18)

Defining Classes in Bottom-Up Order

In order for a class to be fully defined, the class must have a name, and either an existing direct superior class (single inheritance), or an acceptable list of such classes (multiple inheritance). This information allows G2 to determine the class's inheritance path, add the class to the G2 class hierarchy, and thereafter instantiate the class on demand.

If you define classes top-down, completely specifying each one before defining any subclasses, each class becomes fully defined, and can be instantiated, as soon as you complete its definition. However, this order of creation is not always convenient. Therefore G2 does not require you to define a class's direct superior(s) before you name them in the class's definition.

This provision allows you to define classes in bottom-up order. A class definition with one or more direct superior classes that have not yet been defined does not add the new class to the hierarchy, and does not permit the class to be instantiated.

You can have any number of partially completed class definitions in a KB without affecting the class hierarchy or KB execution in any way. The Notes attribute of any such definition has an INCOMPLETE status, and states that one or more direct superior classes is not defined.

If many class definitions specify the same nonexistent superior class, defining the superior will complete all of the definitions that depend on it, and add them all to the hierarchy at once.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (16 out of 18)

Copyright © 1997 Gensym Corporation, Inc.