Differing implementations for a function in two interfaces

Chris Nicholson-Sauls ibisbasenji at gmail.com
Mon Apr 17 10:28:54 PDT 2006

Ryan Steen wrote:
> In article <e1vlnb$226i$1 at digitaldaemon.com>, Lionello Lunesu says...
>>IA might be an interface for the 
>>output/GUI and IB for the input.
> Yes, but what might cause the need to have the implementation in one class?
> And if there is really a need what hinders a virtual split of that implenting
> class?
> IA --> CA <-- C --> CB <-- IB
> where --> and <-- denote inheretance?

Here you lose encapsulation, wherein you are basically having to create a C, then ask it 
for its CA and later for its CB, and the CA/CB classes (inner classes, maybe?) have to 
know their parent object and ask it for the real data and behaviors.  Ew, ew, ew. 
(Although at least inner classes won't need the parent pointer, once we settle on some 
kind of 'parent' or 'outer' keyword.)

-- Chris Nicholson-Sauls

More information about the Digitalmars-d-learn mailing list