gmplImplementsStatement

Implements Statement Summary

Implements is a terminal FileFilter oriented refactoring statement that only occurs within Refactor statements. This external Implements statement is processed in the same way as Implements commands in CLS files are processed by gmBasic. It specifies that the class be refactored to implement the interface defined by the class specified with this statement. There are, of course, differences in the naming conventions. For Refactor Implements the names of components satisfying the interface must match exactly as opposed to being preceded the class name and an underscore.

The attributes of the Implements statement are as follows:

Attribute Description
Interface This attribute contains the identifier of the class whose interface is being implemented by the class identified in the FileFilter attribute of the parent Refactor statement.

Though at a superficial level VB6 interfaces appear to be the same as those in the established OOPs, there are several very important differences. First of all, any class can serve as an Interface for another class. An interface class is created in the same manner as any other class. It is this fact that makes this refactoring statement possible. The significance of this is that gmBasic does not need know that a given class is an interface until some other class implements it. Second of all, VB does not support "implementation inheritance", it supports "interface inheritance". What this really means is that a Vb6 class that is used later as an interface can contain not only implementation logic which is only used if an object of that class is created, but the class can contain other components as well which are not part of the interface. The explicitly "Public" methods and properties of the interface class are what must be implemented, but it is not even necessary for the component types to correspond directly as the following working VB6 code shows.


   Attribute VB_Name = "PersonalData"
   Public Name As String
   Public Address As String

   Implements PersonalData
   Private Property Get PersonalData_Address() As String
      PersonalData_Address = "SupplierAddress"
   End Property
   Private Property Let PersonalData_Address(ByVal RHS As String)
   End Property
   Private Property Let PersonalData_Name(ByVal RHS As String)
   End Property
   Private Property Get PersonalData_Name() As String
     PersonalData_Name = "SupplierName"
   End Property
Components defined as fields in the interface file are implemented as properties. Note also if the interface had been asserted via the refactoring statements, the above properties would be assumed to have the simpler identifiers -- Name and Address.
Table of Contents