Multiple base classes in .NET

This is a discussion on Multiple base classes in .NET within the Framework and Interface Programming forums in category; "Larry Smith" <no_spam @ _nospam.com> wrote in message news:eZO4O8axHHA.1208 @ TK2MSFTNGP05.phx.gbl... > Thanks for the clarification (appreciated). As for the rumour, I'm not > sure how they'll tackle that given that there already seem to be some > built-in assumptions based on single-inheritance. They could change this > of course but it might cause a lot of problems. Anyway, thanks again. I'd be surprised if we ever see multiple inheritance in C#... http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx http://www.google.co.uk/search?hl=en...eritance&meta= -- Mark Rae ASP.NET MVP http://www.markrae.net...

Go Back   Application Development Forum > Framework and Interface Programming

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #11  
Old 07-13-2007, 09:05 PM
Mark Rae [MVP]
Guest
 
Default Re: Multiple base classes in .NET

"Larry Smith" <no_spam@_nospam.com> wrote in message
news:eZO4O8axHHA.1208@TK2MSFTNGP05.phx.gbl...

> Thanks for the clarification (appreciated). As for the rumour, I'm not
> sure how they'll tackle that given that there already seem to be some
> built-in assumptions based on single-inheritance. They could change this
> of course but it might cause a lot of problems. Anyway, thanks again.


I'd be surprised if we ever see multiple inheritance in C#...

http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx
http://www.google.co.uk/search?hl=en...eritance&meta=


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Reply With Quote
  #12  
Old 07-14-2007, 10:43 AM
Larry Smith
Guest
 
Default Re: Multiple base classes in .NET

> I'd be surprised if we ever see multiple inheritance in C#...
>
> http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx
> http://www.google.co.uk/search?hl=en...eritance&meta=


I'd be surpised as well. It's not likely to take off given that it's already
established as single inheritance. Moreover, it's rarely even used in the
C++ world. From my own (long) experience in that arena, it makes sense
conceptually but in practice it's mechanically very difficult to work with.
I doubt significant improvements can be made on this front.


Reply With Quote
  #13  
Old 07-14-2007, 10:43 AM
Larry Smith
Guest
 
Default Re: Multiple base classes in .NET

> I'd be surprised if we ever see multiple inheritance in C#...
>
> http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx
> http://www.google.co.uk/search?hl=en...eritance&meta=


I'd be surpised as well. It's not likely to take off given that it's already
established as single inheritance. Moreover, it's rarely even used in the
C++ world. From my own (long) experience in that arena, it makes sense
conceptually but in practice it's mechanically very difficult to work with.
I doubt significant improvements can be made on this front.


Reply With Quote
  #14  
Old 07-14-2007, 11:37 AM
Mark Rae [MVP]
Guest
 
Default Re: Multiple base classes in .NET

"Larry Smith" <no_spam@_nospam.com> wrote in message
news:%23A5C5UixHHA.3328@TK2MSFTNGP03.phx.gbl...

> I'd be surpised as well. It's not likely to take off given that it's
> already established as single inheritance. Moreover, it's rarely even used
> in the C++ world. From my own (long) experience in that arena, it makes
> sense conceptually but in practice it's mechanically very difficult to
> work with. I doubt significant improvements can be made on this front.


Indeed. I've been using C# since the latter half of 2002 and have never had
any need for multiple inheritance...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Reply With Quote
  #15  
Old 07-14-2007, 11:37 AM
Mark Rae [MVP]
Guest
 
Default Re: Multiple base classes in .NET

"Larry Smith" <no_spam@_nospam.com> wrote in message
news:%23A5C5UixHHA.3328@TK2MSFTNGP03.phx.gbl...

> I'd be surpised as well. It's not likely to take off given that it's
> already established as single inheritance. Moreover, it's rarely even used
> in the C++ world. From my own (long) experience in that arena, it makes
> sense conceptually but in practice it's mechanically very difficult to
> work with. I doubt significant improvements can be made on this front.


Indeed. I've been using C# since the latter half of 2002 and have never had
any need for multiple inheritance...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Reply With Quote
  #16  
Old 07-14-2007, 01:00 PM
Peter Duniho
Guest
 
Default Re: Multiple base classes in .NET

(removed microsoft.public.vstudio.extensibility and
microsoft.public.dotnet.framework.clr due to lack of relevance and
reduction of cross-posting)

On Sat, 14 Jul 2007 07:42:37 -0700, Larry Smith <no_spam@_nospam.com>
wrote:

> I'd be surpised as well. It's not likely to take off given that it's
> already
> established as single inheritance. Moreover, it's rarely even used in the
> C++ world. From my own (long) experience in that arena, it makes sense
> conceptually but in practice it's mechanically very difficult to work
> with.
> I doubt significant improvements can be made on this front.


IMHO, C# already does make an improvement over multiple inheritance vs
C++. That is, a class can in fact inherit multiple interfaces. This
allows for the same basic behavior as multiple inheritance, while forcing
the programmer to be explicit about how the class is arranged (ambiguity
in behavior of base classes shared by multiply inherited classes being one
of the bigger stumbling blocks for multiple inheritance in C++, IMHO).

