• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question


  • Subject: Re: Question
  • From: Greg Titus <email@hidden>
  • Date: Sun, 2 Dec 2001 20:58:09 -0800

On Sunday, December 2, 2001, at 06:43 PM, Eduardo I. Jiminez wrote:

Hi. I am not exactly an expert in Cocoa, but I am not a beginner.

Now, I'm trying to develop a very complex application. This application has a very complex design in terms of classes and relationships (about 150+ classes). Now, my basic problem is the following: this design has many classes with multiple inheritance. I've tried to think of ways of dealing with the problem, but I have not found an elegant solution. My last resort is developing the "model" part of my application in C++, which offers the features I need to implement this, and then using those C++ classes from the "Controller" in my Cocoa application. Could someone brief me in the complexities of doing this?. What kinds of problems can I run into.

Also, does anyone have an useful resource available about how to model multiple inheritance in non-multiple inheritance capable languages? I know there are many papers available, but some digested online resource (or advice) would be helpful.

You are asking the wrong question, I think - at least, it's the wrong question if you want a good answer. The way you are asking it you are almost guaranteed to get an unsatisfactory answer and to come away with the opinion that Objective-C and Java lacking multiple inheritance is a _bad_ thing. :-)

You don't really want to model multiple inheritance, per se, you want to model some specific kinds of relationships between your classes and you are used to using multiple inheritance in C++ to do so.

There are several different reasons why people generally end up using multiple inheritance in C++, and in the case of Cocoa they might map most suitably to one or more of: protocols, categories, composite objects, forwarding, et cetera. It really depends on the reason why you were doing it in the first place. It's very likely that there will be several different approaches for different parts of your object model that are the best fit instead of a single "do multiple inheritance this way".

I could go into a lot of detail about the different kinds... (One quick example: one use of MI in C++ is a base class with all virtual members and then many other classes inheriting from that class as a way to deal with many different types of otherwise unrelated objects that all implement the same set of methods. In Java you'd use an interface instead. In Objective-C you'd use either a formal or informal protocol - and which was best would depend on other things. That's the very easiest example because it's an area where I can point to a specific language feature which is a much better fit for the design pattern than MI.) But we'd quickly get bogged down in all the different ways to do things described in very general and nearly useless terms, and I'd still probably miss some of the patterns that end up being in your design.

If you are willing to go into some more detail about what your class design is trying to accomplish we (I) could probably be more helpful.

--Greg


  • Follow-Ups:
    • Re: Question
      • From: "Eduardo I. Jiménez" <email@hidden>
References: 
 >Question (From: "Eduardo I. Jiménez" <email@hidden>)

  • Prev by Date: Re: Target action isn't linking
  • Next by Date: Re: Storing NSString with attributes
  • Previous by thread: Question
  • Next by thread: Re: Question
  • Index(es):
    • Date
    • Thread