Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-pcd!hplsla!jima From: jima@hplsla.HP.COM (Jim Adcock) Newsgroups: comp.lang.c++ Subject: Re: Objective C: Flame Fodder Message-ID: <6590115@hplsla.HP.COM> Date: 5 May 89 18:13:10 GMT References: <5007@tekgvs.LABS.TEK.COM> Organization: HP Lake Stevens, WA Lines: 41 > Programmer A is building a MailBox class, which must be able to > mail any kind of office object (whether existing now or in the future). > He chooses to have MailBox inherit functionality from Collection, which > inherits from Object. > > Programmer B is building an Envelope class, which like MailBox must > be able to contain any number of any kind of office Form. He chooses > to have Envelope inherit collection functionality from Collection. > > Programmer C is building a family of Form classes. For his own good > and sufficient reasons, he chooses not to inherit functionality from > Collection, but instead defiles an abstract Form class with separate > subclasses for Memo, BusinessLetter, etc. In any language, for a given business class to be mailed, that class must meet the expectations of the MailBox class. Presumably the MailBox class needs to know about the size of an object to be mailed, its class, a way to turn that object into a mailable form -- such as machine independent ascii representations etc. In any langauge, if the needs of the MailBox are not met, the program will bomb, either at compile time, or (god forbid) while a customer is running the program. One way to have the needs of the MailBox met are for the writer of the MailBox to write a set of specification of the functionality an object needs in order to mailable. Certainly, if the object's class is already written, it is unlikely to meet the needs of a MailBox written later. So the class must be either rewritten or augmented. In any language, if a class happens [blind luck] to have the functionality MailBox needs -- then the job is done before it is started. One simple, clean way to solve this problem in C++ is to use multiple inheritence to add the functionality the MailBox needs, regardless of the class hierarchy that a class originally inherited from. Thus C++ allows people to create differing class hierarchies, with totally differing goals, philosophies, optimizations, and weaknesses; and to combine these strength and weaknesses at later times, resolving conflicts where they arise. Rather than pretending one person's class hierarchy is the solution to the whole world's problems.