Browse Prior Art Database

Objects with Multi-Personality

IP.com Disclosure Number: IPCOM000114514D
Original Publication Date: 1994-Sep-01
Included in the Prior Art Database: 2005-Mar-28
Document File: 2 page(s) / 32K

Publishing Venue

IBM

Related People

Chow, AC: AUTHOR [+3]

Abstract

In Object-Oriented System Object Model (SOM) programming environment, programmers usually have a same object that need to behave differently under different context. one way of implementing this kind of objects is to have an instance variable that keeps track of the object's current contexT and use "switch" or "case" statements to render different behaviors in different context. This approach is not only cumbersome for programmers but also inefficient during runtime.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 100% of the total text.

Objects with Multi-Personality

      In Object-Oriented System Object Model (SOM) programming
environment, programmers usually have a same object that need to
behave differently under different context.  one way of implementing
this kind of objects is to have an instance variable that keeps track
of the object's current contexT and use "switch" or "case" statements
to render different behaviors in different context.  This approach is
not only cumbersome for programmers but also inefficient during
runtime.

      In this new solution, a generic SOM base class is implemented
to define a set of class interfaces.  For each possible context, we
subclass from the base class into a new SOM class that overrides only
the class interfaces defined in its parent class and implement the
particular behaviors for that context.  During runtime, we
instantiate an object from the base class.  According to the initial
context of the object, the object's method table is replaced by the
method table of a corresponding subclass.  Whenever the context of
the object is changed, a programmer can change the object's method
table to the one of the correct subclass and thus change the behavior
of the object instantly and completely.  A prerequest is that there
should be no instance variable introduced in the subclasses for any
multi-personality objects.  They should only be defined within the
generic base class.