Re: Why not multiple inheritance in C# and java



Its not really tight coupling. I have a an appserver that houses stateful
user sessions that house by business objects. These objects have Fields and
Methods, and an inbuilt O/R mapping layer. The user interface is simply a
"mirror" of the innards of the business objects. So if the UI changes a
Field, it tells the business object, via a WebService, eg
<Field id="FirstName" value="Radek"/>. The server keeps all internal
changes and publishes any other value changes, and the UI is responsible for
displaying the results. So each client widget, eg TextBox, CheckBox etc
must know what Field it is bound to (or method if its a Button), and
sufficient logic to compose a reasonable request to the server (you can
change more than value, and NULLs always complicate things etc). I would
love to encapsulate this in a class (which I have in the Gupta language) and
simply inherit from both the Windows Control type and my class. At worst, I
would have to tie change events together and invoke a method. The member
variables, such as the Field I am bound to are necessarily repeated for each
Windows control type, and that offends me. There is no such design/code
duplication on the server code.

Radek

"Wiebe Tijsma" <wiebeREMOVE@xxxxxxxxxxxxxxxxxx> wrote in message
news:u6yKPQZfFHA.2384@xxxxxxxxxxxxxxxxxxxxxxx
> Sounds like you're tightly coupling components directly to your model,
> maybe you just need to apply the MVC (Model-View Controller) pattern.
>
> You can mimic MI by delegating your interface to a class implementing the
> same interface right?
>
> It does require you to redeclare all implementing methods indeed, wich is
> a pain if your interface is fairly complex and need to implement it on
> many classes.
>
> Antoher option is to declare 2 interfaces/base class, and have your
> classes work with both. like the IXPathNavigable and XPathNavigator, where
> the declaring interface only consists of 1 method that retrieves the more
> complex base class instance:
>
> interface IXPathNavigable {
> XPathNavigator CreateNavigator();
> }
>
> like this:
>
> interface IMyInterface {
> ... many methods implementation ...
> }
>
> interface IMyInterfaceSource {
> IMyInterface GetMyInterface()
> }
>
> public class MyClass : IMyInterface, IMyInterfaceSource {
>
> /* many methods implementation */
>
> IMyInterface IMyInterfaceSource.GetMyInterface(){
> return this;
> }
>
> }
>
> // Your inherited components only need to implement IMyInterfaceSource, //
> wich could be relatively easy with 4 lines of code:
>
> public class MyCheckBox : CheckBox, IMyInterfaceSource {
> private IMyInterface implementation = new MyClass();
>
> IMyInterface IMyInterfaceSource.GetMyInterface(){
> return implementation;
> }
> }
>
> [ I do believe interfaces should be kept simple though, and if it requires
> a lot of methods, don't use interfaces but abstract base classes ]
>
> sometimes I miss some delphi functionality, where you can delegate the
> entire interface to a property of the instance. Explanation:
> http://www.netindustry.nl/blog/2005/04/wheres-in-c.html
>
> Hmm maybe I should write an article about it, any suggestions? ;-)
>
> About the table normalization, isn't a table layout much more limited than
> MI? I don't even use databases at the moment that use table inheritance at
> all, let alone multiple table inheritance, wich one do you use?
>
> Wiebe
>
> Radek Cerny wrote:
>> In my architecture, I keep 100% separation of business functionality from
>> presentation layer (Web Services connect a rich,thin client to functional
>> server objects). So I have two separate cases. Server-side, I have more
>> control over, as I do not use Datasets or such - my objects are built
>> from the ground up.
>> However, on the client, I must provide all controls that are capable of
>> talking my specific Web Service schema to the server, but I must inherit
>> from the standard WinForms controls. I have no choice but to replicate
>> code in a checkbox, textbox, radio button class etc. If I had MI, I
>> would have an abstract class that understood my schema, and all the
>> window classes would inherit from that as well as the .NET supplied
>> standard Windows classes. For now, I can only implement an interface,
>> but there is much code that is identical across controls.
>> Server-side, I would still like MI, but learned to live without it.
>> Philosophically, I can not understand those who do not appreciate MI;
>> used correctly, you can normalise your code base like you would normalise
>> your database.
>>
>> Radek
>>
>> "Wiebe Tijsma" <wiebeREMOVE@xxxxxxxxxxxxxxxxxx> wrote in message
>> news:%23RBsqKXfFHA.1444@xxxxxxxxxxxxxxxxxxxxxxx
>>
>>>I'd be interested in wich cases, I've been thinking a lot about that...
>>>(not out of scepticism, but out of ... em interest & learning
>>>possibilities)
>>>
>>>Care to enlighten me?
>>>
>>>Thanks,
>>>
>>>Wiebe
>>>
>>>
>>>Radek Cerny wrote:
>>>
>>>>I agree wholeheartedly. I had MI in a previous world (Gupta/Centura
>>>>4GL) and I miss it dearly. Mind you I think that all in all, c# is
>>>>pretty damn good, but I can make several real cases where MI is the
>>>>correct design/model and would save a fair amount of duplication. I
>>>>have pretty much given up hope on ever seeing it in the CLR tho.
>>>>
>>>>Radek
>>>>
>>>>"Mark Broadbent" <nospam@xxxxxxxxxx> wrote in message
>>>>news:unsVQXJfFHA.1948@xxxxxxxxxxxxxxxxxxxxxxx
>>>>
>>>>
>>>>>http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85562.aspx
>>>>>
>>>>>My personal opinion (for what it is worth!) is that it is a real shame
>>>>>not to include this (regardless of all the potential pitfalls). Having
>>>>>heard a speech by Anders a couple of years back, I got the impression
>>>>>that he really didn't like it. But I guess that there has been only a
>>>>>few occasions that I thought that I really wanted to be able to do this
>>>>>...but maybe my approach is different because I know I can't.
>>>>>
>>>>>Br,
>>>>>
>>>>>Mark.
>>>>>
>>>>>"MAHESH MANDHARE" <mahesh_dotnetinfo@xxxxxxxxxxx> wrote in message
>>>>>news:3B3A3CAE-788A-4227-B6B6-1FE6BF99F8F8@xxxxxxxxxxxxxxxx
>>>>>
>>>>>
>>>>>>Hi ,
>>>>>>Can Anyone explain me exactly why multiple inheritance not used in
>>>>>>java and c#
>>>>>>thanks,
>>>>>>Mahesh
>>>>>>--
>>>>>>Have A Good Day,
>>>>>>Mahesh,
>>>>>>Maheshmandhare@xxxxxxxxxxx
>>>>>
>>>>>
>>


.