vendredi 28 avril 2017

Public interface, internal functionality

I have an interface which is currently public. This is passed to the client as a representation of a type (same application but I cannot modify calling code beyond changes types).

A -> B.GetIntrerface();

A -> B.SendInterface(A.InterfaceIGot);

Is essentially what I'm saying here.

With that in mind, if I want to have internal functionality (so that the caller cannot see it), and I do not want to pass a concrete class to the caller, is there a design pattern that supports this?

Can I do:

A.otherInterface = A.instanceOfB.GetInterface();
instanceOfB.SendInterface(A.otherInterface);

Where otherInterface is public.

And internally in SendInterface ?

A.DoSomethingInternal();

I know I could downcast, but it seems messy. Is there an established design pattern for this?

Thanks!

Aucun commentaire:

Enregistrer un commentaire