Pete
Reply With Quote
  #17  
Old 07-18-2007, 04:34 AM
Paul Werkowitz
Guest
 
Default Re: Multiple base classes in .NET

Am Sat, 14 Jul 2007 16:37:06 +0100 schrieb Mark Rae [MVP]:

>
> Indeed. I've been using C# since the latter half of 2002 and have never had
> any need for multiple inheritance...


Hello, how then can you advise me to implement the following:

I have derivations from the standard WinForm Controls that implement
certain protocols for loading, storing, verification etc. Code example:

//-----------------------------------------------------------------
// boBindName
//
[
Bindable (true)
, Category ("QFC")
, Description ("Feld/Property, an das gebunden werden soll")
]
public string boBindName
{
get { return mBoBindName; }
set { mBoBindName = value; }
}

I have many of those.

At the moment, I need to have the exact same code in all of my derived
controls. Any change in that code must be manually repeated for all
controls - a perfect situation for implementation inheritance with the help
of MI.

Paule

Reply With Quote
  #18  
Old 07-18-2007, 04:34 AM
Paul Werkowitz
Guest
 
Default Re: Multiple base classes in .NET

Am Sat, 14 Jul 2007 16:37:06 +0100 schrieb Mark Rae [MVP]:

>
> Indeed. I've been using C# since the latter half of 2002 and have never had
> any need for multiple inheritance...


Hello, how then can you advise me to implement the following:

I have derivations from the standard WinForm Controls that implement
certain protocols for loading, storing, verification etc. Code example:

//-----------------------------------------------------------------
// boBindName
//
[
Bindable (true)
, Category ("QFC")
, Description ("Feld/Property, an das gebunden werden soll")
]
public string boBindName
{
get { return mBoBindName; }
set { mBoBindName = value; }
}

I have many of those.

At the moment, I need to have the exact same code in all of my derived
controls. Any change in that code must be manually repeated for all
controls - a perfect situation for implementation inheritance with the help
of MI.

Paule

Reply With Quote
  #19  
Old 07-18-2007, 04:42 AM
Paul Werkowitz
Guest
 
Default Re: Multiple base classes in .NET

Am Sat, 14 Jul 2007 09:59:39 -0700 schrieb Peter Duniho:

> IMHO, C# already does make an improvement over multiple inheritance vs
> C++. That is, a class can in fact inherit multiple interfaces.


A class can implement multiple interfaces - roughly the same as in C++
(minor differences ignored). But a class in C# cannot use implementation
inheritance, which can be very useful. You have to duplicate the code, use
delegation etc.

>This
> allows for the same basic behavior as multiple inheritance, while forcing
> the programmer to be explicit about how the class is arranged (ambiguity
> in behavior of base classes shared by multiply inherited classes being one
> of the bigger stumbling blocks for multiple inheritance in C++, IMHO).


No, disagree. The same ambiguity problems can arise when you implement
multiple interfaces in a C#-class. The solution is the same, though:
Compiler gives notice, and you have to manually resolve the amiguity,
usually by qualifying the name. No problem.

Paule
Reply With Quote
  #20  
Old 07-18-2007, 07:23 AM
Richard
Guest
 
Default Re: Multiple base classes in .NET

[Please do not mail me a copy of your followup]

Paul Werkowitz <newsgroups@primaprogramm.de> spake the secret code
<1fd4e049y61vc$.i7k81e3krf13$.dlg@40tude.net> thusly:

>Am Sat, 14 Jul 2007 16:37:06 +0100 schrieb Mark Rae [MVP]:
>
>>
>> Indeed. I've been using C# since the latter half of 2002 and have never had
>> any need for multiple inheritance...

>
>Hello, how then can you advise me to implement the following:
>
>I have derivations from the standard WinForm Controls that implement
>certain protocols for loading, storing, verification etc. Code example:
>
> //-----------------------------------------------------------------
> // boBindName
> //
> [
> Bindable (true)
> , Category ("QFC")
> , Description ("Feld/Property, an das gebunden werden soll")
> ]
> public string boBindName
> {
> get { return mBoBindName; }
> set { mBoBindName = value; }
> }
>
>I have many of those.
>
>At the moment, I need to have the exact same code in all of my derived
>controls. Any change in that code must be manually repeated for all
>controls - a perfect situation for implementation inheritance with the help
>of MI.


Personally, I'd question any design that is encouraging you to
subclass every .NET WinForms Control.

MI is only one way to aggregate behaviors, not the only way. In .NET
you can implement multiple interfaces to aggregate multiple behaviors
into a single class. In .NET 2 you also have generics, so you can do
template type tricks:

class BindableControl<T> : T
{
[Bindable(true)]
[Category("QFC")]
[Description("...")]
public string boBindName
{
get { return mBoBindName; }
set { mBoBindName = value; }
}
private string mBoBindName;
}

This eliminates the duplication, but it still is requiring you to
subclass every .NET control. I'd consider other design alternatives
that wouldn't require you to do this.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:26 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.