Interfaces, Big Deal!!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fergus Cooney

    #16
    Re: Interfaces, Big Deal!!

    Hi Franco,

    I'm entirely in agreement with you on this issue. Yes, Interfaces have
    their (many) uses. But so does multiple inheritance.

    My case in point - I create many objects with a totally different nature.
    But I want them all to be capable of being in a linked list. I don't want to
    have to create a separate class to manage these links. I don't want a
    collection or an ArrayList. I simply want a Next and a Prev and a couple of
    other trivial bits.

    I'd like to define a small linked-list Capability class which I bolt-on to
    my other classes through multiple inheritance.

    But I can't. :-((

    My only recourse is to define an interface, CapLinkable, and <copy> the
    code (it's perfectly generic - needs not even a single character to be
    changed) into <every> class that is to have this Capability. [I only have this
    in C# because I can do it in about 15 lines - in VB it would probably be about
    75!!]

    But it's a maintenance nightmare, for I cannot even do it with <include>
    files - it has to be a textual copy each time!!

    There are many small pieces of functionality that would work for many,
    many disparate objects without code change required - or in your case, minimal
    changes.

    Another example is the ability to Serialise. This could be done through
    the inheritance of Capabilities. But no, it has to be done by setting an
    Attribute and having the serialization done behind the scenes as a fiddle by
    the Attribute in conjunction with a Formatter. Why can't an object serialise
    <itself> by inheriting from a CapSerializable Capability?

    It would be very useful if there were a mechanism for bolting these
    Capabilities onto a class without having to reimplement the wheel each time.

    Regards,
    Fergus


    Comment

    • Fergus Cooney

      #17
      Re: Interfaces, Big Deal!!

      Hi Franco,

      I'm entirely in agreement with you on this issue. Yes, Interfaces have
      their (many) uses. But so does multiple inheritance.

      My case in point - I create many objects with a totally different nature.
      But I want them all to be capable of being in a linked list. I don't want to
      have to create a separate class to manage these links. I don't want a
      collection or an ArrayList. I simply want a Next and a Prev and a couple of
      other trivial bits.

      I'd like to define a small linked-list Capability class which I bolt-on to
      my other classes through multiple inheritance.

      But I can't. :-((

      My only recourse is to define an interface, CapLinkable, and <copy> the
      code (it's perfectly generic - needs not even a single character to be
      changed) into <every> class that is to have this Capability. [I only have this
      in C# because I can do it in about 15 lines - in VB it would probably be about
      75!!]

      But it's a maintenance nightmare, for I cannot even do it with <include>
      files - it has to be a textual copy each time!!

      There are many small pieces of functionality that would work for many,
      many disparate objects without code change required - or in your case, minimal
      changes.

      Another example is the ability to Serialise. This could be done through
      the inheritance of Capabilities. But no, it has to be done by setting an
      Attribute and having the serialization done behind the scenes as a fiddle by
      the Attribute in conjunction with a Formatter. Why can't an object serialise
      <itself> by inheriting from a CapSerializable Capability?

      It would be very useful if there were a mechanism for bolting these
      Capabilities onto a class without having to reimplement the wheel each time.

      Regards,
      Fergus


      Comment

      • Jay B. Harlow [MVP - Outlook]

        #18
        Re: Interfaces, Big Deal!!

        Franco,
        As Sherif stated, .NET does not have Multiple Implementation Inheritance,
        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 a
        ShapeImpl implementation class. Your Circle class would implement the IShape
        interface, then contain a ShapeImpl object as a field, the IShape method
        would delegate to the ShapeImple class. NOTE, Circle would NOT inherit from
        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 properties
        you can attach event handlers to the targeted controls enabling you at add
        functionality.







        Hope this helps
        Jay


        "Franco Gustavo" <gfranco@inunti us.com> wrote in message
        news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=blue]
        > But Control doesn't do anything that I want.
        >
        > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
        RadioButton,[color=blue]
        > 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 message
        > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..[color=green]
        > > Hello
        > >
        > > Unlike C++, C# doesn't support multiple implementaion inheritance. But[/color]
        > your[color=green]
        > > problem can be solved by deriving the class ExtendedControl Funcionality[/color]
        > from[color=green]
        > > 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...[color=darkred]
        > > > Hi,
        > > >
        > > >
        > > >
        > > > Please help me to understand this, because I don't see what I'm[/color][/color][/color]
        missing.[color=blue][color=green][color=darkred]
        > > >
        > > >
        > > >
        > > > I was reading a lot of examples on Internet that explain that C#[/color][/color][/color]
        doesn't[color=blue][color=green][color=darkred]
        > > > implement multiple inheritance it implement multiple interfaces.
        > > >
        > > >
        > > >
        > > > So, I keep reading and reading and reading to see how can I resolve my
        > > > problem with interfaces.
        > > >
        > > > The conclusion is I'm writing to all of you because I couldn't find[/color][/color][/color]
        the[color=blue][color=green]
        > > way[color=darkred]
        > > > to resolve my problem.
        > > >
        > > >
        > > >
        > > > If I can create multiples interfaces and I have to implement the[/color][/color][/color]
        methods[color=blue][color=green]
        > > on[color=darkred]
        > > > 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 Circle,
        > > > Rectangle, and Line.
        > > >
        > > > If on my interface I declare my method Draw(); and I implement on 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 question is[/color][/color]
        > what[color=green][color=darkred]
        > > > is the similitude between Multiple Inheritance and Multiple[/color][/color]
        > Interfaces????[color=green]
        > > I[color=darkred]
        > > > 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 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 getVirtualSize and[/color]
        > > that's[color=darkred]
        > > > it.
        > > >
        > > >
        > > >
        > > > Very nice!!!
        > > >
        > > >
        > > >
        > > > Now the real question is, I create a lot of logic on my paint method;[/color][/color]
        > this[color=green][color=darkred]
        > > > logic is exactly the same for all derived classes, why do I have to
        > > > implement this entire logic on each Control???
        > > >
        > > >
        > > >
        > > > With multiple inheritances you just create a class
        > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color][/color][/color]
        really[color=blue]
        > I[color=green][color=darkred]
        > > > have a nice source code, because my class ExtendedControl Funcionality[/color][/color]
        > has[color=green][color=darkred]
        > > > 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 a[/color][/color]
        > mess[color=green][color=darkred]
        > > > and very difficult to maintain, I want to centralize my source code[/color][/color][/color]
        and[color=blue]
        > in[color=green][color=darkred]
        > > > the same time I want to use many methods of the base classes, that[/color][/color][/color]
        means[color=blue]
        > I[color=green][color=darkred]
        > > > want to use all the protected methods that the controls offer to me[/color]
        > > because[color=darkred]
        > > > OnPaintEx needs those.
        > > >
        > > >
        > > >
        > > > Really, here is only one example, the reality is that is a lot of[/color][/color][/color]
        source[color=blue][color=green][color=darkred]
        > > > code that I "should" implement on every Control, I don't want to do[/color][/color]
        > that.[color=green][color=darkred]
        > > >
        > > >
        > > >
        > > > Thanks, the answers will be really appreciated.
        > > >
        > > > Gustavo.
        > > >
        > > >
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jay B. Harlow [MVP - Outlook]

          #19
          Re: Interfaces, Big Deal!!

          Franco,
          As Sherif stated, .NET does not have Multiple Implementation Inheritance,
          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 a
          ShapeImpl implementation class. Your Circle class would implement the IShape
          interface, then contain a ShapeImpl object as a field, the IShape method
          would delegate to the ShapeImple class. NOTE, Circle would NOT inherit from
          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 properties
          you can attach event handlers to the targeted controls enabling you at add
          functionality.







          Hope this helps
          Jay


          "Franco Gustavo" <gfranco@inunti us.com> wrote in message
          news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=blue]
          > But Control doesn't do anything that I want.
          >
          > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
          RadioButton,[color=blue]
          > 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 message
          > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..[color=green]
          > > Hello
          > >
          > > Unlike C++, C# doesn't support multiple implementaion inheritance. But[/color]
          > your[color=green]
          > > problem can be solved by deriving the class ExtendedControl Funcionality[/color]
          > from[color=green]
          > > 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...[color=darkred]
          > > > Hi,
          > > >
          > > >
          > > >
          > > > Please help me to understand this, because I don't see what I'm[/color][/color][/color]
          missing.[color=blue][color=green][color=darkred]
          > > >
          > > >
          > > >
          > > > I was reading a lot of examples on Internet that explain that C#[/color][/color][/color]
          doesn't[color=blue][color=green][color=darkred]
          > > > implement multiple inheritance it implement multiple interfaces.
          > > >
          > > >
          > > >
          > > > So, I keep reading and reading and reading to see how can I resolve my
          > > > problem with interfaces.
          > > >
          > > > The conclusion is I'm writing to all of you because I couldn't find[/color][/color][/color]
          the[color=blue][color=green]
          > > way[color=darkred]
          > > > to resolve my problem.
          > > >
          > > >
          > > >
          > > > If I can create multiples interfaces and I have to implement the[/color][/color][/color]
          methods[color=blue][color=green]
          > > on[color=darkred]
          > > > 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 Circle,
          > > > Rectangle, and Line.
          > > >
          > > > If on my interface I declare my method Draw(); and I implement on 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 question is[/color][/color]
          > what[color=green][color=darkred]
          > > > is the similitude between Multiple Inheritance and Multiple[/color][/color]
          > Interfaces????[color=green]
          > > I[color=darkred]
          > > > 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 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 getVirtualSize and[/color]
          > > that's[color=darkred]
          > > > it.
          > > >
          > > >
          > > >
          > > > Very nice!!!
          > > >
          > > >
          > > >
          > > > Now the real question is, I create a lot of logic on my paint method;[/color][/color]
          > this[color=green][color=darkred]
          > > > logic is exactly the same for all derived classes, why do I have to
          > > > implement this entire logic on each Control???
          > > >
          > > >
          > > >
          > > > With multiple inheritances you just create a class
          > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color][/color][/color]
          really[color=blue]
          > I[color=green][color=darkred]
          > > > have a nice source code, because my class ExtendedControl Funcionality[/color][/color]
          > has[color=green][color=darkred]
          > > > 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 a[/color][/color]
          > mess[color=green][color=darkred]
          > > > and very difficult to maintain, I want to centralize my source code[/color][/color][/color]
          and[color=blue]
          > in[color=green][color=darkred]
          > > > the same time I want to use many methods of the base classes, that[/color][/color][/color]
          means[color=blue]
          > I[color=green][color=darkred]
          > > > want to use all the protected methods that the controls offer to me[/color]
          > > because[color=darkred]
          > > > OnPaintEx needs those.
          > > >
          > > >
          > > >
          > > > Really, here is only one example, the reality is that is a lot of[/color][/color][/color]
          source[color=blue][color=green][color=darkred]
          > > > code that I "should" implement on every Control, I don't want to do[/color][/color]
          > that.[color=green][color=darkred]
          > > >
          > > >
          > > >
          > > > Thanks, the answers will be really appreciated.
          > > >
          > > > Gustavo.
          > > >
          > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Franco Gustavo

            #20
            Re: Interfaces, Big Deal!!

            Exactly, You know perfect what I'm talking about.



            In fact on my example all the base classes have a class in common,

            "Control", and that is exactly what I need to change because all the OnPaint
            and OnPaintBackgrou nd are coming from Control Object.



            So is not crazy the idea that if I have Label, Panel, and GroupBox coming
            from a common class "Control" have the possibilities to change the behavior
            of the Base class.



            And having this functionality still I think is good OOP



            Thanks,

            Gustavo.



            "Fergus Cooney" <filter-1@tesco.net> wrote in message
            news:%23iEGpYni DHA.2224@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > Hi Franco,
            >
            > I'm entirely in agreement with you on this issue. Yes, Interfaces have
            > their (many) uses. But so does multiple inheritance.
            >
            > My case in point - I create many objects with a totally different[/color]
            nature.[color=blue]
            > But I want them all to be capable of being in a linked list. I don't want[/color]
            to[color=blue]
            > have to create a separate class to manage these links. I don't want a
            > collection or an ArrayList. I simply want a Next and a Prev and a couple[/color]
            of[color=blue]
            > other trivial bits.
            >
            > I'd like to define a small linked-list Capability class which I[/color]
            bolt-on to[color=blue]
            > my other classes through multiple inheritance.
            >
            > But I can't. :-((
            >
            > My only recourse is to define an interface, CapLinkable, and <copy>[/color]
            the[color=blue]
            > code (it's perfectly generic - needs not even a single character to be
            > changed) into <every> class that is to have this Capability. [I only have[/color]
            this[color=blue]
            > in C# because I can do it in about 15 lines - in VB it would probably be[/color]
            about[color=blue]
            > 75!!]
            >
            > But it's a maintenance nightmare, for I cannot even do it with[/color]
            <include>[color=blue]
            > files - it has to be a textual copy each time!!
            >
            > There are many small pieces of functionality that would work for many,
            > many disparate objects without code change required - or in your case,[/color]
            minimal[color=blue]
            > changes.
            >
            > Another example is the ability to Serialise. This could be done[/color]
            through[color=blue]
            > the inheritance of Capabilities. But no, it has to be done by setting an
            > Attribute and having the serialization done behind the scenes as a fiddle[/color]
            by[color=blue]
            > the Attribute in conjunction with a Formatter. Why can't an object[/color]
            serialise[color=blue]
            > <itself> by inheriting from a CapSerializable Capability?
            >
            > It would be very useful if there were a mechanism for bolting these
            > Capabilities onto a class without having to reimplement the wheel each[/color]
            time.[color=blue]
            >
            > Regards,
            > Fergus
            >
            >[/color]


            Comment

            • Franco Gustavo

              #21
              Re: Interfaces, Big Deal!!

              Exactly, You know perfect what I'm talking about.



              In fact on my example all the base classes have a class in common,

              "Control", and that is exactly what I need to change because all the OnPaint
              and OnPaintBackgrou nd are coming from Control Object.



              So is not crazy the idea that if I have Label, Panel, and GroupBox coming
              from a common class "Control" have the possibilities to change the behavior
              of the Base class.



              And having this functionality still I think is good OOP



              Thanks,

              Gustavo.



              "Fergus Cooney" <filter-1@tesco.net> wrote in message
              news:%23iEGpYni DHA.2224@TK2MSF TNGP10.phx.gbl. ..[color=blue]
              > Hi Franco,
              >
              > I'm entirely in agreement with you on this issue. Yes, Interfaces have
              > their (many) uses. But so does multiple inheritance.
              >
              > My case in point - I create many objects with a totally different[/color]
              nature.[color=blue]
              > But I want them all to be capable of being in a linked list. I don't want[/color]
              to[color=blue]
              > have to create a separate class to manage these links. I don't want a
              > collection or an ArrayList. I simply want a Next and a Prev and a couple[/color]
              of[color=blue]
              > other trivial bits.
              >
              > I'd like to define a small linked-list Capability class which I[/color]
              bolt-on to[color=blue]
              > my other classes through multiple inheritance.
              >
              > But I can't. :-((
              >
              > My only recourse is to define an interface, CapLinkable, and <copy>[/color]
              the[color=blue]
              > code (it's perfectly generic - needs not even a single character to be
              > changed) into <every> class that is to have this Capability. [I only have[/color]
              this[color=blue]
              > in C# because I can do it in about 15 lines - in VB it would probably be[/color]
              about[color=blue]
              > 75!!]
              >
              > But it's a maintenance nightmare, for I cannot even do it with[/color]
              <include>[color=blue]
              > files - it has to be a textual copy each time!!
              >
              > There are many small pieces of functionality that would work for many,
              > many disparate objects without code change required - or in your case,[/color]
              minimal[color=blue]
              > changes.
              >
              > Another example is the ability to Serialise. This could be done[/color]
              through[color=blue]
              > the inheritance of Capabilities. But no, it has to be done by setting an
              > Attribute and having the serialization done behind the scenes as a fiddle[/color]
              by[color=blue]
              > the Attribute in conjunction with a Formatter. Why can't an object[/color]
              serialise[color=blue]
              > <itself> by inheriting from a CapSerializable Capability?
              >
              > It would be very useful if there were a mechanism for bolting these
              > Capabilities onto a class without having to reimplement the wheel each[/color]
              time.[color=blue]
              >
              > Regards,
              > Fergus
              >
              >[/color]


              Comment

              • Lloyd Dupont

                #22
                Re: Interfaces, Big Deal!!

                I 100% agree Jay B. Harlow, It's my solution either.

                let's speak about your transparency problem now, you have 2 things to set
                (not one)
                1. a transparent background color
                2. SetStyle() there is a transparent flag.

                now if you have a top panel which is transparent, and use .NET 1.1 all your
                child control would be correctly transparent.

                "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> a écrit dans le
                message de news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=blue]
                > Franco,
                > As Sherif stated, .NET does not have Multiple Implementation Inheritance,
                > 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 a
                > ShapeImpl implementation class. Your Circle class would implement the[/color]
                IShape[color=blue]
                > 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=blue]
                > 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=blue]
                > you can attach event handlers to the targeted controls enabling you at add
                > functionality.
                >
                >[/color]
                http://msdn.microsoft.com/library/de...derobjects.asp[color=blue]
                >
                >[/color]
                http://msdn.microsoft.com/library/de...erprovider.asp[color=blue]
                >
                >[/color]
                http://msdn.microsoft.com/library/de...idersample.asp[color=blue]
                >
                > Hope this helps
                > Jay
                >
                >
                > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
                > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=green]
                > > But Control doesn't do anything that I want.
                > >
                > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
                > RadioButton,[color=green]
                > > 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 message
                > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
                > > > Hello
                > > >
                > > > Unlike C++, C# doesn't support multiple implementaion inheritance. But[/color]
                > > your[color=darkred]
                > > > problem can be solved by deriving the class[/color][/color][/color]
                ExtendedControl Funcionality[color=blue][color=green]
                > > from[color=darkred]
                > > > 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][/color]
                > missing.[color=green][color=darkred]
                > > > >
                > > > >
                > > > >
                > > > > I was reading a lot of examples on Internet that explain that C#[/color][/color]
                > doesn't[color=green][color=darkred]
                > > > > implement multiple inheritance it implement multiple interfaces.
                > > > >
                > > > >
                > > > >
                > > > > So, I keep reading and reading and reading to see how can I resolve[/color][/color][/color]
                my[color=blue][color=green][color=darkred]
                > > > > problem with interfaces.
                > > > >
                > > > > The conclusion is I'm writing to all of you because I couldn't find[/color][/color]
                > the[color=green][color=darkred]
                > > > way
                > > > > to resolve my problem.
                > > > >
                > > > >
                > > > >
                > > > > If I can create multiples interfaces and I have to implement the[/color][/color]
                > methods[color=green][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][/color]
                useful[color=blue][color=green][color=darkred]
                > > > > because for example
                > > > >
                > > > > I can create an Interface called Shape, and 3 Classes called Circle,
                > > > > Rectangle, and Line.
                > > > >
                > > > > If on my interface I declare my method Draw(); and I implement on[/color][/color][/color]
                each[color=blue][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][/color]
                is[color=blue][color=green]
                > > what[color=darkred]
                > > > > is the similitude between Multiple Inheritance and Multiple[/color]
                > > Interfaces????[color=darkred]
                > > > 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][/color]
                own[color=blue][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][/color]
                and[color=blue][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][/color]
                method;[color=blue][color=green]
                > > this[color=darkred]
                > > > > logic is exactly the same for all derived classes, why do I have to
                > > > > implement this entire logic on each Control???
                > > > >
                > > > >
                > > > >
                > > > > With multiple inheritances you just create a class
                > > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color][/color]
                > really[color=green]
                > > I[color=darkred]
                > > > > have a nice source code, because my class[/color][/color][/color]
                ExtendedControl Funcionality[color=blue][color=green]
                > > has[color=darkred]
                > > > > 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 a[/color]
                > > mess[color=darkred]
                > > > > and very difficult to maintain, I want to centralize my source code[/color][/color]
                > and[color=green]
                > > in[color=darkred]
                > > > > the same time I want to use many methods of the base classes, that[/color][/color]
                > means[color=green]
                > > I[color=darkred]
                > > > > want to use all the protected methods that the controls offer to me
                > > > because
                > > > > OnPaintEx needs those.
                > > > >
                > > > >
                > > > >
                > > > > Really, here is only one example, the reality is that is a lot of[/color][/color]
                > source[color=green][color=darkred]
                > > > > code that I "should" implement on every Control, I don't want to do[/color]
                > > that.[color=darkred]
                > > > >
                > > > >
                > > > >
                > > > > Thanks, the answers will be really appreciated.
                > > > >
                > > > > Gustavo.
                > > > >
                > > > >
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Lloyd Dupont

                  #23
                  Re: Interfaces, Big Deal!!

                  I 100% agree Jay B. Harlow, It's my solution either.

                  let's speak about your transparency problem now, you have 2 things to set
                  (not one)
                  1. a transparent background color
                  2. SetStyle() there is a transparent flag.

                  now if you have a top panel which is transparent, and use .NET 1.1 all your
                  child control would be correctly transparent.

                  "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> a écrit dans le
                  message de news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=blue]
                  > Franco,
                  > As Sherif stated, .NET does not have Multiple Implementation Inheritance,
                  > 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 a
                  > ShapeImpl implementation class. Your Circle class would implement the[/color]
                  IShape[color=blue]
                  > 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=blue]
                  > 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=blue]
                  > you can attach event handlers to the targeted controls enabling you at add
                  > functionality.
                  >
                  >[/color]
                  http://msdn.microsoft.com/library/de...derobjects.asp[color=blue]
                  >
                  >[/color]
                  http://msdn.microsoft.com/library/de...erprovider.asp[color=blue]
                  >
                  >[/color]
                  http://msdn.microsoft.com/library/de...idersample.asp[color=blue]
                  >
                  > Hope this helps
                  > Jay
                  >
                  >
                  > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
                  > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=green]
                  > > But Control doesn't do anything that I want.
                  > >
                  > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
                  > RadioButton,[color=green]
                  > > 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 message
                  > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
                  > > > Hello
                  > > >
                  > > > Unlike C++, C# doesn't support multiple implementaion inheritance. But[/color]
                  > > your[color=darkred]
                  > > > problem can be solved by deriving the class[/color][/color][/color]
                  ExtendedControl Funcionality[color=blue][color=green]
                  > > from[color=darkred]
                  > > > 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][/color]
                  > missing.[color=green][color=darkred]
                  > > > >
                  > > > >
                  > > > >
                  > > > > I was reading a lot of examples on Internet that explain that C#[/color][/color]
                  > doesn't[color=green][color=darkred]
                  > > > > implement multiple inheritance it implement multiple interfaces.
                  > > > >
                  > > > >
                  > > > >
                  > > > > So, I keep reading and reading and reading to see how can I resolve[/color][/color][/color]
                  my[color=blue][color=green][color=darkred]
                  > > > > problem with interfaces.
                  > > > >
                  > > > > The conclusion is I'm writing to all of you because I couldn't find[/color][/color]
                  > the[color=green][color=darkred]
                  > > > way
                  > > > > to resolve my problem.
                  > > > >
                  > > > >
                  > > > >
                  > > > > If I can create multiples interfaces and I have to implement the[/color][/color]
                  > methods[color=green][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][/color]
                  useful[color=blue][color=green][color=darkred]
                  > > > > because for example
                  > > > >
                  > > > > I can create an Interface called Shape, and 3 Classes called Circle,
                  > > > > Rectangle, and Line.
                  > > > >
                  > > > > If on my interface I declare my method Draw(); and I implement on[/color][/color][/color]
                  each[color=blue][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][/color]
                  is[color=blue][color=green]
                  > > what[color=darkred]
                  > > > > is the similitude between Multiple Inheritance and Multiple[/color]
                  > > Interfaces????[color=darkred]
                  > > > 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][/color]
                  own[color=blue][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][/color]
                  and[color=blue][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][/color]
                  method;[color=blue][color=green]
                  > > this[color=darkred]
                  > > > > logic is exactly the same for all derived classes, why do I have to
                  > > > > implement this entire logic on each Control???
                  > > > >
                  > > > >
                  > > > >
                  > > > > With multiple inheritances you just create a class
                  > > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color][/color]
                  > really[color=green]
                  > > I[color=darkred]
                  > > > > have a nice source code, because my class[/color][/color][/color]
                  ExtendedControl Funcionality[color=blue][color=green]
                  > > has[color=darkred]
                  > > > > 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 a[/color]
                  > > mess[color=darkred]
                  > > > > and very difficult to maintain, I want to centralize my source code[/color][/color]
                  > and[color=green]
                  > > in[color=darkred]
                  > > > > the same time I want to use many methods of the base classes, that[/color][/color]
                  > means[color=green]
                  > > I[color=darkred]
                  > > > > want to use all the protected methods that the controls offer to me
                  > > > because
                  > > > > OnPaintEx needs those.
                  > > > >
                  > > > >
                  > > > >
                  > > > > Really, here is only one example, the reality is that is a lot of[/color][/color]
                  > source[color=green][color=darkred]
                  > > > > code that I "should" implement on every Control, I don't want to do[/color]
                  > > that.[color=darkred]
                  > > > >
                  > > > >
                  > > > >
                  > > > > Thanks, the answers will be really appreciated.
                  > > > >
                  > > > > Gustavo.
                  > > > >
                  > > > >
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Franco Gustavo

                    #24
                    Re: Interfaces, Big Deal!!

                    > As Sherif stated, .NET does not have Multiple Implementation Inheritance,[color=blue]
                    > 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 a
                    > ShapeImpl implementation class. Your Circle class would implement the[/color]
                    IShape[color=blue]
                    > 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=blue]
                    > 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 and
                    private variables from Circle because is a object into the Circle object.
                    [color=blue]
                    > 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=blue]
                    > you can attach event handlers to the targeted controls enabling you at add
                    > 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 message
                    news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=blue]
                    > Franco,
                    > As Sherif stated, .NET does not have Multiple Implementation Inheritance,
                    > 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 a
                    > ShapeImpl implementation class. Your Circle class would implement the[/color]
                    IShape[color=blue]
                    > 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=blue]
                    > 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=blue]
                    > you can attach event handlers to the targeted controls enabling you at add
                    > functionality.
                    >
                    >[/color]
                    http://msdn.microsoft.com/library/de...derobjects.asp[color=blue]
                    >
                    >[/color]
                    http://msdn.microsoft.com/library/de...erprovider.asp[color=blue]
                    >
                    >[/color]
                    http://msdn.microsoft.com/library/de...idersample.asp[color=blue]
                    >
                    > Hope this helps
                    > Jay
                    >
                    >
                    > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
                    > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=green]
                    > > But Control doesn't do anything that I want.
                    > >
                    > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
                    > RadioButton,[color=green]
                    > > 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 message
                    > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
                    > > > Hello
                    > > >
                    > > > Unlike C++, C# doesn't support multiple implementaion inheritance. But[/color]
                    > > your[color=darkred]
                    > > > problem can be solved by deriving the class[/color][/color][/color]
                    ExtendedControl Funcionality[color=blue][color=green]
                    > > from[color=darkred]
                    > > > 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][/color]
                    > missing.[color=green][color=darkred]
                    > > > >
                    > > > >
                    > > > >
                    > > > > I was reading a lot of examples on Internet that explain that C#[/color][/color]
                    > doesn't[color=green][color=darkred]
                    > > > > implement multiple inheritance it implement multiple interfaces.
                    > > > >
                    > > > >
                    > > > >
                    > > > > So, I keep reading and reading and reading to see how can I resolve[/color][/color][/color]
                    my[color=blue][color=green][color=darkred]
                    > > > > problem with interfaces.
                    > > > >
                    > > > > The conclusion is I'm writing to all of you because I couldn't find[/color][/color]
                    > the[color=green][color=darkred]
                    > > > way
                    > > > > to resolve my problem.
                    > > > >
                    > > > >
                    > > > >
                    > > > > If I can create multiples interfaces and I have to implement the[/color][/color]
                    > methods[color=green][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][/color]
                    useful[color=blue][color=green][color=darkred]
                    > > > > because for example
                    > > > >
                    > > > > I can create an Interface called Shape, and 3 Classes called Circle,
                    > > > > Rectangle, and Line.
                    > > > >
                    > > > > If on my interface I declare my method Draw(); and I implement on[/color][/color][/color]
                    each[color=blue][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][/color]
                    is[color=blue][color=green]
                    > > what[color=darkred]
                    > > > > is the similitude between Multiple Inheritance and Multiple[/color]
                    > > Interfaces????[color=darkred]
                    > > > 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][/color]
                    own[color=blue][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][/color]
                    and[color=blue][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][/color]
                    method;[color=blue][color=green]
                    > > this[color=darkred]
                    > > > > logic is exactly the same for all derived classes, why do I have to
                    > > > > implement this entire logic on each Control???
                    > > > >
                    > > > >
                    > > > >
                    > > > > With multiple inheritances you just create a class
                    > > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color][/color]
                    > really[color=green]
                    > > I[color=darkred]
                    > > > > have a nice source code, because my class[/color][/color][/color]
                    ExtendedControl Funcionality[color=blue][color=green]
                    > > has[color=darkred]
                    > > > > 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 a[/color]
                    > > mess[color=darkred]
                    > > > > and very difficult to maintain, I want to centralize my source code[/color][/color]
                    > and[color=green]
                    > > in[color=darkred]
                    > > > > the same time I want to use many methods of the base classes, that[/color][/color]
                    > means[color=green]
                    > > I[color=darkred]
                    > > > > want to use all the protected methods that the controls offer to me
                    > > > because
                    > > > > OnPaintEx needs those.
                    > > > >
                    > > > >
                    > > > >
                    > > > > Really, here is only one example, the reality is that is a lot of[/color][/color]
                    > source[color=green][color=darkred]
                    > > > > code that I "should" implement on every Control, I don't want to do[/color]
                    > > that.[color=darkred]
                    > > > >
                    > > > >
                    > > > >
                    > > > > Thanks, the answers will be really appreciated.
                    > > > >
                    > > > > Gustavo.
                    > > > >
                    > > > >
                    > > > >
                    > > > >
                    > > >
                    > > >[/color]
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Franco Gustavo

                      #25
                      Re: Interfaces, Big Deal!!

                      > As Sherif stated, .NET does not have Multiple Implementation Inheritance,[color=blue]
                      > 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 a
                      > ShapeImpl implementation class. Your Circle class would implement the[/color]
                      IShape[color=blue]
                      > 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=blue]
                      > 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 and
                      private variables from Circle because is a object into the Circle object.
                      [color=blue]
                      > 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=blue]
                      > you can attach event handlers to the targeted controls enabling you at add
                      > 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 message
                      news:u20V6cniDH A.604@TK2MSFTNG P10.phx.gbl...[color=blue]
                      > Franco,
                      > As Sherif stated, .NET does not have Multiple Implementation Inheritance,
                      > 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 a
                      > ShapeImpl implementation class. Your Circle class would implement the[/color]
                      IShape[color=blue]
                      > 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=blue]
                      > 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=blue]
                      > you can attach event handlers to the targeted controls enabling you at add
                      > functionality.
                      >
                      >[/color]
                      http://msdn.microsoft.com/library/de...derobjects.asp[color=blue]
                      >
                      >[/color]
                      http://msdn.microsoft.com/library/de...erprovider.asp[color=blue]
                      >
                      >[/color]
                      http://msdn.microsoft.com/library/de...idersample.asp[color=blue]
                      >
                      > Hope this helps
                      > Jay
                      >
                      >
                      > "Franco Gustavo" <gfranco@inunti us.com> wrote in message
                      > news:uSkgoXmiDH A.3660@tk2msftn gp13.phx.gbl...[color=green]
                      > > But Control doesn't do anything that I want.
                      > >
                      > > Basically, I want derive from Label, Panel, GroupBox, CheckBox,[/color]
                      > RadioButton,[color=green]
                      > > 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 message
                      > > news:%23yrvKOmi DHA.1048@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
                      > > > Hello
                      > > >
                      > > > Unlike C++, C# doesn't support multiple implementaion inheritance. But[/color]
                      > > your[color=darkred]
                      > > > problem can be solved by deriving the class[/color][/color][/color]
                      ExtendedControl Funcionality[color=blue][color=green]
                      > > from[color=darkred]
                      > > > 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][/color]
                      > missing.[color=green][color=darkred]
                      > > > >
                      > > > >
                      > > > >
                      > > > > I was reading a lot of examples on Internet that explain that C#[/color][/color]
                      > doesn't[color=green][color=darkred]
                      > > > > implement multiple inheritance it implement multiple interfaces.
                      > > > >
                      > > > >
                      > > > >
                      > > > > So, I keep reading and reading and reading to see how can I resolve[/color][/color][/color]
                      my[color=blue][color=green][color=darkred]
                      > > > > problem with interfaces.
                      > > > >
                      > > > > The conclusion is I'm writing to all of you because I couldn't find[/color][/color]
                      > the[color=green][color=darkred]
                      > > > way
                      > > > > to resolve my problem.
                      > > > >
                      > > > >
                      > > > >
                      > > > > If I can create multiples interfaces and I have to implement the[/color][/color]
                      > methods[color=green][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][/color]
                      useful[color=blue][color=green][color=darkred]
                      > > > > because for example
                      > > > >
                      > > > > I can create an Interface called Shape, and 3 Classes called Circle,
                      > > > > Rectangle, and Line.
                      > > > >
                      > > > > If on my interface I declare my method Draw(); and I implement on[/color][/color][/color]
                      each[color=blue][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][/color]
                      is[color=blue][color=green]
                      > > what[color=darkred]
                      > > > > is the similitude between Multiple Inheritance and Multiple[/color]
                      > > Interfaces????[color=darkred]
                      > > > 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][/color]
                      own[color=blue][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][/color]
                      and[color=blue][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][/color]
                      method;[color=blue][color=green]
                      > > this[color=darkred]
                      > > > > logic is exactly the same for all derived classes, why do I have to
                      > > > > implement this entire logic on each Control???
                      > > > >
                      > > > >
                      > > > >
                      > > > > With multiple inheritances you just create a class
                      > > > > ExtendedControl Funcionality and Implement a method OnPaintEx, and[/color][/color]
                      > really[color=green]
                      > > I[color=darkred]
                      > > > > have a nice source code, because my class[/color][/color][/color]
                      ExtendedControl Funcionality[color=blue][color=green]
                      > > has[color=darkred]
                      > > > > 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 a[/color]
                      > > mess[color=darkred]
                      > > > > and very difficult to maintain, I want to centralize my source code[/color][/color]
                      > and[color=green]
                      > > in[color=darkred]
                      > > > > the same time I want to use many methods of the base classes, that[/color][/color]
                      > means[color=green]
                      > > I[color=darkred]
                      > > > > want to use all the protected methods that the controls offer to me
                      > > > because
                      > > > > OnPaintEx needs those.
                      > > > >
                      > > > >
                      > > > >
                      > > > > Really, here is only one example, the reality is that is a lot of[/color][/color]
                      > source[color=green][color=darkred]
                      > > > > code that I "should" implement on every Control, I don't want to do[/color]
                      > > that.[color=darkred]
                      > > > >
                      > > > >
                      > > > >
                      > > > > Thanks, the answers will be really appreciated.
                      > > > >
                      > > > > Gustavo.
                      > > > >
                      > > > >
                      > > > >
                      > > > >
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Franco Gustavo

                        #26
                        Re: Interfaces, Big Deal!!

                        Wow, do they fixed??

                        I'm using 1.0 and I set for my controls

                        this.SetStyle(C ontrolStyles.Al lPaintingInWmPa int, true);
                        this.SetStyle(C ontrolStyles.Us erPaint, true);
                        this.SetStyle(C ontrolStyles.Op aque, true);

                        And doing all the logic.

                        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

                        Thanks,
                        Gustavo.

                        "Lloyd Dupont" <net.galador@ld > wrote in message
                        news:%23Eytsini DHA.560@tk2msft ngp13.phx.gbl.. .[color=blue]
                        > I 100% agree Jay B. Harlow, It's my solution either.
                        >
                        > let's speak about your transparency problem now, you have 2 things to set
                        > (not one)
                        > 1. a transparent background color
                        > 2. SetStyle() there is a transparent flag.
                        >
                        > now if you have a top panel which is transparent, and use .NET 1.1 all[/color]
                        your[color=blue]
                        > child control would be correctly transparent.
                        >
                        > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> a écrit dans le
                        > message de 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

                          #27
                          Re: Interfaces, Big Deal!!

                          Wow, do they fixed??

                          I'm using 1.0 and I set for my controls

                          this.SetStyle(C ontrolStyles.Al lPaintingInWmPa int, true);
                          this.SetStyle(C ontrolStyles.Us erPaint, true);
                          this.SetStyle(C ontrolStyles.Op aque, true);

                          And doing all the logic.

                          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

                          Thanks,
                          Gustavo.

                          "Lloyd Dupont" <net.galador@ld > wrote in message
                          news:%23Eytsini DHA.560@tk2msft ngp13.phx.gbl.. .[color=blue]
                          > I 100% agree Jay B. Harlow, It's my solution either.
                          >
                          > let's speak about your transparency problem now, you have 2 things to set
                          > (not one)
                          > 1. a transparent background color
                          > 2. SetStyle() there is a transparent flag.
                          >
                          > now if you have a top panel which is transparent, and use .NET 1.1 all[/color]
                          your[color=blue]
                          > child control would be correctly transparent.
                          >
                          > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> a écrit dans le
                          > message de 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

                          • Rick

                            #28
                            Re: Interfaces, Big Deal!!

                            Check out the "decorator pattern". That might be what you're looking for
                            (at least how I interpretted your question)

                            Rick

                            Comment

                            • Rick

                              #29
                              Re: Interfaces, Big Deal!!

                              Check out the "decorator pattern". That might be what you're looking for
                              (at least how I interpretted your question)

                              Rick

                              Comment

                              • Jay B. Harlow [MVP - Outlook]

                                #30
                                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

                                Working...