Interfaces, Big Deal!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jay B. Harlow [MVP - Outlook]

    #31
    Re: Interfaces, Big Deal!!

    Franco,[color=blue]
    > Ok, I see, on this case Interface and Implementation are coming on couple
    > and I have just one implementation for my code.
    > But still I don't see how ShapeImpl will access to my protected methods[/color]
    and[color=blue]
    > private variables from Circle because is a object into the Circle object.
    >[/color]
    Are the protected methods inherited or added to Circle. If you added them to
    Circle should they have been added to ShapeImpl instead?

    Are they private variables added to Circle itself, should they have been
    added to ShapeImpl instead?

    For methods you will need to structure the method such that the
    Implementation class (ShapeImpl) will be able to see it. Either via an
    interface of Friend.

    Alternatively ShapeImpl can have call backs (either delegate fields or full
    events) that it uses to call into Circle when it needs information from
    Circle.

    For variables I would either make them a member of the Implementation class
    itself or pass them as parameters when I call into the Implementation class.
    Normally I would set it up such that each instance of Circle had its own
    ShapeImpl, which means that ShapeImpl can hold per instance variables of
    Circle, in which case ShapeImpl would not need to access details of Circle.

    Hope this helps
    Jay


    "Franco Gustavo" <gfranco@inunti us.com> wrote in message
    news:e3bJtoniDH A.3660@tk2msftn gp13.phx.gbl...[color=blue][color=green]
    > > As Sherif stated, .NET does not have Multiple Implementation[/color][/color]
    Inheritance,[color=blue][color=green]
    > > one common method to get around this is to have an Implementation class
    > > along with your interface. You would have an IShape interface along with[/color][/color]
    a[color=blue][color=green]
    > > ShapeImpl implementation class. Your Circle class would implement the[/color]
    > IShape[color=green]
    > > interface, then contain a ShapeImpl object as a field, the IShape method
    > > would delegate to the ShapeImple class. NOTE, Circle would NOT inherit[/color]
    > from[color=green]
    > > ShapeImpl.[/color]
    >
    > Ok, I see, on this case Interface and Implementation are coming on couple
    > and I have just one implementation for my code.
    > But still I don't see how ShapeImpl will access to my protected methods[/color]
    and[color=blue]
    > private variables from Circle because is a object into the Circle object.
    >[color=green]
    > > Have you considered using creating an Extender Provider class instead?
    > >
    > > An Extender Provider is a class (can be either a Component or a Control)
    > > that implements the System.Componen tModel.IExtende rProvider interface
    > > allowing you to add new properties to controls. Along with these[/color]
    > properties[color=green]
    > > you can attach event handlers to the targeted controls enabling you at[/color][/color]
    add[color=blue][color=green]
    > > functionality.[/color]
    >
    > I didn't know about that and how it works, I'll read that and try a shot.
    >
    > Thanks very much,
    > Gustavo.
    >
    >
    > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
    message[color=blue]
    > news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=green]
    > > Franco,
    > > As Sherif stated, .NET does not have Multiple Implementation[/color][/color]
    Inheritance,[color=blue][color=green]
    > > one common method to get around this is to have an Implementation class
    > > along with your interface. You would have an IShape interface along with[/color][/color]
    a[color=blue][color=green]
    > > ShapeImpl implementation class. Your Circle class would implement the[/color]
    > IShape[color=green]
    > > interface, then contain a ShapeImpl object as a field, the IShape method
    > > would delegate to the ShapeImple class. NOTE, Circle would NOT inherit[/color]
    > from[color=green]
    > > ShapeImpl.
    > >
    > > Have you considered using creating an Extender Provider class instead?
    > >
    > > An Extender Provider is a class (can be either a Component or a Control)
    > > that implements the System.Componen tModel.IExtende rProvider interface
    > > allowing you to add new properties to controls. Along with these[/color]
    > properties[color=green]
    > > you can attach event handlers to the targeted controls enabling you at[/color][/color]
    add[color=blue][color=green]
    > > functionality.
    > >
    > >[/color]
    >[/color]
    http://msdn.microsoft.com/library/de...derobjects.asp[color=blue][color=green]
    > >
    > >[/color]
    >[/color]
    http://msdn.microsoft.com/library/de...erprovider.asp[color=blue][color=green]
    > >
    > >[/color]
    >[/color]
    http://msdn.microsoft.com/library/de...idersample.asp[color=blue][color=green]
    > >
    > > Hope this helps
    > > Jay
    > >
    > >
    > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
    > > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=darkred]
    > > > But Control doesn't do anything that I want.
    > > >
    > > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
    > > RadioButton,[color=darkred]
    > > > etc. and add my extended funcionalities
    > > >
    > > > The Class control doesn't have any funcionality.
    > > >
    > > > On that case if I derived from Control I have to rewrite each windows
    > > > control from scratch wich is "not possible", doesn't make sense.
    > > >
    > > > Thanks,
    > > > Gustavo.
    > > >
    > > > "Sherif ElMetainy" <elmeteny.NOSPA M@wayout.net.NO SPAM> wrote in[/color][/color][/color]
    message[color=blue][color=green][color=darkred]
    > > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..
    > > > > Hello
    > > > >
    > > > > Unlike C++, C# doesn't support multiple implementaion inheritance.[/color][/color][/color]
    But[color=blue][color=green][color=darkred]
    > > > your
    > > > > problem can be solved by deriving the class[/color][/color]
    > ExtendedControl Funcionality[color=green][color=darkred]
    > > > from
    > > > > Control and deriving your class from ExtendedControl Funcionality.
    > > > >
    > > > > Best regards,
    > > > >
    > > > > Sherif
    > > > >
    > > > >
    > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
    > > > > news:#hz4qCmiDH A.1564@tk2msftn gp13.phx.gbl...
    > > > > > Hi,
    > > > > >
    > > > > >
    > > > > >
    > > > > > Please help me to understand this, because I don't see what I'm[/color]
    > > missing.[color=darkred]
    > > > > >
    > > > > >
    > > > > >
    > > > > > I was reading a lot of examples on Internet that explain that C#[/color]
    > > doesn't[color=darkred]
    > > > > > implement multiple inheritance it implement multiple interfaces.
    > > > > >
    > > > > >
    > > > > >
    > > > > > So, I keep reading and reading and reading to see how can I[/color][/color][/color]
    resolve[color=blue]
    > my[color=green][color=darkred]
    > > > > > problem with interfaces.
    > > > > >
    > > > > > The conclusion is I'm writing to all of you because I couldn't[/color][/color][/color]
    find[color=blue][color=green]
    > > the[color=darkred]
    > > > > way
    > > > > > to resolve my problem.
    > > > > >
    > > > > >
    > > > > >
    > > > > > If I can create multiples interfaces and I have to implement the[/color]
    > > methods[color=darkred]
    > > > > on
    > > > > > the derived class, then what's the big deal.
    > > > > >
    > > > > >
    > > > > >
    > > > > > I know if I declare a class that inherit from one interface is[/color][/color]
    > useful[color=green][color=darkred]
    > > > > > because for example
    > > > > >
    > > > > > I can create an Interface called Shape, and 3 Classes called[/color][/color][/color]
    Circle,[color=blue][color=green][color=darkred]
    > > > > > Rectangle, and Line.
    > > > > >
    > > > > > If on my interface I declare my method Draw(); and I implement on[/color][/color]
    > each[color=green][color=darkred]
    > > > > > derived class then I could do the next.
    > > > > >
    > > > > >
    > > > > >
    > > > > > IShape s = (IShape) AnyShapeObject;
    > > > > >
    > > > > > s.draw();
    > > > > >
    > > > > >
    > > > > >
    > > > > > I think is very useful and I used many times. But now the question[/color][/color]
    > is[color=green][color=darkred]
    > > > what
    > > > > > is the similitude between Multiple Inheritance and Multiple
    > > > Interfaces????
    > > > > I
    > > > > > don't see too much
    > > > > >
    > > > > >
    > > > > >
    > > > > > Why on Internet always speak for Multiple Inheritance and Multiple
    > > > > > Interfaces like they have a relation???
    > > > > >
    > > > > >
    > > > > >
    > > > > > My Case:
    > > > > >
    > > > > >
    > > > > >
    > > > > > I have many Windows Control and I'm inherit each one for create my[/color][/color]
    > own[color=green][color=darkred]
    > > > > > Controls.
    > > > > >
    > > > > > For example I want to add method called getVirtualSize( );
    > > > > >
    > > > > >
    > > > > >
    > > > > > I create and interface
    > > > > >
    > > > > > IVirtualSize
    > > > > >
    > > > > >
    > > > > >
    > > > > > It contain
    > > > > >
    > > > > > public getVirtualSize( );
    > > > > >
    > > > > >
    > > > > >
    > > > > > So, on my derived class I MUST implement my method getVirtualSize[/color][/color]
    > and[color=green][color=darkred]
    > > > > that's
    > > > > > it.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Very nice!!!
    > > > > >
    > > > > >
    > > > > >
    > > > > > Now the real question is, I create a lot of logic on my paint[/color][/color]
    > method;[color=green][color=darkred]
    > > > this
    > > > > > logic is exactly the same for all derived classes, why do I have[/color][/color][/color]
    to[color=blue][color=green][color=darkred]
    > > > > > implement this entire logic on each Control???
    > > > > >
    > > > > >
    > > > > >
    > > > > > With multiple inheritances you just create a class
    > > > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color]
    > > really[color=darkred]
    > > > I
    > > > > > have a nice source code, because my class[/color][/color]
    > ExtendedControl Funcionality[color=green][color=darkred]
    > > > has
    > > > > > all the new extended functionality.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Then how can I do the same with interfaces????
    > > > > >
    > > > > >
    > > > > >
    > > > > > I don't want to put my piece of code on every derived class, it is[/color][/color][/color]
    a[color=blue][color=green][color=darkred]
    > > > mess
    > > > > > and very difficult to maintain, I want to centralize my source[/color][/color][/color]
    code[color=blue][color=green]
    > > and[color=darkred]
    > > > in
    > > > > > the same time I want to use many methods of the base classes, that[/color]
    > > means[color=darkred]
    > > > I
    > > > > > want to use all the protected methods that the controls offer to[/color][/color][/color]
    me[color=blue][color=green][color=darkred]
    > > > > because
    > > > > > OnPaintEx needs those.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Really, here is only one example, the reality is that is a lot of[/color]
    > > source[color=darkred]
    > > > > > code that I "should" implement on every Control, I don't want to[/color][/color][/color]
    do[color=blue][color=green][color=darkred]
    > > > that.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Thanks, the answers will be really appreciated.
    > > > > >
    > > > > > Gustavo.
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >[/color]
    > >
    > >[/color]
    >
    >[/color]


    Comment

    • Franco Gustavo

      #32
      Re: Interfaces, Big Deal!!

      > Are the protected methods inherited or added to Circle. If you added them
      to[color=blue]
      > Circle should they have been added to ShapeImpl instead?
      >
      > Are they private variables added to Circle itself, should they have been
      > added to ShapeImpl instead?[/color]

      No, they belong to the base class.



      I see how to do it with callback functions, is not so messy and can work
      fine.



      Anyway all those ways are an alternative, is like there are no a clear way
      how to do it without insert a trick o working around.



      So, Then if multiple inheritance and multiples interfaces implementation "I
      see" are really different, why on 95% on the web site speak like they have a
      relation?

      Thanks very much, and I'll try to do it on the clear possible way.



      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
      news:ePe4ANpiDH A.2536@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Franco,[color=green]
      > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
      couple[color=blue][color=green]
      > > and I have just one implementation for my code.
      > > But still I don't see how ShapeImpl will access to my protected methods[/color]
      > and[color=green]
      > > private variables from Circle because is a object into the Circle[/color][/color]
      object.[color=blue][color=green]
      > >[/color]
      > Are the protected methods inherited or added to Circle. If you added them[/color]
      to[color=blue]
      > Circle should they have been added to ShapeImpl instead?
      >
      > Are they private variables added to Circle itself, should they have been
      > added to ShapeImpl instead?
      >
      > For methods you will need to structure the method such that the
      > Implementation class (ShapeImpl) will be able to see it. Either via an
      > interface of Friend.
      >
      > Alternatively ShapeImpl can have call backs (either delegate fields or[/color]
      full[color=blue]
      > events) that it uses to call into Circle when it needs information from
      > Circle.
      >
      > For variables I would either make them a member of the Implementation[/color]
      class[color=blue]
      > itself or pass them as parameters when I call into the Implementation[/color]
      class.[color=blue]
      > Normally I would set it up such that each instance of Circle had its own
      > ShapeImpl, which means that ShapeImpl can hold per instance variables of
      > Circle, in which case ShapeImpl would not need to access details of[/color]
      Circle.[color=blue]
      >
      > Hope this helps
      > Jay
      >
      >
      > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
      > news:e3bJtoniDH A.3660@tk2msftn gp13.phx.gbl...[color=green][color=darkred]
      > > > As Sherif stated, .NET does not have Multiple Implementation[/color][/color]
      > Inheritance,[color=green][color=darkred]
      > > > one common method to get around this is to have an Implementation[/color][/color][/color]
      class[color=blue][color=green][color=darkred]
      > > > along with your interface. You would have an IShape interface along[/color][/color][/color]
      with[color=blue]
      > a[color=green][color=darkred]
      > > > ShapeImpl implementation class. Your Circle class would implement the[/color]
      > > IShape[color=darkred]
      > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color][/color]
      method[color=blue][color=green][color=darkred]
      > > > would delegate to the ShapeImple class. NOTE, Circle would NOT inherit[/color]
      > > from[color=darkred]
      > > > ShapeImpl.[/color]
      > >
      > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
      couple[color=blue][color=green]
      > > and I have just one implementation for my code.
      > > But still I don't see how ShapeImpl will access to my protected methods[/color]
      > and[color=green]
      > > private variables from Circle because is a object into the Circle[/color][/color]
      object.[color=blue][color=green]
      > >[color=darkred]
      > > > Have you considered using creating an Extender Provider class instead?
      > > >
      > > > An Extender Provider is a class (can be either a Component or a[/color][/color][/color]
      Control)[color=blue][color=green][color=darkred]
      > > > that implements the System.Componen tModel.IExtende rProvider interface
      > > > allowing you to add new properties to controls. Along with these[/color]
      > > properties[color=darkred]
      > > > you can attach event handlers to the targeted controls enabling you at[/color][/color]
      > add[color=green][color=darkred]
      > > > functionality.[/color]
      > >
      > > I didn't know about that and how it works, I'll read that and try a[/color][/color]
      shot.[color=blue][color=green]
      > >
      > > Thanks very much,
      > > Gustavo.
      > >
      > >
      > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
      > message[color=green]
      > > news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=darkred]
      > > > Franco,
      > > > As Sherif stated, .NET does not have Multiple Implementation[/color][/color]
      > Inheritance,[color=green][color=darkred]
      > > > one common method to get around this is to have an Implementation[/color][/color][/color]
      class[color=blue][color=green][color=darkred]
      > > > along with your interface. You would have an IShape interface along[/color][/color][/color]
      with[color=blue]
      > a[color=green][color=darkred]
      > > > ShapeImpl implementation class. Your Circle class would implement the[/color]
      > > IShape[color=darkred]
      > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color][/color]
      method[color=blue][color=green][color=darkred]
      > > > would delegate to the ShapeImple class. NOTE, Circle would NOT inherit[/color]
      > > from[color=darkred]
      > > > ShapeImpl.
      > > >
      > > > Have you considered using creating an Extender Provider class instead?
      > > >
      > > > An Extender Provider is a class (can be either a Component or a[/color][/color][/color]
      Control)[color=blue][color=green][color=darkred]
      > > > that implements the System.Componen tModel.IExtende rProvider interface
      > > > allowing you to add new properties to controls. Along with these[/color]
      > > properties[color=darkred]
      > > > you can attach event handlers to the targeted controls enabling you at[/color][/color]
      > add[color=green][color=darkred]
      > > > functionality.
      > > >
      > > >[/color]
      > >[/color]
      >[/color]
      http://msdn.microsoft.com/library/de...derobjects.asp[color=blue][color=green][color=darkred]
      > > >
      > > >[/color]
      > >[/color]
      >[/color]
      http://msdn.microsoft.com/library/de...erprovider.asp[color=blue][color=green][color=darkred]
      > > >
      > > >[/color]
      > >[/color]
      >[/color]
      http://msdn.microsoft.com/library/de...idersample.asp[color=blue][color=green][color=darkred]
      > > >
      > > > Hope this helps
      > > > Jay
      > > >
      > > >
      > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
      > > > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...
      > > > > But Control doesn't do anything that I want.
      > > > >
      > > > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,
      > > > RadioButton,
      > > > > etc. and add my extended funcionalities
      > > > >
      > > > > The Class control doesn't have any funcionality.
      > > > >
      > > > > On that case if I derived from Control I have to rewrite each[/color][/color][/color]
      windows[color=blue][color=green][color=darkred]
      > > > > control from scratch wich is "not possible", doesn't make sense.
      > > > >
      > > > > Thanks,
      > > > > Gustavo.
      > > > >
      > > > > "Sherif ElMetainy" <elmeteny.NOSPA M@wayout.net.NO SPAM> wrote in[/color][/color]
      > message[color=green][color=darkred]
      > > > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..
      > > > > > Hello
      > > > > >
      > > > > > Unlike C++, C# doesn't support multiple implementaion inheritance.[/color][/color]
      > But[color=green][color=darkred]
      > > > > your
      > > > > > problem can be solved by deriving the class[/color]
      > > ExtendedControl Funcionality[color=darkred]
      > > > > from
      > > > > > Control and deriving your class from ExtendedControl Funcionality.
      > > > > >
      > > > > > Best regards,
      > > > > >
      > > > > > Sherif
      > > > > >
      > > > > >
      > > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
      > > > > > news:#hz4qCmiDH A.1564@tk2msftn gp13.phx.gbl...
      > > > > > > Hi,
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Please help me to understand this, because I don't see what I'm
      > > > missing.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > I was reading a lot of examples on Internet that explain that C#
      > > > doesn't
      > > > > > > implement multiple inheritance it implement multiple interfaces.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > So, I keep reading and reading and reading to see how can I[/color][/color]
      > resolve[color=green]
      > > my[color=darkred]
      > > > > > > problem with interfaces.
      > > > > > >
      > > > > > > The conclusion is I'm writing to all of you because I couldn't[/color][/color]
      > find[color=green][color=darkred]
      > > > the
      > > > > > way
      > > > > > > to resolve my problem.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > If I can create multiples interfaces and I have to implement the
      > > > methods
      > > > > > on
      > > > > > > the derived class, then what's the big deal.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > I know if I declare a class that inherit from one interface is[/color]
      > > useful[color=darkred]
      > > > > > > because for example
      > > > > > >
      > > > > > > I can create an Interface called Shape, and 3 Classes called[/color][/color]
      > Circle,[color=green][color=darkred]
      > > > > > > Rectangle, and Line.
      > > > > > >
      > > > > > > If on my interface I declare my method Draw(); and I implement[/color][/color][/color]
      on[color=blue][color=green]
      > > each[color=darkred]
      > > > > > > derived class then I could do the next.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > IShape s = (IShape) AnyShapeObject;
      > > > > > >
      > > > > > > s.draw();
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > I think is very useful and I used many times. But now the[/color][/color][/color]
      question[color=blue][color=green]
      > > is[color=darkred]
      > > > > what
      > > > > > > is the similitude between Multiple Inheritance and Multiple
      > > > > Interfaces????
      > > > > > I
      > > > > > > don't see too much
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Why on Internet always speak for Multiple Inheritance and[/color][/color][/color]
      Multiple[color=blue][color=green][color=darkred]
      > > > > > > Interfaces like they have a relation???
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > My Case:
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > I have many Windows Control and I'm inherit each one for create[/color][/color][/color]
      my[color=blue][color=green]
      > > own[color=darkred]
      > > > > > > Controls.
      > > > > > >
      > > > > > > For example I want to add method called getVirtualSize( );
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > I create and interface
      > > > > > >
      > > > > > > IVirtualSize
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > It contain
      > > > > > >
      > > > > > > public getVirtualSize( );
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > So, on my derived class I MUST implement my method[/color][/color][/color]
      getVirtualSize[color=blue][color=green]
      > > and[color=darkred]
      > > > > > that's
      > > > > > > it.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Very nice!!!
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Now the real question is, I create a lot of logic on my paint[/color]
      > > method;[color=darkred]
      > > > > this
      > > > > > > logic is exactly the same for all derived classes, why do I have[/color][/color]
      > to[color=green][color=darkred]
      > > > > > > implement this entire logic on each Control???
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > With multiple inheritances you just create a class
      > > > > > > ExtendedControl Funcionality and Implement a method OnPaintEx,[/color][/color][/color]
      and[color=blue][color=green][color=darkred]
      > > > really
      > > > > I
      > > > > > > have a nice source code, because my class[/color]
      > > ExtendedControl Funcionality[color=darkred]
      > > > > has
      > > > > > > all the new extended functionality.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Then how can I do the same with interfaces????
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > I don't want to put my piece of code on every derived class, it[/color][/color][/color]
      is[color=blue]
      > a[color=green][color=darkred]
      > > > > mess
      > > > > > > and very difficult to maintain, I want to centralize my source[/color][/color]
      > code[color=green][color=darkred]
      > > > and
      > > > > in
      > > > > > > the same time I want to use many methods of the base classes,[/color][/color][/color]
      that[color=blue][color=green][color=darkred]
      > > > means
      > > > > I
      > > > > > > want to use all the protected methods that the controls offer to[/color][/color]
      > me[color=green][color=darkred]
      > > > > > because
      > > > > > > OnPaintEx needs those.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Really, here is only one example, the reality is that is a lot[/color][/color][/color]
      of[color=blue][color=green][color=darkred]
      > > > source
      > > > > > > code that I "should" implement on every Control, I don't want to[/color][/color]
      > do[color=green][color=darkred]
      > > > > that.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > > Thanks, the answers will be really appreciated.
      > > > > > >
      > > > > > > Gustavo.
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > > >
      > > > > >
      > > > > >
      > > > >
      > > > >
      > > >
      > > >[/color]
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Franco Gustavo

        #33
        Re: Interfaces, Big Deal!!

        > Are the protected methods inherited or added to Circle. If you added them
        to[color=blue]
        > Circle should they have been added to ShapeImpl instead?
        >
        > Are they private variables added to Circle itself, should they have been
        > added to ShapeImpl instead?[/color]

        No, they belong to the base class.



        I see how to do it with callback functions, is not so messy and can work
        fine.



        Anyway all those ways are an alternative, is like there are no a clear way
        how to do it without insert a trick o working around.



        So, Then if multiple inheritance and multiples interfaces implementation "I
        see" are really different, why on 95% on the web site speak like they have a
        relation?

        Thanks very much, and I'll try to do it on the clear possible way.



        "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
        news:ePe4ANpiDH A.2536@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Franco,[color=green]
        > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
        couple[color=blue][color=green]
        > > and I have just one implementation for my code.
        > > But still I don't see how ShapeImpl will access to my protected methods[/color]
        > and[color=green]
        > > private variables from Circle because is a object into the Circle[/color][/color]
        object.[color=blue][color=green]
        > >[/color]
        > Are the protected methods inherited or added to Circle. If you added them[/color]
        to[color=blue]
        > Circle should they have been added to ShapeImpl instead?
        >
        > Are they private variables added to Circle itself, should they have been
        > added to ShapeImpl instead?
        >
        > For methods you will need to structure the method such that the
        > Implementation class (ShapeImpl) will be able to see it. Either via an
        > interface of Friend.
        >
        > Alternatively ShapeImpl can have call backs (either delegate fields or[/color]
        full[color=blue]
        > events) that it uses to call into Circle when it needs information from
        > Circle.
        >
        > For variables I would either make them a member of the Implementation[/color]
        class[color=blue]
        > itself or pass them as parameters when I call into the Implementation[/color]
        class.[color=blue]
        > Normally I would set it up such that each instance of Circle had its own
        > ShapeImpl, which means that ShapeImpl can hold per instance variables of
        > Circle, in which case ShapeImpl would not need to access details of[/color]
        Circle.[color=blue]
        >
        > Hope this helps
        > Jay
        >
        >
        > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
        > news:e3bJtoniDH A.3660@tk2msftn gp13.phx.gbl...[color=green][color=darkred]
        > > > As Sherif stated, .NET does not have Multiple Implementation[/color][/color]
        > Inheritance,[color=green][color=darkred]
        > > > one common method to get around this is to have an Implementation[/color][/color][/color]
        class[color=blue][color=green][color=darkred]
        > > > along with your interface. You would have an IShape interface along[/color][/color][/color]
        with[color=blue]
        > a[color=green][color=darkred]
        > > > ShapeImpl implementation class. Your Circle class would implement the[/color]
        > > IShape[color=darkred]
        > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color][/color]
        method[color=blue][color=green][color=darkred]
        > > > would delegate to the ShapeImple class. NOTE, Circle would NOT inherit[/color]
        > > from[color=darkred]
        > > > ShapeImpl.[/color]
        > >
        > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
        couple[color=blue][color=green]
        > > and I have just one implementation for my code.
        > > But still I don't see how ShapeImpl will access to my protected methods[/color]
        > and[color=green]
        > > private variables from Circle because is a object into the Circle[/color][/color]
        object.[color=blue][color=green]
        > >[color=darkred]
        > > > Have you considered using creating an Extender Provider class instead?
        > > >
        > > > An Extender Provider is a class (can be either a Component or a[/color][/color][/color]
        Control)[color=blue][color=green][color=darkred]
        > > > that implements the System.Componen tModel.IExtende rProvider interface
        > > > allowing you to add new properties to controls. Along with these[/color]
        > > properties[color=darkred]
        > > > you can attach event handlers to the targeted controls enabling you at[/color][/color]
        > add[color=green][color=darkred]
        > > > functionality.[/color]
        > >
        > > I didn't know about that and how it works, I'll read that and try a[/color][/color]
        shot.[color=blue][color=green]
        > >
        > > Thanks very much,
        > > Gustavo.
        > >
        > >
        > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
        > message[color=green]
        > > news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=darkred]
        > > > Franco,
        > > > As Sherif stated, .NET does not have Multiple Implementation[/color][/color]
        > Inheritance,[color=green][color=darkred]
        > > > one common method to get around this is to have an Implementation[/color][/color][/color]
        class[color=blue][color=green][color=darkred]
        > > > along with your interface. You would have an IShape interface along[/color][/color][/color]
        with[color=blue]
        > a[color=green][color=darkred]
        > > > ShapeImpl implementation class. Your Circle class would implement the[/color]
        > > IShape[color=darkred]
        > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color][/color]
        method[color=blue][color=green][color=darkred]
        > > > would delegate to the ShapeImple class. NOTE, Circle would NOT inherit[/color]
        > > from[color=darkred]
        > > > ShapeImpl.
        > > >
        > > > Have you considered using creating an Extender Provider class instead?
        > > >
        > > > An Extender Provider is a class (can be either a Component or a[/color][/color][/color]
        Control)[color=blue][color=green][color=darkred]
        > > > that implements the System.Componen tModel.IExtende rProvider interface
        > > > allowing you to add new properties to controls. Along with these[/color]
        > > properties[color=darkred]
        > > > you can attach event handlers to the targeted controls enabling you at[/color][/color]
        > add[color=green][color=darkred]
        > > > functionality.
        > > >
        > > >[/color]
        > >[/color]
        >[/color]
        http://msdn.microsoft.com/library/de...derobjects.asp[color=blue][color=green][color=darkred]
        > > >
        > > >[/color]
        > >[/color]
        >[/color]
        http://msdn.microsoft.com/library/de...erprovider.asp[color=blue][color=green][color=darkred]
        > > >
        > > >[/color]
        > >[/color]
        >[/color]
        http://msdn.microsoft.com/library/de...idersample.asp[color=blue][color=green][color=darkred]
        > > >
        > > > Hope this helps
        > > > Jay
        > > >
        > > >
        > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
        > > > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...
        > > > > But Control doesn't do anything that I want.
        > > > >
        > > > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,
        > > > RadioButton,
        > > > > etc. and add my extended funcionalities
        > > > >
        > > > > The Class control doesn't have any funcionality.
        > > > >
        > > > > On that case if I derived from Control I have to rewrite each[/color][/color][/color]
        windows[color=blue][color=green][color=darkred]
        > > > > control from scratch wich is "not possible", doesn't make sense.
        > > > >
        > > > > Thanks,
        > > > > Gustavo.
        > > > >
        > > > > "Sherif ElMetainy" <elmeteny.NOSPA M@wayout.net.NO SPAM> wrote in[/color][/color]
        > message[color=green][color=darkred]
        > > > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..
        > > > > > Hello
        > > > > >
        > > > > > Unlike C++, C# doesn't support multiple implementaion inheritance.[/color][/color]
        > But[color=green][color=darkred]
        > > > > your
        > > > > > problem can be solved by deriving the class[/color]
        > > ExtendedControl Funcionality[color=darkred]
        > > > > from
        > > > > > Control and deriving your class from ExtendedControl Funcionality.
        > > > > >
        > > > > > Best regards,
        > > > > >
        > > > > > Sherif
        > > > > >
        > > > > >
        > > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
        > > > > > news:#hz4qCmiDH A.1564@tk2msftn gp13.phx.gbl...
        > > > > > > Hi,
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Please help me to understand this, because I don't see what I'm
        > > > missing.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > I was reading a lot of examples on Internet that explain that C#
        > > > doesn't
        > > > > > > implement multiple inheritance it implement multiple interfaces.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > So, I keep reading and reading and reading to see how can I[/color][/color]
        > resolve[color=green]
        > > my[color=darkred]
        > > > > > > problem with interfaces.
        > > > > > >
        > > > > > > The conclusion is I'm writing to all of you because I couldn't[/color][/color]
        > find[color=green][color=darkred]
        > > > the
        > > > > > way
        > > > > > > to resolve my problem.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > If I can create multiples interfaces and I have to implement the
        > > > methods
        > > > > > on
        > > > > > > the derived class, then what's the big deal.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > I know if I declare a class that inherit from one interface is[/color]
        > > useful[color=darkred]
        > > > > > > because for example
        > > > > > >
        > > > > > > I can create an Interface called Shape, and 3 Classes called[/color][/color]
        > Circle,[color=green][color=darkred]
        > > > > > > Rectangle, and Line.
        > > > > > >
        > > > > > > If on my interface I declare my method Draw(); and I implement[/color][/color][/color]
        on[color=blue][color=green]
        > > each[color=darkred]
        > > > > > > derived class then I could do the next.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > IShape s = (IShape) AnyShapeObject;
        > > > > > >
        > > > > > > s.draw();
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > I think is very useful and I used many times. But now the[/color][/color][/color]
        question[color=blue][color=green]
        > > is[color=darkred]
        > > > > what
        > > > > > > is the similitude between Multiple Inheritance and Multiple
        > > > > Interfaces????
        > > > > > I
        > > > > > > don't see too much
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Why on Internet always speak for Multiple Inheritance and[/color][/color][/color]
        Multiple[color=blue][color=green][color=darkred]
        > > > > > > Interfaces like they have a relation???
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > My Case:
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > I have many Windows Control and I'm inherit each one for create[/color][/color][/color]
        my[color=blue][color=green]
        > > own[color=darkred]
        > > > > > > Controls.
        > > > > > >
        > > > > > > For example I want to add method called getVirtualSize( );
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > I create and interface
        > > > > > >
        > > > > > > IVirtualSize
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > It contain
        > > > > > >
        > > > > > > public getVirtualSize( );
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > So, on my derived class I MUST implement my method[/color][/color][/color]
        getVirtualSize[color=blue][color=green]
        > > and[color=darkred]
        > > > > > that's
        > > > > > > it.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Very nice!!!
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Now the real question is, I create a lot of logic on my paint[/color]
        > > method;[color=darkred]
        > > > > this
        > > > > > > logic is exactly the same for all derived classes, why do I have[/color][/color]
        > to[color=green][color=darkred]
        > > > > > > implement this entire logic on each Control???
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > With multiple inheritances you just create a class
        > > > > > > ExtendedControl Funcionality and Implement a method OnPaintEx,[/color][/color][/color]
        and[color=blue][color=green][color=darkred]
        > > > really
        > > > > I
        > > > > > > have a nice source code, because my class[/color]
        > > ExtendedControl Funcionality[color=darkred]
        > > > > has
        > > > > > > all the new extended functionality.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Then how can I do the same with interfaces????
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > I don't want to put my piece of code on every derived class, it[/color][/color][/color]
        is[color=blue]
        > a[color=green][color=darkred]
        > > > > mess
        > > > > > > and very difficult to maintain, I want to centralize my source[/color][/color]
        > code[color=green][color=darkred]
        > > > and
        > > > > in
        > > > > > > the same time I want to use many methods of the base classes,[/color][/color][/color]
        that[color=blue][color=green][color=darkred]
        > > > means
        > > > > I
        > > > > > > want to use all the protected methods that the controls offer to[/color][/color]
        > me[color=green][color=darkred]
        > > > > > because
        > > > > > > OnPaintEx needs those.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Really, here is only one example, the reality is that is a lot[/color][/color][/color]
        of[color=blue][color=green][color=darkred]
        > > > source
        > > > > > > code that I "should" implement on every Control, I don't want to[/color][/color]
        > do[color=green][color=darkred]
        > > > > that.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > > Thanks, the answers will be really appreciated.
        > > > > > >
        > > > > > > Gustavo.
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > > >
        > > > > >
        > > > > >
        > > > >
        > > > >
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jay B. Harlow [MVP - Outlook]

          #34
          Re: Interfaces, Big Deal!!

          Franco,[color=blue]
          > Anyway all those ways are an alternative, is like there are no a clear way
          > how to do it without insert a trick o working around.[/color]
          If multiple implementation inheritance is important to you, and you prefer
          to target the .NET platform you may want to consider switching to Eiffel
          http://www.eiffel.com. It supports multiple implementation inheritance on
          the .NET platform. Of course using Eiffel's multiple implementation
          inheritance may limit your class libraries to Eiffel. I don't use Eiffel, I
          have just read about it on occasion.
          [color=blue]
          > So, Then if multiple inheritance and multiples interfaces implementation[/color]
          "I[color=blue]
          > see" are really different, why on 95% on the web site speak like they have[/color]
          a[color=blue]
          > relation?[/color]
          As has been demonstrated Multiple interfaces & delegation is how you
          implement multiple inheritance in .NET. So obviously they are related.

          If you take implementation out of the picture. In C++ Multiple Class
          Inheritance defines a derived type that is composed of multiple base types.
          In .NET Multiple Interface Inheritance defines a derived type that is
          composed of multiple base types.

          In both cases you are defining a derived type that is also "is a" more than
          one base type.

          In either case you can use the derived type anyplace any of the base types
          can be used.

          So I'm really not seeing how you consider them not to be related!

          Implementation is just one facet of the equation.

          Hope this helps
          Jay


          "Franco Gustavo" <gfranco@inunti us.com> wrote in message
          news:%23UB52Wsi DHA.488@TK2MSFT NGP09.phx.gbl.. .[color=blue][color=green]
          > > Are the protected methods inherited or added to Circle. If you added[/color][/color]
          them[color=blue]
          > to[color=green]
          > > Circle should they have been added to ShapeImpl instead?
          > >
          > > Are they private variables added to Circle itself, should they have been
          > > added to ShapeImpl instead?[/color]
          >
          > No, they belong to the base class.
          >
          >
          >
          > I see how to do it with callback functions, is not so messy and can work
          > fine.
          >
          >
          >
          > Anyway all those ways are an alternative, is like there are no a clear way
          > how to do it without insert a trick o working around.
          >
          >
          >
          > So, Then if multiple inheritance and multiples interfaces implementation[/color]
          "I[color=blue]
          > see" are really different, why on 95% on the web site speak like they have[/color]
          a[color=blue]
          > relation?
          >
          > Thanks very much, and I'll try to do it on the clear possible way.
          >
          >
          >
          > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
          message[color=blue]
          > news:ePe4ANpiDH A.2536@TK2MSFTN GP10.phx.gbl...[color=green]
          > > Franco,[color=darkred]
          > > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
          > couple[color=green][color=darkred]
          > > > and I have just one implementation for my code.
          > > > But still I don't see how ShapeImpl will access to my protected[/color][/color][/color]
          methods[color=blue][color=green]
          > > and[color=darkred]
          > > > private variables from Circle because is a object into the Circle[/color][/color]
          > object.[color=green][color=darkred]
          > > >[/color]
          > > Are the protected methods inherited or added to Circle. If you added[/color][/color]
          them[color=blue]
          > to[color=green]
          > > Circle should they have been added to ShapeImpl instead?
          > >
          > > Are they private variables added to Circle itself, should they have been
          > > added to ShapeImpl instead?
          > >
          > > For methods you will need to structure the method such that the
          > > Implementation class (ShapeImpl) will be able to see it. Either via an
          > > interface of Friend.
          > >
          > > Alternatively ShapeImpl can have call backs (either delegate fields or[/color]
          > full[color=green]
          > > events) that it uses to call into Circle when it needs information from
          > > Circle.
          > >
          > > For variables I would either make them a member of the Implementation[/color]
          > class[color=green]
          > > itself or pass them as parameters when I call into the Implementation[/color]
          > class.[color=green]
          > > Normally I would set it up such that each instance of Circle had its own
          > > ShapeImpl, which means that ShapeImpl can hold per instance variables of
          > > Circle, in which case ShapeImpl would not need to access details of[/color]
          > Circle.[color=green]
          > >
          > > Hope this helps
          > > Jay
          > >
          > >
          > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
          > > news:e3bJtoniDH A.3660@tk2msftn gp13.phx.gbl...[color=darkred]
          > > > > As Sherif stated, .NET does not have Multiple Implementation[/color]
          > > Inheritance,[color=darkred]
          > > > > one common method to get around this is to have an Implementation[/color][/color]
          > class[color=green][color=darkred]
          > > > > along with your interface. You would have an IShape interface along[/color][/color]
          > with[color=green]
          > > a[color=darkred]
          > > > > ShapeImpl implementation class. Your Circle class would implement[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > IShape
          > > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color]
          > method[color=green][color=darkred]
          > > > > would delegate to the ShapeImple class. NOTE, Circle would NOT[/color][/color][/color]
          inherit[color=blue][color=green][color=darkred]
          > > > from
          > > > > ShapeImpl.
          > > >
          > > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
          > couple[color=green][color=darkred]
          > > > and I have just one implementation for my code.
          > > > But still I don't see how ShapeImpl will access to my protected[/color][/color][/color]
          methods[color=blue][color=green]
          > > and[color=darkred]
          > > > private variables from Circle because is a object into the Circle[/color][/color]
          > object.[color=green][color=darkred]
          > > >
          > > > > Have you considered using creating an Extender Provider class[/color][/color][/color]
          instead?[color=blue][color=green][color=darkred]
          > > > >
          > > > > An Extender Provider is a class (can be either a Component or a[/color][/color]
          > Control)[color=green][color=darkred]
          > > > > that implements the System.Componen tModel.IExtende rProvider[/color][/color][/color]
          interface[color=blue][color=green][color=darkred]
          > > > > allowing you to add new properties to controls. Along with these
          > > > properties
          > > > > you can attach event handlers to the targeted controls enabling you[/color][/color][/color]
          at[color=blue][color=green]
          > > add[color=darkred]
          > > > > functionality.
          > > >
          > > > I didn't know about that and how it works, I'll read that and try a[/color][/color]
          > shot.[color=green][color=darkred]
          > > >
          > > > Thanks very much,
          > > > Gustavo.
          > > >
          > > >
          > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
          > > message[color=darkred]
          > > > news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...
          > > > > Franco,
          > > > > As Sherif stated, .NET does not have Multiple Implementation[/color]
          > > Inheritance,[color=darkred]
          > > > > one common method to get around this is to have an Implementation[/color][/color]
          > class[color=green][color=darkred]
          > > > > along with your interface. You would have an IShape interface along[/color][/color]
          > with[color=green]
          > > a[color=darkred]
          > > > > ShapeImpl implementation class. Your Circle class would implement[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > IShape
          > > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color]
          > method[color=green][color=darkred]
          > > > > would delegate to the ShapeImple class. NOTE, Circle would NOT[/color][/color][/color]
          inherit[color=blue][color=green][color=darkred]
          > > > from
          > > > > ShapeImpl.
          > > > >
          > > > > Have you considered using creating an Extender Provider class[/color][/color][/color]
          instead?[color=blue][color=green][color=darkred]
          > > > >
          > > > > An Extender Provider is a class (can be either a Component or a[/color][/color]
          > Control)[color=green][color=darkred]
          > > > > that implements the System.Componen tModel.IExtende rProvider[/color][/color][/color]
          interface[color=blue][color=green][color=darkred]
          > > > > allowing you to add new properties to controls. Along with these
          > > > properties
          > > > > you can attach event handlers to the targeted controls enabling you[/color][/color][/color]
          at[color=blue][color=green]
          > > add[color=darkred]
          > > > > functionality.
          > > > >
          > > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://msdn.microsoft.com/library/de...derobjects.asp[color=blue][color=green][color=darkred]
          > > > >
          > > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://msdn.microsoft.com/library/de...erprovider.asp[color=blue][color=green][color=darkred]
          > > > >
          > > > >
          > > >[/color]
          > >[/color]
          >[/color]
          http://msdn.microsoft.com/library/de...idersample.asp[color=blue][color=green][color=darkred]
          > > > >
          > > > > Hope this helps
          > > > > Jay
          > > > >
          > > > >
          > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
          > > > > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...
          > > > > > But Control doesn't do anything that I want.
          > > > > >
          > > > > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,
          > > > > RadioButton,
          > > > > > etc. and add my extended funcionalities
          > > > > >
          > > > > > The Class control doesn't have any funcionality.
          > > > > >
          > > > > > On that case if I derived from Control I have to rewrite each[/color][/color]
          > windows[color=green][color=darkred]
          > > > > > control from scratch wich is "not possible", doesn't make sense.
          > > > > >
          > > > > > Thanks,
          > > > > > Gustavo.
          > > > > >
          > > > > > "Sherif ElMetainy" <elmeteny.NOSPA M@wayout.net.NO SPAM> wrote in[/color]
          > > message[color=darkred]
          > > > > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..
          > > > > > > Hello
          > > > > > >
          > > > > > > Unlike C++, C# doesn't support multiple implementaion[/color][/color][/color]
          inheritance.[color=blue][color=green]
          > > But[color=darkred]
          > > > > > your
          > > > > > > problem can be solved by deriving the class
          > > > ExtendedControl Funcionality
          > > > > > from
          > > > > > > Control and deriving your class from[/color][/color][/color]
          ExtendedControl Funcionality.[color=blue][color=green][color=darkred]
          > > > > > >
          > > > > > > Best regards,
          > > > > > >
          > > > > > > Sherif
          > > > > > >
          > > > > > >
          > > > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
          > > > > > > news:#hz4qCmiDH A.1564@tk2msftn gp13.phx.gbl...
          > > > > > > > Hi,
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Please help me to understand this, because I don't see what[/color][/color][/color]
          I'm[color=blue][color=green][color=darkred]
          > > > > missing.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > I was reading a lot of examples on Internet that explain that[/color][/color][/color]
          C#[color=blue][color=green][color=darkred]
          > > > > doesn't
          > > > > > > > implement multiple inheritance it implement multiple[/color][/color][/color]
          interfaces.[color=blue][color=green][color=darkred]
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > So, I keep reading and reading and reading to see how can I[/color]
          > > resolve[color=darkred]
          > > > my
          > > > > > > > problem with interfaces.
          > > > > > > >
          > > > > > > > The conclusion is I'm writing to all of you because I couldn't[/color]
          > > find[color=darkred]
          > > > > the
          > > > > > > way
          > > > > > > > to resolve my problem.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > If I can create multiples interfaces and I have to implement[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > > methods
          > > > > > > on
          > > > > > > > the derived class, then what's the big deal.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > I know if I declare a class that inherit from one interface is
          > > > useful
          > > > > > > > because for example
          > > > > > > >
          > > > > > > > I can create an Interface called Shape, and 3 Classes called[/color]
          > > Circle,[color=darkred]
          > > > > > > > Rectangle, and Line.
          > > > > > > >
          > > > > > > > If on my interface I declare my method Draw(); and I implement[/color][/color]
          > on[color=green][color=darkred]
          > > > each
          > > > > > > > derived class then I could do the next.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > IShape s = (IShape) AnyShapeObject;
          > > > > > > >
          > > > > > > > s.draw();
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > I think is very useful and I used many times. But now the[/color][/color]
          > question[color=green][color=darkred]
          > > > is
          > > > > > what
          > > > > > > > is the similitude between Multiple Inheritance and Multiple
          > > > > > Interfaces????
          > > > > > > I
          > > > > > > > don't see too much
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Why on Internet always speak for Multiple Inheritance and[/color][/color]
          > Multiple[color=green][color=darkred]
          > > > > > > > Interfaces like they have a relation???
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > My Case:
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > I have many Windows Control and I'm inherit each one for[/color][/color][/color]
          create[color=blue]
          > my[color=green][color=darkred]
          > > > own
          > > > > > > > Controls.
          > > > > > > >
          > > > > > > > For example I want to add method called getVirtualSize( );
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > I create and interface
          > > > > > > >
          > > > > > > > IVirtualSize
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > It contain
          > > > > > > >
          > > > > > > > public getVirtualSize( );
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > So, on my derived class I MUST implement my method[/color][/color]
          > getVirtualSize[color=green][color=darkred]
          > > > and
          > > > > > > that's
          > > > > > > > it.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Very nice!!!
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Now the real question is, I create a lot of logic on my paint
          > > > method;
          > > > > > this
          > > > > > > > logic is exactly the same for all derived classes, why do I[/color][/color][/color]
          have[color=blue][color=green]
          > > to[color=darkred]
          > > > > > > > implement this entire logic on each Control???
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > With multiple inheritances you just create a class
          > > > > > > > ExtendedControl Funcionality and Implement a method OnPaintEx,[/color][/color]
          > and[color=green][color=darkred]
          > > > > really
          > > > > > I
          > > > > > > > have a nice source code, because my class
          > > > ExtendedControl Funcionality
          > > > > > has
          > > > > > > > all the new extended functionality.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Then how can I do the same with interfaces????
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > I don't want to put my piece of code on every derived class,[/color][/color][/color]
          it[color=blue]
          > is[color=green]
          > > a[color=darkred]
          > > > > > mess
          > > > > > > > and very difficult to maintain, I want to centralize my source[/color]
          > > code[color=darkred]
          > > > > and
          > > > > > in
          > > > > > > > the same time I want to use many methods of the base classes,[/color][/color]
          > that[color=green][color=darkred]
          > > > > means
          > > > > > I
          > > > > > > > want to use all the protected methods that the controls offer[/color][/color][/color]
          to[color=blue][color=green]
          > > me[color=darkred]
          > > > > > > because
          > > > > > > > OnPaintEx needs those.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Really, here is only one example, the reality is that is a lot[/color][/color]
          > of[color=green][color=darkred]
          > > > > source
          > > > > > > > code that I "should" implement on every Control, I don't want[/color][/color][/color]
          to[color=blue][color=green]
          > > do[color=darkred]
          > > > > > that.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > > Thanks, the answers will be really appreciated.
          > > > > > > >
          > > > > > > > Gustavo.
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > > >
          > > > > > >
          > > > > > >
          > > > > >
          > > > > >
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Jay B. Harlow [MVP - Outlook]

            #35
            Re: Interfaces, Big Deal!!

            Franco,[color=blue]
            > Anyway all those ways are an alternative, is like there are no a clear way
            > how to do it without insert a trick o working around.[/color]
            If multiple implementation inheritance is important to you, and you prefer
            to target the .NET platform you may want to consider switching to Eiffel
            http://www.eiffel.com. It supports multiple implementation inheritance on
            the .NET platform. Of course using Eiffel's multiple implementation
            inheritance may limit your class libraries to Eiffel. I don't use Eiffel, I
            have just read about it on occasion.
            [color=blue]
            > So, Then if multiple inheritance and multiples interfaces implementation[/color]
            "I[color=blue]
            > see" are really different, why on 95% on the web site speak like they have[/color]
            a[color=blue]
            > relation?[/color]
            As has been demonstrated Multiple interfaces & delegation is how you
            implement multiple inheritance in .NET. So obviously they are related.

            If you take implementation out of the picture. In C++ Multiple Class
            Inheritance defines a derived type that is composed of multiple base types.
            In .NET Multiple Interface Inheritance defines a derived type that is
            composed of multiple base types.

            In both cases you are defining a derived type that is also "is a" more than
            one base type.

            In either case you can use the derived type anyplace any of the base types
            can be used.

            So I'm really not seeing how you consider them not to be related!

            Implementation is just one facet of the equation.

            Hope this helps
            Jay


            "Franco Gustavo" <gfranco@inunti us.com> wrote in message
            news:%23UB52Wsi DHA.488@TK2MSFT NGP09.phx.gbl.. .[color=blue][color=green]
            > > Are the protected methods inherited or added to Circle. If you added[/color][/color]
            them[color=blue]
            > to[color=green]
            > > Circle should they have been added to ShapeImpl instead?
            > >
            > > Are they private variables added to Circle itself, should they have been
            > > added to ShapeImpl instead?[/color]
            >
            > No, they belong to the base class.
            >
            >
            >
            > I see how to do it with callback functions, is not so messy and can work
            > fine.
            >
            >
            >
            > Anyway all those ways are an alternative, is like there are no a clear way
            > how to do it without insert a trick o working around.
            >
            >
            >
            > So, Then if multiple inheritance and multiples interfaces implementation[/color]
            "I[color=blue]
            > see" are really different, why on 95% on the web site speak like they have[/color]
            a[color=blue]
            > relation?
            >
            > Thanks very much, and I'll try to do it on the clear possible way.
            >
            >
            >
            > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
            message[color=blue]
            > news:ePe4ANpiDH A.2536@TK2MSFTN GP10.phx.gbl...[color=green]
            > > Franco,[color=darkred]
            > > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
            > couple[color=green][color=darkred]
            > > > and I have just one implementation for my code.
            > > > But still I don't see how ShapeImpl will access to my protected[/color][/color][/color]
            methods[color=blue][color=green]
            > > and[color=darkred]
            > > > private variables from Circle because is a object into the Circle[/color][/color]
            > object.[color=green][color=darkred]
            > > >[/color]
            > > Are the protected methods inherited or added to Circle. If you added[/color][/color]
            them[color=blue]
            > to[color=green]
            > > Circle should they have been added to ShapeImpl instead?
            > >
            > > Are they private variables added to Circle itself, should they have been
            > > added to ShapeImpl instead?
            > >
            > > For methods you will need to structure the method such that the
            > > Implementation class (ShapeImpl) will be able to see it. Either via an
            > > interface of Friend.
            > >
            > > Alternatively ShapeImpl can have call backs (either delegate fields or[/color]
            > full[color=green]
            > > events) that it uses to call into Circle when it needs information from
            > > Circle.
            > >
            > > For variables I would either make them a member of the Implementation[/color]
            > class[color=green]
            > > itself or pass them as parameters when I call into the Implementation[/color]
            > class.[color=green]
            > > Normally I would set it up such that each instance of Circle had its own
            > > ShapeImpl, which means that ShapeImpl can hold per instance variables of
            > > Circle, in which case ShapeImpl would not need to access details of[/color]
            > Circle.[color=green]
            > >
            > > Hope this helps
            > > Jay
            > >
            > >
            > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
            > > news:e3bJtoniDH A.3660@tk2msftn gp13.phx.gbl...[color=darkred]
            > > > > As Sherif stated, .NET does not have Multiple Implementation[/color]
            > > Inheritance,[color=darkred]
            > > > > one common method to get around this is to have an Implementation[/color][/color]
            > class[color=green][color=darkred]
            > > > > along with your interface. You would have an IShape interface along[/color][/color]
            > with[color=green]
            > > a[color=darkred]
            > > > > ShapeImpl implementation class. Your Circle class would implement[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > > > IShape
            > > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color]
            > method[color=green][color=darkred]
            > > > > would delegate to the ShapeImple class. NOTE, Circle would NOT[/color][/color][/color]
            inherit[color=blue][color=green][color=darkred]
            > > > from
            > > > > ShapeImpl.
            > > >
            > > > Ok, I see, on this case Interface and Implementation are coming on[/color][/color]
            > couple[color=green][color=darkred]
            > > > and I have just one implementation for my code.
            > > > But still I don't see how ShapeImpl will access to my protected[/color][/color][/color]
            methods[color=blue][color=green]
            > > and[color=darkred]
            > > > private variables from Circle because is a object into the Circle[/color][/color]
            > object.[color=green][color=darkred]
            > > >
            > > > > Have you considered using creating an Extender Provider class[/color][/color][/color]
            instead?[color=blue][color=green][color=darkred]
            > > > >
            > > > > An Extender Provider is a class (can be either a Component or a[/color][/color]
            > Control)[color=green][color=darkred]
            > > > > that implements the System.Componen tModel.IExtende rProvider[/color][/color][/color]
            interface[color=blue][color=green][color=darkred]
            > > > > allowing you to add new properties to controls. Along with these
            > > > properties
            > > > > you can attach event handlers to the targeted controls enabling you[/color][/color][/color]
            at[color=blue][color=green]
            > > add[color=darkred]
            > > > > functionality.
            > > >
            > > > I didn't know about that and how it works, I'll read that and try a[/color][/color]
            > shot.[color=green][color=darkred]
            > > >
            > > > Thanks very much,
            > > > Gustavo.
            > > >
            > > >
            > > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in[/color]
            > > message[color=darkred]
            > > > news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...
            > > > > Franco,
            > > > > As Sherif stated, .NET does not have Multiple Implementation[/color]
            > > Inheritance,[color=darkred]
            > > > > one common method to get around this is to have an Implementation[/color][/color]
            > class[color=green][color=darkred]
            > > > > along with your interface. You would have an IShape interface along[/color][/color]
            > with[color=green]
            > > a[color=darkred]
            > > > > ShapeImpl implementation class. Your Circle class would implement[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > > > IShape
            > > > > interface, then contain a ShapeImpl object as a field, the IShape[/color][/color]
            > method[color=green][color=darkred]
            > > > > would delegate to the ShapeImple class. NOTE, Circle would NOT[/color][/color][/color]
            inherit[color=blue][color=green][color=darkred]
            > > > from
            > > > > ShapeImpl.
            > > > >
            > > > > Have you considered using creating an Extender Provider class[/color][/color][/color]
            instead?[color=blue][color=green][color=darkred]
            > > > >
            > > > > An Extender Provider is a class (can be either a Component or a[/color][/color]
            > Control)[color=green][color=darkred]
            > > > > that implements the System.Componen tModel.IExtende rProvider[/color][/color][/color]
            interface[color=blue][color=green][color=darkred]
            > > > > allowing you to add new properties to controls. Along with these
            > > > properties
            > > > > you can attach event handlers to the targeted controls enabling you[/color][/color][/color]
            at[color=blue][color=green]
            > > add[color=darkred]
            > > > > functionality.
            > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://msdn.microsoft.com/library/de...derobjects.asp[color=blue][color=green][color=darkred]
            > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://msdn.microsoft.com/library/de...erprovider.asp[color=blue][color=green][color=darkred]
            > > > >
            > > > >
            > > >[/color]
            > >[/color]
            >[/color]
            http://msdn.microsoft.com/library/de...idersample.asp[color=blue][color=green][color=darkred]
            > > > >
            > > > > Hope this helps
            > > > > Jay
            > > > >
            > > > >
            > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
            > > > > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...
            > > > > > But Control doesn't do anything that I want.
            > > > > >
            > > > > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,
            > > > > RadioButton,
            > > > > > etc. and add my extended funcionalities
            > > > > >
            > > > > > The Class control doesn't have any funcionality.
            > > > > >
            > > > > > On that case if I derived from Control I have to rewrite each[/color][/color]
            > windows[color=green][color=darkred]
            > > > > > control from scratch wich is "not possible", doesn't make sense.
            > > > > >
            > > > > > Thanks,
            > > > > > Gustavo.
            > > > > >
            > > > > > "Sherif ElMetainy" <elmeteny.NOSPA M@wayout.net.NO SPAM> wrote in[/color]
            > > message[color=darkred]
            > > > > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..
            > > > > > > Hello
            > > > > > >
            > > > > > > Unlike C++, C# doesn't support multiple implementaion[/color][/color][/color]
            inheritance.[color=blue][color=green]
            > > But[color=darkred]
            > > > > > your
            > > > > > > problem can be solved by deriving the class
            > > > ExtendedControl Funcionality
            > > > > > from
            > > > > > > Control and deriving your class from[/color][/color][/color]
            ExtendedControl Funcionality.[color=blue][color=green][color=darkred]
            > > > > > >
            > > > > > > Best regards,
            > > > > > >
            > > > > > > Sherif
            > > > > > >
            > > > > > >
            > > > > > > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
            > > > > > > news:#hz4qCmiDH A.1564@tk2msftn gp13.phx.gbl...
            > > > > > > > Hi,
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Please help me to understand this, because I don't see what[/color][/color][/color]
            I'm[color=blue][color=green][color=darkred]
            > > > > missing.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > I was reading a lot of examples on Internet that explain that[/color][/color][/color]
            C#[color=blue][color=green][color=darkred]
            > > > > doesn't
            > > > > > > > implement multiple inheritance it implement multiple[/color][/color][/color]
            interfaces.[color=blue][color=green][color=darkred]
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > So, I keep reading and reading and reading to see how can I[/color]
            > > resolve[color=darkred]
            > > > my
            > > > > > > > problem with interfaces.
            > > > > > > >
            > > > > > > > The conclusion is I'm writing to all of you because I couldn't[/color]
            > > find[color=darkred]
            > > > > the
            > > > > > > way
            > > > > > > > to resolve my problem.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > If I can create multiples interfaces and I have to implement[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > > > > methods
            > > > > > > on
            > > > > > > > the derived class, then what's the big deal.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > I know if I declare a class that inherit from one interface is
            > > > useful
            > > > > > > > because for example
            > > > > > > >
            > > > > > > > I can create an Interface called Shape, and 3 Classes called[/color]
            > > Circle,[color=darkred]
            > > > > > > > Rectangle, and Line.
            > > > > > > >
            > > > > > > > If on my interface I declare my method Draw(); and I implement[/color][/color]
            > on[color=green][color=darkred]
            > > > each
            > > > > > > > derived class then I could do the next.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > IShape s = (IShape) AnyShapeObject;
            > > > > > > >
            > > > > > > > s.draw();
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > I think is very useful and I used many times. But now the[/color][/color]
            > question[color=green][color=darkred]
            > > > is
            > > > > > what
            > > > > > > > is the similitude between Multiple Inheritance and Multiple
            > > > > > Interfaces????
            > > > > > > I
            > > > > > > > don't see too much
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Why on Internet always speak for Multiple Inheritance and[/color][/color]
            > Multiple[color=green][color=darkred]
            > > > > > > > Interfaces like they have a relation???
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > My Case:
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > I have many Windows Control and I'm inherit each one for[/color][/color][/color]
            create[color=blue]
            > my[color=green][color=darkred]
            > > > own
            > > > > > > > Controls.
            > > > > > > >
            > > > > > > > For example I want to add method called getVirtualSize( );
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > I create and interface
            > > > > > > >
            > > > > > > > IVirtualSize
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > It contain
            > > > > > > >
            > > > > > > > public getVirtualSize( );
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > So, on my derived class I MUST implement my method[/color][/color]
            > getVirtualSize[color=green][color=darkred]
            > > > and
            > > > > > > that's
            > > > > > > > it.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Very nice!!!
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Now the real question is, I create a lot of logic on my paint
            > > > method;
            > > > > > this
            > > > > > > > logic is exactly the same for all derived classes, why do I[/color][/color][/color]
            have[color=blue][color=green]
            > > to[color=darkred]
            > > > > > > > implement this entire logic on each Control???
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > With multiple inheritances you just create a class
            > > > > > > > ExtendedControl Funcionality and Implement a method OnPaintEx,[/color][/color]
            > and[color=green][color=darkred]
            > > > > really
            > > > > > I
            > > > > > > > have a nice source code, because my class
            > > > ExtendedControl Funcionality
            > > > > > has
            > > > > > > > all the new extended functionality.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Then how can I do the same with interfaces????
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > I don't want to put my piece of code on every derived class,[/color][/color][/color]
            it[color=blue]
            > is[color=green]
            > > a[color=darkred]
            > > > > > mess
            > > > > > > > and very difficult to maintain, I want to centralize my source[/color]
            > > code[color=darkred]
            > > > > and
            > > > > > in
            > > > > > > > the same time I want to use many methods of the base classes,[/color][/color]
            > that[color=green][color=darkred]
            > > > > means
            > > > > > I
            > > > > > > > want to use all the protected methods that the controls offer[/color][/color][/color]
            to[color=blue][color=green]
            > > me[color=darkred]
            > > > > > > because
            > > > > > > > OnPaintEx needs those.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Really, here is only one example, the reality is that is a lot[/color][/color]
            > of[color=green][color=darkred]
            > > > > source
            > > > > > > > code that I "should" implement on every Control, I don't want[/color][/color][/color]
            to[color=blue][color=green]
            > > do[color=darkred]
            > > > > > that.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > > Thanks, the answers will be really appreciated.
            > > > > > > >
            > > > > > > > Gustavo.
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > > >
            > > > > > >
            > > > > > >
            > > > > >
            > > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Fergus Cooney

              #36
              Re: Interfaces, Big Deal!!

              Hi Jay,

              || As has been demonstrated Multiple interfaces & delegation is
              || how you implement multiple inheritance in .NET. So obviously
              || they are related.

              They <are> related in that they use the words multiple and inheritance but
              the <quality> of that inheritance is radically different. As you say above
              ".... is how you implement...". With multiple inheritance of base classes you
              <don't> implement - the implementation is carried forward from the base class.

              || If you take implementation out of the picture.

              Exactly. But what a big if!!

              || Implementation is just one facet of the equation.

              Implementation is the first-order component in the equation!!

              To me, the the whole point of multiple class inheritance is bolt-on
              implementation. I define my Widget class with three words: Inherits
              BaseWidget, CapLinkable. Just that, and I've got a Widget which has
              linked-list capabilities and I haven't had to mess around with worker classes,
              delegates or anything else.

              Using a ShapeImpl, or another worker/helper, with call-backs to get
              protected and private members will work, sure, but it's a workaround - around
              the gap that multiple class inheritance would have filled.

              You have to define the IShape interface. Then you have to implement it,
              and, as it's going to be reuseable you implement it in ShapeImpl. But every
              class that wants it still has to implement IShape to instantiate and call its
              ShapeImpl. Then everything that ShapeImpl needs to do that accesses
              private/protected members requires either a Delegate or a part of the IShape
              interface - dedicated just to this inter-object communication - while the
              target object has to have receiving methods which do their thing and package
              up the results and passes them back.

              All of the above compared with: Inherits BaseClass, ShapeExtensions ,
              OtherUsefulStuf f.

              Hey, I added an extra word and got a whole bunch of other useful stuff.
              ;-)

              Well, that's my moan about it. I'd like the language/framework/compiler
              people to put the hard work in so that I can have reusable Capabilities. I'm
              not asking for much am I?**

              Regards,
              Fergus

              ** Yes, I know - I am! :-D


              Comment

              • Fergus Cooney

                #37
                Re: Interfaces, Big Deal!!

                Hi Jay,

                || As has been demonstrated Multiple interfaces & delegation is
                || how you implement multiple inheritance in .NET. So obviously
                || they are related.

                They <are> related in that they use the words multiple and inheritance but
                the <quality> of that inheritance is radically different. As you say above
                ".... is how you implement...". With multiple inheritance of base classes you
                <don't> implement - the implementation is carried forward from the base class.

                || If you take implementation out of the picture.

                Exactly. But what a big if!!

                || Implementation is just one facet of the equation.

                Implementation is the first-order component in the equation!!

                To me, the the whole point of multiple class inheritance is bolt-on
                implementation. I define my Widget class with three words: Inherits
                BaseWidget, CapLinkable. Just that, and I've got a Widget which has
                linked-list capabilities and I haven't had to mess around with worker classes,
                delegates or anything else.

                Using a ShapeImpl, or another worker/helper, with call-backs to get
                protected and private members will work, sure, but it's a workaround - around
                the gap that multiple class inheritance would have filled.

                You have to define the IShape interface. Then you have to implement it,
                and, as it's going to be reuseable you implement it in ShapeImpl. But every
                class that wants it still has to implement IShape to instantiate and call its
                ShapeImpl. Then everything that ShapeImpl needs to do that accesses
                private/protected members requires either a Delegate or a part of the IShape
                interface - dedicated just to this inter-object communication - while the
                target object has to have receiving methods which do their thing and package
                up the results and passes them back.

                All of the above compared with: Inherits BaseClass, ShapeExtensions ,
                OtherUsefulStuf f.

                Hey, I added an extra word and got a whole bunch of other useful stuff.
                ;-)

                Well, that's my moan about it. I'd like the language/framework/compiler
                people to put the hard work in so that I can have reusable Capabilities. I'm
                not asking for much am I?**

                Regards,
                Fergus

                ** Yes, I know - I am! :-D


                Comment

                • Jay B. Harlow [MVP - Outlook]

                  #38
                  Re: Interfaces, Big Deal!!

                  Fergus,
                  I am not disagreeing with you or Franco. Multiple Implementation Inheritance
                  is a very useful tool.

                  The problem is .NET does not offer it (1.0 or 1.1). Period. Based on the
                  published roadmap, it will not be offered in .NET 2.0.

                  Whether it will be offered in .NET 3.0 is anyone's guess.

                  Franco is trying to understand how in .NET they are related, I am trying to
                  explain to him how they are related.

                  So there is no need to get in some academic debate about how great & wonder
                  Multiple Implementation Inheritance is and how Multiple Interface
                  Inheritance is not related. I don't buy it.

                  I'm out of this conversation.

                  Hope this helps
                  Jay

                  "Fergus Cooney" <filter-1@tesco.net> wrote in message
                  news:etBJTEtiDH A.2520@TK2MSFTN GP09.phx.gbl...[color=blue]
                  > Hi Jay,
                  >
                  > || As has been demonstrated Multiple interfaces & delegation is
                  > || how you implement multiple inheritance in .NET. So obviously
                  > || they are related.
                  >
                  > They <are> related in that they use the words multiple and inheritance[/color]
                  but[color=blue]
                  > the <quality> of that inheritance is radically different. As you say above
                  > ".... is how you implement...". With multiple inheritance of base classes[/color]
                  you[color=blue]
                  > <don't> implement - the implementation is carried forward from the base[/color]
                  class.[color=blue]
                  >
                  > || If you take implementation out of the picture.
                  >
                  > Exactly. But what a big if!!
                  >
                  > || Implementation is just one facet of the equation.
                  >
                  > Implementation is the first-order component in the equation!!
                  >
                  > To me, the the whole point of multiple class inheritance is bolt-on
                  > implementation. I define my Widget class with three words: Inherits
                  > BaseWidget, CapLinkable. Just that, and I've got a Widget which has
                  > linked-list capabilities and I haven't had to mess around with worker[/color]
                  classes,[color=blue]
                  > delegates or anything else.
                  >
                  > Using a ShapeImpl, or another worker/helper, with call-backs to get
                  > protected and private members will work, sure, but it's a workaround -[/color]
                  around[color=blue]
                  > the gap that multiple class inheritance would have filled.
                  >
                  > You have to define the IShape interface. Then you have to implement[/color]
                  it,[color=blue]
                  > and, as it's going to be reuseable you implement it in ShapeImpl. But[/color]
                  every[color=blue]
                  > class that wants it still has to implement IShape to instantiate and call[/color]
                  its[color=blue]
                  > ShapeImpl. Then everything that ShapeImpl needs to do that accesses
                  > private/protected members requires either a Delegate or a part of the[/color]
                  IShape[color=blue]
                  > interface - dedicated just to this inter-object communication - while the
                  > target object has to have receiving methods which do their thing and[/color]
                  package[color=blue]
                  > up the results and passes them back.
                  >
                  > All of the above compared with: Inherits BaseClass, ShapeExtensions ,
                  > OtherUsefulStuf f.
                  >
                  > Hey, I added an extra word and got a whole bunch of other useful[/color]
                  stuff.[color=blue]
                  > ;-)
                  >
                  > Well, that's my moan about it. I'd like the[/color]
                  language/framework/compiler[color=blue]
                  > people to put the hard work in so that I can have reusable Capabilities.[/color]
                  I'm[color=blue]
                  > not asking for much am I?**
                  >
                  > Regards,
                  > Fergus
                  >
                  > ** Yes, I know - I am! :-D
                  >
                  >[/color]


                  Comment

                  • Jay B. Harlow [MVP - Outlook]

                    #39
                    Re: Interfaces, Big Deal!!

                    Fergus,
                    I am not disagreeing with you or Franco. Multiple Implementation Inheritance
                    is a very useful tool.

                    The problem is .NET does not offer it (1.0 or 1.1). Period. Based on the
                    published roadmap, it will not be offered in .NET 2.0.

                    Whether it will be offered in .NET 3.0 is anyone's guess.

                    Franco is trying to understand how in .NET they are related, I am trying to
                    explain to him how they are related.

                    So there is no need to get in some academic debate about how great & wonder
                    Multiple Implementation Inheritance is and how Multiple Interface
                    Inheritance is not related. I don't buy it.

                    I'm out of this conversation.

                    Hope this helps
                    Jay

                    "Fergus Cooney" <filter-1@tesco.net> wrote in message
                    news:etBJTEtiDH A.2520@TK2MSFTN GP09.phx.gbl...[color=blue]
                    > Hi Jay,
                    >
                    > || As has been demonstrated Multiple interfaces & delegation is
                    > || how you implement multiple inheritance in .NET. So obviously
                    > || they are related.
                    >
                    > They <are> related in that they use the words multiple and inheritance[/color]
                    but[color=blue]
                    > the <quality> of that inheritance is radically different. As you say above
                    > ".... is how you implement...". With multiple inheritance of base classes[/color]
                    you[color=blue]
                    > <don't> implement - the implementation is carried forward from the base[/color]
                    class.[color=blue]
                    >
                    > || If you take implementation out of the picture.
                    >
                    > Exactly. But what a big if!!
                    >
                    > || Implementation is just one facet of the equation.
                    >
                    > Implementation is the first-order component in the equation!!
                    >
                    > To me, the the whole point of multiple class inheritance is bolt-on
                    > implementation. I define my Widget class with three words: Inherits
                    > BaseWidget, CapLinkable. Just that, and I've got a Widget which has
                    > linked-list capabilities and I haven't had to mess around with worker[/color]
                    classes,[color=blue]
                    > delegates or anything else.
                    >
                    > Using a ShapeImpl, or another worker/helper, with call-backs to get
                    > protected and private members will work, sure, but it's a workaround -[/color]
                    around[color=blue]
                    > the gap that multiple class inheritance would have filled.
                    >
                    > You have to define the IShape interface. Then you have to implement[/color]
                    it,[color=blue]
                    > and, as it's going to be reuseable you implement it in ShapeImpl. But[/color]
                    every[color=blue]
                    > class that wants it still has to implement IShape to instantiate and call[/color]
                    its[color=blue]
                    > ShapeImpl. Then everything that ShapeImpl needs to do that accesses
                    > private/protected members requires either a Delegate or a part of the[/color]
                    IShape[color=blue]
                    > interface - dedicated just to this inter-object communication - while the
                    > target object has to have receiving methods which do their thing and[/color]
                    package[color=blue]
                    > up the results and passes them back.
                    >
                    > All of the above compared with: Inherits BaseClass, ShapeExtensions ,
                    > OtherUsefulStuf f.
                    >
                    > Hey, I added an extra word and got a whole bunch of other useful[/color]
                    stuff.[color=blue]
                    > ;-)
                    >
                    > Well, that's my moan about it. I'd like the[/color]
                    language/framework/compiler[color=blue]
                    > people to put the hard work in so that I can have reusable Capabilities.[/color]
                    I'm[color=blue]
                    > not asking for much am I?**
                    >
                    > Regards,
                    > Fergus
                    >
                    > ** Yes, I know - I am! :-D
                    >
                    >[/color]


                    Comment

                    • Fergus Cooney

                      #40
                      Re: Interfaces, Big Deal!!

                      Hi Jay,

                      I'm glad that you see a use for Multiple Implementation Inheritance.
                      Others argue against it in principle.

                      || I'm really not seeing how you consider them not to be related!

                      You said you had trouble understanding how Franco couldn't see that the
                      two inheritances were related in as intimate a way as you see it. I was
                      explaining how I see that connection as being weaker.

                      || Multiple Implementation Inheritance is and how Multiple Interface
                      || Inheritance is not related. I don't buy it.

                      I never said that they were unrelated. See above.

                      || I don't buy it. ... I'm out of this conversation

                      I'm sorry if it offended you that I express myself strongly on this issue.
                      It appears that way.

                      Regards,
                      Fergus


                      Comment

                      • Fergus Cooney

                        #41
                        Re: Interfaces, Big Deal!!

                        Hi Jay,

                        I'm glad that you see a use for Multiple Implementation Inheritance.
                        Others argue against it in principle.

                        || I'm really not seeing how you consider them not to be related!

                        You said you had trouble understanding how Franco couldn't see that the
                        two inheritances were related in as intimate a way as you see it. I was
                        explaining how I see that connection as being weaker.

                        || Multiple Implementation Inheritance is and how Multiple Interface
                        || Inheritance is not related. I don't buy it.

                        I never said that they were unrelated. See above.

                        || I don't buy it. ... I'm out of this conversation

                        I'm sorry if it offended you that I express myself strongly on this issue.
                        It appears that way.

                        Regards,
                        Fergus


                        Comment

                        • Cindy Winegarden

                          #42
                          Re: Interfaces, Big Deal!!

                          In news:uhPJUuniDH A.3392@tk2msftn gp13.phx.gbl,
                          Franco Gustavo <gfranco@inunti us.com> posted:[color=blue]
                          > So, that means if I use VS2003 wich compile with 1.1 can I :
                          > Create a Form, put a Background Image on the Form
                          > Create a Panel and set Color.Transpare ncy like a child of the Form
                          > Create a Radio button like Child of Panel
                          >
                          > And the background for the radio button will be the form
                          > Backgorund????? ???
                          >
                          > May you confirm that? if that's true is a excelent news and I'll
                          > switch to VS2003 the soon as possible[/color]

                          Hi Franco,

                          I'm not that great with VS.NET but (using VS.NET 2003) I created a form and
                          gave it a Background Image. I added a Panel with BackColor of
                          Web>Transparent , and added a Button on top of that, again Web>Transparent .
                          The button's background was the piece of the Form's Background Image that it
                          was on top of. It looked very nice.

                          --
                          Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
                          cindy.winegarde n@mvps.org, www.cindywinegarden.com


                          Comment

                          • Cindy Winegarden

                            #43
                            Re: Interfaces, Big Deal!!

                            In news:uhPJUuniDH A.3392@tk2msftn gp13.phx.gbl,
                            Franco Gustavo <gfranco@inunti us.com> posted:[color=blue]
                            > So, that means if I use VS2003 wich compile with 1.1 can I :
                            > Create a Form, put a Background Image on the Form
                            > Create a Panel and set Color.Transpare ncy like a child of the Form
                            > Create a Radio button like Child of Panel
                            >
                            > And the background for the radio button will be the form
                            > Backgorund????? ???
                            >
                            > May you confirm that? if that's true is a excelent news and I'll
                            > switch to VS2003 the soon as possible[/color]

                            Hi Franco,

                            I'm not that great with VS.NET but (using VS.NET 2003) I created a form and
                            gave it a Background Image. I added a Panel with BackColor of
                            Web>Transparent , and added a Button on top of that, again Web>Transparent .
                            The button's background was the piece of the Form's Background Image that it
                            was on top of. It looked very nice.

                            --
                            Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
                            cindy.winegarde n@mvps.org, www.cindywinegarden.com


                            Comment

                            Working...