More about multiple inheritance

OK, you can solve problems where multiple inheritance is needed by using interfaces. But im facing a problem where it cant help me. Im constructing a system where there are componentes that need to extend JTextField as well Observable. I dont have interfaces above it in the hierarchy to substitute multiple inheritance. What can I do?
When you have a scenario that you have to use two (or more) third party classes, and need to inherit from both, how do interfaces can help? If ate least I had multiple inheritance from classes...

<< Begin Rant >>
I have seen more inherited code that is terribly designed because multiple inheritence was available.
The example provided is a perfect example of this: At first blush, it seems easy to combine the UI and data components by combining Observable and JTextArea. If you were able to do this, the person inheriting your code in 3 years will curse your name.
Nothing pisses me off more (well, I'm sure there are other things, but...) than attempting to debug C++ source code and finding that function calls are being made to multiple super classes.
Here's a fun one: try adding an innocuous method getInfo() to a class you've inherited, only to find that someone uses getInfo() in one of the super-classes, and it has been declared as 'friend' because the design is piss poor and it was the only way they could make the function available. Now, I have to go on a goose chase searching for all the places in the entire type hierarchy that getInfo() is used and change the code to explicitly call the other base class.
It gets to the point where its easier to name it getInfo2() (like that's good design) and get on with things.
MI is evil, evil, evil in any environment where you are trying to have code re-use and multiple teams.
I find that most programmers who insist that multiple inheritence is a good thing just don't know how to use the Composite design pattern.
Sun's decision to not support MI in Java is a sound one: the result is code that can be easily read and understood.
<< End Rant >>
Whew... I feel much better having said that...
- K

Similar Messages

  • INF Looking for means to dialog C#-Dev team about multiple inheritance.

    Please help.
    I really need multiple inheritance with C#. Is there any forum/means to have a dialog with the dev's for C# about this? The amount of extra work and maintenance costs of not having multiple inheritance has been a big problem, but lately, it has really become
    a burden for not having. The maintainability and reuse-ability of code is drastically reduced without it.

    Btw, I think that this has been discussed
    many times before. Almost once or twice each year since .NET is released (that's 12 years by now).
    I don't think you can make them allow this feature as tons of example trying to convince them this is needed has been proved not necessary to use multiple inheritance by them.
    Many of the discussions ends with something like "Java also does not support multiple inheritance but there isn't seems to be a problem for them". Maybe you can get more luck to convince Oracle to include MI in Java first.
    Btw, I found it hard to believe you need Multiple Implementation Inheritance to... improve maintainability of code? WTF??? I think Multiple Implementation Inheritance has it own place in the hall of fame for the bugs it caused in languages that supports
    it, even in C++.

  • Question about multiple inheritance

    Why does java not support multiple inheritance, but also give you the ability to use interfaces?
    I've done a quick search on here which turned up the same thing as the books on java I've read - they tell me that java doesn't support multiple inheritance, and that it supports interfaces, but not why.
    And from what I can see, the between multiple inheritance and single inheritance + interfaces make them seem almost equivalent, especially when you consider abstract classes. So why did the java designers make this decision?
    Edit: Just to say I've never programmed in an OO language that supports multiple inheritance, so I've never had to deal with it. Also, single inheritance has never crippled any of my designs (not that there have been that many), I'm not whingeing, just asking.
    Message was edited by:
    Dross

    Why does java not support multiple
    inheritance, but also give you the ability to use
    interfaces?It does support MI, just not MI of Implementation.
    why.
    class Beasty { }
    class Horse extend Beasty {
       public void gallop() { System.out.println( "horse" ); }
    class Donkey extend Beasty  {
       public void gallop() { System.out.println( "donkey" ); }
    class Mule extend House, Donkey {
    Mule mule = new Mule();
    mule.gallop();what would this print out.
    MI of implementation makes life harder, but adds very little to the party. So why add it?

  • Where can I learn more about multiple Apple IDs when I have multiple Apple computers?

    I have both an iMac and a Macbook Pro.  However, I can only locate one Apple ID and that is for my Macbook Pro.  How do I locate my Apple ID for my iMac.?

    my iMac is not associated with my Apple ID
    Have you gone here and checked if all of your machines are listed here (and if not, simply add whatever is missing):
    https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/classicLogin?appIdKey= 58ef9db8ff4d201409e7270a68e4408ae1678e1618204c476572a1b5e5fb3518&path&language=U S-EN
    Also, what's important is when you check into the app store: can you purchase/download anything using your Apple ID on either of your Macs?

  • How java support multiple inheritance by the use of interface.

    As per my understanding, Interface is just having the signatures of the methods not the implementation.
    So How java support multiple inheritance by the use of interface?
    Answer 1: we can institate interface reference by its implemented
    class.
              ����� interface inf...
              ����� class aa implements inf..
              ����� class bb implements inf....
               Now, inf i = new aa();
               inf i = new bb();
    Answer 2: We can extends as many interface as we want in the
    single
               interface.
               i.e. interface infFirst....
               interface infSecond....
               interface infThird....
               Now ,
               interface ingMulti extends infFrist, infThird...
    By above two answers its not prity clear as per the multiple inheritance in C or C++.
               i.e.
               class first{
               method abc();....}
               class second{
               method bbc()......}
               class multi::first::second{
               we can call to abc();.....as well as bbc();
    -Please give your important suggstion on the same.(Hope I explain it well.)
    -Jeff

    The keyword implement is used only for interfaces not
    for abstract class. If i am wrong correct me.I believe your right, but I will double check.
    As for the multiple inheritence think about the following code:
    class Animal {
        //  Animal generic stuff in this class
    interface Eat {
        //  Generic stuff that models eating behavior
    interface Runs {
        //  generic methods that model running behavior
    public class Horse extends Animal implements Eat, Runs {
        //  Stuff specific to a horse
    }The Animal class is generic but has stuff in it common to all animals.
    The Eat interface models behavior that is generic to eating, all living things have to eat something to survive. Herbavore are different from carnivores.
    The Runs interface models generic behavior to running, such as speed. A cheeta definately runs faster than a human.
    This brings us to the Horse class. It extends the Animal class because it "is-a" animal, and it implements the eat and runs interface because they are behaviors a horse has.
    I hope that helps.
    Extending an abstract class is the same as extending a regular class with the exception you MUST override all abstract methods in the abstract class. Thats not too difficult but I believe when designing classes, designing an abstract can be more diffecult than modeling the base class, and generic behaviors in interfaces. JMO.
    JJ

  • Multiple Inheritance

    Hello,
    I have been programming Java for last year,
    evolved in quite some skills with it, and
    really think it is great...
    However, I was shocked to find out that there
    is no multiple inheritance feature.
    I know it is rare, and my case proves it
    (1 year now, I never needed it)
    HOWEVER, when one needs multiple inheritance,
    then they really do need it.
    I have interfaces which I would like implemented
    in their respective class (ie ISomething be
    implemented in CSomething), then some classes
    I need to implement many of those interfaces...
    Now I am forced to have those classes extend
    multiple interfaces, and duplicate the interface
    implementation code inside each of them.
    I dont mind a little bit of copy/paste, nor
    do I care about the compiled classes being
    slightly bigger, BUT the problem is that
    when I need to change some behaviour in those
    interfaces, in the near (or far) future, I will
    have their implementation scattered in many
    classes... This is dangerously error prone and
    not proffesional at all... And I do not think
    that including multiple inheritance in the language
    could be more error prone than this...
    I think the Java team does a 100% perfect brilliant
    job, but at this specific point, they "over-tried"
    to "protect" the programmers from themselves...
    Well, thats all,
    I think some next version of Java should support
    multiple inheritance. And the Java "warning" could be :
    "if you havent missed it till now, then you probably
    do not need anyway, so do not bother using it just
    because it exists"
    Thanks for reading my thoughts,
    Dimitris

    Personally I never need multiple inheritance of code and I try to avoid inheritance of code whenever possible. A common mistake in OO is too use inheritance as a way of reusing code. Code reuse is much easier, cleaner and more powerful by using composition instead. Only use inheritance for polymorhism (to use multiple implementations for the same interface). An example:
    interface A {
      void ma();
      void maa();
    interface B {
      void mb();
    class C implements A, B {
      private A a;
      private A c;
      private B b;
      public void ma() {
        a.ma();
      public void maa() {
        c.maa();
      public void mb() {
        b.mb();
    }This is much more powerful than code reuse through inheritance. In this example I use one method from 'a' and one method from 'c' when I implement interface A. I can change the value of 'a', 'b' and 'c' during runtime, and I dont have to reuse all the code in 'a' and 'b', I can select which code to reuse. This is the power of composition and interfaces. Note that I only access 'a', 'b' and 'c' through the interfaces A and B, never directly through their implementations.
    I would recommend you to look at your design and start to think about interfaces and inheritance, not about code reuse though inheritance.

  • Enumerate multiple inheritance scenarios and their java equivalents?

    hi,
    ppl have often said things like
    "java doesn't support multiple inheritance but this is ok, since there are other mechanisms for doing the same thing (by which we nearly always mean interfaces)"
    how solid a statement is this? are there any formal methods available eg smt like "over all possible inheritance trees over all possible classes, only a handful of cases are distinct when viewed from the converting-to-single-inheritance scheme"?
    the two things mentioned as harder to workaround are mixins and the diamond problem - are there more?
    also what other mechanism apart from interfaces (if any) are useful?
    any help appreciated,
    asjf

    What I say is that it doesn't matter since there is
    almost never any need for MI. Most of the time it is
    used it is used because the developer/designer did not
    understand what they were doing and it should not have
    been used in the first place.
    That leaves one with very few cases where it should
    ever be used. And that coupled with the fact that a
    developer should never use it unless they are very
    experienced (so that they actually know that it should
    be used,) means that practicing programmers should
    leave discussion of such usages to scholarly
    journals.thanks :) I guess my problem is that often with computer stuff you don't have to rely on other peoples experience about things - you can go and test it yourself
    I've done very little C++ development, and so have never come across real-world multiple inheritance. I bumped into the first situation with some java code where it might've been a neat solution recently but this could easily fit into the "designer did not understand what they were doing" category from above..
    will have a casual look around the scholarly journals if I can find any that look promising :)
    asjf

  • Replacement for multiple inheritance in MovieClip class

    Hello
    I need your opinion about a problem.
    Commonly, when you need to replace multiple inheritance, you do it by making an aggregation with one of the class involved.
    But in case of MovieClip attached class, there is one more class involved in the process : the MovieClip class, and this class can't be the one aggregated because every class attached to a MovieClip need to inherits from it.
    The problem is if the other class can't be also aggregated because it has some abstract class behaviour, for instance, call of a virtual function.
    A solution could be making the abstract class inherit from the MovieClip class, but what if you want to reuse its behaviour in a class which have nothing to do with MovieClip ?

    This is Not Supported in WebLogic that the Remote Interface extends other Interfaces. Because Annotation Processor just looks up inside the implemented interface methods. The actual interface which is Implemented by the Bean Class. So the Methods declared inside the Interface B and Interface C will be ignored and will not be available as part of the generated Stubs. Thats why u are getting NoSuchMethodError.
    You can even contact Oracle Support on this...there are 3-4 Cases on it. And the Solution is Work As Designed.
    Workaround is : edit your interface A as following
    Declare all the Business Methods only in the Remote Interface and not inside it's Super Interfaces.
    Example:
    @Stateless(name="A")
    @Remote({A.class})
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public class AImpl implements A {
    @Override
    public void writeA() {
    System.out.println("A");
    @Override
    public void writeB() {
    System.out.println("B");
    @Override
    public void writeC() {
    System.out.println("C");
    @Remote
    @JNDIName(A.JNDI_NAME)
    public interface A extends B, C {
    public static String JNDI_NAME = "A_JNDI_NAME";
    void writeA();
    void writeB();
    void writeC();
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Wonders Are Here)

  • Doubt on Multiple Inheritance

    Hi all,
    I am confused by the java statement that "By using interface we can achieve multiple inheritance bcoz java doesn't support Multiple inheritance".
    Yes.Ok java doent support Multiple inheritance. Now we know that inheritance means that "one object acquires the property of another object".
    So how can it is possible achieve Multiple inheritance by interface.
    Interface that contains just undefined methods like below code.
    interface Member1
         public void eye();
         public void nose();
         public void mouth();
    interface Member2 extends member1
         public void neck();
         public void hand();
         public void stomach();
    interface Member3 extends Member1,Member2
         public void leg();
    class Man implements Member3
         public man()
         Member3 ref=new Man();
         // Here Implements all 7 methods.
    Is the above code defines multiple Inheitance?
    undefined methods are eye,nose,mouth,neck,handand stomach are fall in Interface Member3 .Yes. But Inheritance means that one object acquires the property of another object.Property means that code and data.
    In here, there is no code just declarations of method which is not to be a code .
    So How can we say interface achieve multiple inheritance.
    Please any one explain and clear my doubt with simple example.
    with cheers,
    G.GandhiRaj.

    Multiple inheritance is about aquiring both behavior and attributes from two or more sources. A lot of times, this "is a" relationship is confused with "has a" relationships.
    For example, a Book "has a" Page. A Book "is a" Publication. So multiple inheretance in this instance would come from stating that a Book "is a" Publication and "is a" PaperProduct. In this example, you could redesign your model and state that a PaperProduct inherits from Publication. However, a Book doesn't have to be limited to being a PaperProduct, it can also be an ElectronicProduct, thus inhereting attributes and behaviors from this new class as well. In essence, the Book can exist in two forms simulataneously (as many actually do). So you still have the need for multiple inheritance - perhaps.
    Interfaces define the behavioral aspects of multiple inheritance. You loose the aquisition of attributes from base classes. In many cases this is acceptable. For the first time I recently found a true need for multiple inheritance in one fo my Java apps. Some would say that my data model is poorly designed then. So I tried restructuring the model and that solve the problem.
    It is probably a good idea to completely understand your data model from many dimensions first before resorting to the copying of attributes like I almost did. Don't be locked into a design too quickly. Be willing to change your mind and you will probably find a solution that works.

  • Is there (REAL) multiple inheritance ?

    Hi brothers,
    how r u..
    let us discuss about one property of java, what do you think ..
    The ability of multiple inheritance is one famous property of java, and that is done by interface, but I think that is not multiple inheritance really in contrast with C++ especially about inheriting of methods.
    If a class M implements interface I and class C, M or its subclasses must implement all methods of I, i.e., the bodies of those methods are made in in M class; then where is the multiple inheritance or even the linear inheritance?
    Is the multiple inheritance for methods prototypes only?
    I[b] suggest that you put those methods in M class directly instead than putting them indirectly.
    C++ provides real multiple inhritance for all members.
    May be if the interface contains constants, we can see multiple inheritance clearly, OR :
    in use APIs, but I dont have much experince in APIs?
    What do you think in what I said?

    Hi brothers,Hi :)
    how r u..fine thanks, and you?
    let us discuss about one property of java, what do
    you think ..I'll do my best :$
    If a class M implements interface I and class C, M or
    its subclasses must implement all methods of I, i.e.,
    the bodies of those methods are made in in M class;
    then where is the multiple inheritance or even the
    linear inheritance?
    Is the multiple inheritance for methods prototypes
    only?Inheritance is there to make your code more understandable I guess.
    An Interface is there to define what the object is about. Persoanally I always felt that true inheritance in java is done when using the 'extends' word rather then the 'implements' keyword. When extending a class you no longer have to declare that method in your class or subclass (unless it is an abstract class).
    I am not a genious in Java, however I always felt that an interface is there to specify the type of the object.
    I suggest that you put those methods in M class
    directly instead than putting them indirectly.But then your set of classes would not longer be understandable, and your objects can no longer have logical meaning. For example imagine haveing an class called 'John' I would never want to have all the methods and properties that describe 'John' to be lofically named only in 'John'! I would want an interface that describes to me that John needs to have two legs and two arms. An other interface that describes to me that John can walk, run, sit, etc, and another interface that tells me that John has a name, surname, id number and so on.
    C++ provides real multiple inhritance for all
    members.Then I guess C++ is the language for you ;)
    May be if the interface contains constants, we can
    see multiple inheritance clearly, OR :An interface can contain constants as much as I know!
    What do you think in what I said?was gona ask the same thing, but now I am afraid I wrote a bunch of sh*t :$ :(

  • How to go about multiple inclination with different data selection in Delta

    We have to copy large amount of data ( more than 42lak of recodes) selectivly from on ODS to other ODS. in delata load ( BW 3.5 enverioment)
    I thought of loading data in slices through delta loading with selection condition.
    step 1> Do The initialization with selection condition as for calyear =2001 ( Init without data transfer )
    step 2> Take the delta load .. it will take all delta record with same selection
    step 3> Now I want to do Initialization with selection condition as for calyear =2002
    step 4> take the delta now it will take delta for year 2001 and 2002 both Right ?
    Here what problem I am facing.. while doing 2nd time initialization it prompt me to delete the last  initialization request form scheduler menu.
    if i delete the last request .. will it take the delta  for previous initialization selection  and new initialization selection. ?
    Please advice how to go about multiple inclination with different data selection in delta loading.
    Looking forward your reply.

    Hi,
    step 1> Do The initialization with selection condition as for calyear =2001 ( Init without data transfer )
    step 2> Take the delta load .. it will take all delta record with same selection
    step 3> Now I want to do Initialization with selection condition as for calyear =2002
    step 4> take the delta now it will take delta for year 2001 and 2002 both Right ?
    You are correct with this scenario normally. The message you mentioned normally comes up when you open a infopackage and don't change the selection first or in case you have overlapping selections with an already done init.
    regards
    Siggi

  • More about  languages

    Hello there...
    As you all probably know it's possible to have multiple menu backgrounds, different button text, different subtitles and audio with dvd studio pro. BUT (yes.. there is one big but in all this) i have a problem when it comes to menus for diferent languagues.
    I know how to make a script to select an audio ou subtitle stream acording to user input (in a language menu).
    My question is: if dvd studio allows you to use diferent menu layouts for diferent project languages, why it doesn't lets you point a script to a specific menu language, "forcing" you to make 2 menus? I mean... the software will read the language value in the sprm, but if the dvd player language settings are different from the avaiable languages on your project? why there isn't a way to choose custum script no select the language instead of forcing it to only realy the sprm value?
    Or there's one, and it's me that need to learn a little more about dvdsp ?
    Can someone please help me with this?
    Thanks!

    The KOffice apps have quite some options for saving files. KWord can do it in MS Word, MS Write and RTF amongst others. The import filters may not be working all too well, have a look at the Supported File Formats. I can't really tell about the quality of those filter, because I for myself have to handle just PDF-files most of the time, and my former MS Word & MS Excel files are not that important (means I don't really care, if I have to make a fresh start with my docs when going with KOffice).

  • Want to know more about Java//???

    Conference and Workshop on Java Enterprise, Agile, JDK, Mobile, Spring, BPEL, EJB 3, Eclipse, Java EE, Cloud Computing and more..
    If you work on Java there�s no way you can afford to miss the Daring Java Conference @ Developer Summit 2008, being held May 22-23 in Bangalore. And there�s no reason to either. The first-of-its-kind conference offers the ultimate value of leading-edge skills and luminary speakers from the works over. From frameworks and middleware technologies to Open Source Java, Java Mobile, and real time technologies, you will come back to work more productive and valuable to your company. So if you�re keen on taking your knowledge and your capabilities beyond mere industry standards, you know where you need to be!
    To know more about the benefits and the registration procedure visit the summit on the Web *http://developersummit.com/conference.html#jav [http://developersummit.com/conference.html#java] a*.
    On May 23 2008, Java technology transitions into teenage years. Celebrate this achievement at the �Java Teenage Party� on the evening May 23, which will conclude the Daring Java conference.
    You will not find talks of this caliber at other events. Some very good speakers are already lined up (*http://developersummit.com/speakers.htm [http://developersummit.com/speakers.html] l*)
    �     The Future of Enterprise Java by Jim Farley
    �     Building Java-based Cloud Architectures by Amazon's Jinesh Varia
    �     Using Persistent Java Objects in Multiple Tiers by Craig Russell
    �     Enterprise Mashups Using Java by Greg Murray
    �     Java Performance Tooling by Holly Cummins
    �     Beginning Drools - Rule Engines in Java by Brian Sam-Bodden
    �     Develop Secured Ajax Applications by Olivier Poupeney
    �     Leveraging Open Source in Java EE Projects by Peter Thomas
    �     Web Services Development in Java without JEE by Sanjaya Karunasena
    �     Ajax and Comet: Implementing the Real-Time Web by Alessandro Alinone
    �     EJB 3 Java Persistence API in Action by Deb Panda
    The workshops include:
    �     Workshop: Rich Internet Applications with Flex and Java
    �     Workshop: Master Class: The Elements of User Experience
    �     Workshop: SQL Server 2008 Deep Dive
    �     Workshop: Java Data Objects Tutorial
    �     Workshop: Wicket, Spring and Hibernate: Putting It all Together
    �     Workshop: Harnessing Domain-Specific Languages (DSLs)
    �     Workshop: Parachuting Into Brownfields
    �     Workshop: Acceptance Test-Driven Development
    You can register online: *http://developersummit.com/registration.htm [http://developersummit.com/registration.html] l*
    Thanks,
    #3/18, Corporation Buildiing, Residency Road, Bangalore - 560 025
    ph +91 80 4005 1000 Fax: +91 80 2221 0148 Email: *[email protected] [[email protected]] m*
    Conference venue: J N Tata Auditorium IIsc, Bangalore- 560025

    hi

  • Multiple inheritance in Java

    Why it is sometimes said that interfaces provide a form of multiple inheritance?
    Do you agree that interfaces can provide multiple inheritance? Explain.
    Some people say that Java does not support multiple inheritance, and others: a class can implement more than 1 interface. Isn't that multiple inheritance?
    Thanks

    >
    Some people say that Java does not support multiple
    inheritance, and others: a class can implement more
    than 1 interface. Isn't that multiple inheritance?Sort of, but you don't inherit any implementation from an interface.

  • No multiple inheritance in Java. Interfaces used.

    Hi,
    In java a class can extend only one class while the interface can extend any number of interfaces.
    Class extending only one class avoids multiple inheritance.
    Can you explain me the reason of avoiding this in classes and allowing interfaces to extend any number of interfaces ?

    Hi,
    In java a class can extend only one class while the
    interface can extend any number of interfaces.
    Class extending only one class avoids multiple
    inheritance.
    Can you explain me the reason of avoiding this in
    classes and allowing interfaces to extend any number
    of interfaces ?The real question is: do you have a need for multiple inheritance?
    If so, I would be glad to hear about this concrete problem.

Maybe you are looking for

  • Apps not on iTunes library but on iPhone 5S

    Note: when I first created this message a screwup on the keyboard posted the message before I had written more than two sentences.  I hope no one responded to my incomplete message. For some time now when I elect to install a new iOS release (not at

  • List partitioning multi-org tables

    Hi I am doing list partitioning on receivables multi-org tables on org_id column. Running into a performance problem with multi org views. The multi-org views for receivables tables are defined like below with a nvl condition on org_id (partitioned c

  • Sub Query Error When Passing Dynamic Parameter.

    Dear All, I need help for below query problem. I have try below query run no problem when pass a static Parameter into the query but it throw error once i have add in the dynamic parameter:- --Sales BatchNum Transaction SELECT T0.[ItemCode], T0.[Item

  • Hardware identification using Java-application

    Hi, please help me! I would like to get some hardware-specific information using a Java-application? Is it possible? Thanks everybody, dzsitter

  • Can someone explain to me what the Terminal does?

    Can someone explain to me what the Terminal application does? A good explanation would be greatly appreciated, thanks! NA