[AccessD] Framework Discussion - Implements

Ken Ismert KIsmert at TexasSystems.com
Tue Mar 16 12:57:35 CST 2004


Ryan,

Implements means that a class exposes an interface defined by another class.
An interface is simply the method signature of a class, that is, the names
and parameter lists of all its public properties and methods. The
implementer is responsible for two things: it must implement the entire
interface, and it must provide all the functionality and code required to
support the interface.

Inheritance means that a class not only gets the interface of another class,
but its code and functionality as well. The inheritor is relieved from
having to implement the inherited interface, or to provide redundant
functionality. Think of it as compiler-level wrapping. The inheritor can
override certain methods and properties of the inherited class with its own,
and it can add new methods and properties to extend the inherited class.

Inheritance is more powerful than Implements. Implements is supported in
VB6, A2K and later, while Inheritance is not.

VB6/A2K supports polymorphism through interfaces. A class can implement more
than one interface, and so appear as different object types to different
users.

-Ken

PS. Regarding John's quote:

>In other words, you define a class with PUBLIC variables (generally
>considered a no-no) and a bunch of method and property STUBS.  Once you
have
>done that you create other classes that "implements" the parent class.  It
>appears that the parent class' public variables magically become private in
>the class that implements the parent object ...

To clarify, Public variables are simply a way of defining properties in a
class. Thus, these two classes are identical:
  [Class1]
    Public Value As Long
  [Class2]
    Private mlValue As Long
    Property Let Value(ValueIn As Long)
        mlValue = ValueIn
    End Property
    Property Get Value() As Long
        Value = mlValue
    End Property

Public variables, while quick, give you less flexibility, because they are
inherently read/write.

The point is, if you use Implements Class1 in another class, you will only
get the property signature:
    Property Let Class1_Value(ByVal RHS As Long)

    End Property
    Property Get Class1_Value() As Long

    End Property

So, it is rather pointless to use public variables in your interface
definitions. Stick with stub properties and methods.


-----Original Message-----
From: rsmethurst at UK.EY.COM [mailto:rsmethurst at UK.EY.COM]
Sent: Tuesday, March 16, 2004 10:06 AM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Framework Discussion - Implements


Hi All,

In light of all the mails about classes, frameworks and implementation
etc. (most of which I am finding very interesting).

Could someone explain to me the difference between the  'Implements'
statement and how this is differs from inheritance.

Thanks
Ryan




More information about the AccessD mailing list