When a client needs to refer to elements of a Class object that are implemented
through an Interface class, the client must refer to the Interface by name to
use the Interface elements.
There are two basic methods for referring to Interface elements within a class
from client code. Both these methods assume that you have instantiated an object
from a class that uses an Interface for all or part of its functionality:
-
Declare an object variable in the client whose type is the Interface class
and set that object variable to point back to another object that you have already
instantiated from the server's implementing class. You can then manipulate the
Interface-type variable to manipulate the Interface-provided elements of the implementing
client object.
-
Write wrapper routines in the client to manipulate various elements of the
Interface. Each such routine will take as its parameter an object whose type is
the Interface class. When you call the routines, however, you pass an instantiated
object from the server's implementing class.
The following two sections discuss these methods.
-
Method A: Using an Object Variable in the
Client
-
Method B: Using Wrapper Routines in the Client