reference to an interface

Ryan Steen Ryan_member at pathlink.com
Sat Apr 8 23:02:41 PDT 2006


In article <e18ke5$2f95$1 at digitaldaemon.com>, Frank Benoit says...
>
>An interface is something like a promise.

But only something?
As I understand it now, an interface is a requirement and a promise; it
establishes a contract between three parties: client --- serverBoss ---
implementer.

For those classes inhereting from the interface it is a requirement, i.e. the
implementer must fulfill the requirements of his boss.

For the instantions of that interface such a class is promising to fulfill the
requirement, i.e. the client requests the server to fulfill his promise.

But if so, then the interface opens only a view to the class fulfilling the
promise. The class itself, which may fulfill also the promises of other
interfaces, is of no interest and should be kept private.

But if it is private one cannot instantiate it and one needs a function
"resolve". But this function cannot be private and therefore is not allowed to
belong to the interface.

But it is a requirement and should go into an interface ....

What I mean is, that when I am a client, then I want to code

module client; // I am the client
import serverboss; // provides me with the declaration of the interface I
import implementer1; // provides me with an implementation of the interface I
import implementer2; // ... another implementation of I
int main()
{
serverboss.I i;
implementer1.resolve( i);
// some code omitted
implementer2.resolve( i);
// code going on
}





More information about the Digitalmars-d-learn mailing list