home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!hagbard!loglule!jbn
- From: jbn@lulea.trab.se (Johan Bengtsson)
- Newsgroups: comp.lang.c++
- Subject: Re: Should I use a generic object which all others inherit from
- Message-ID: <5232@holden.lulea.trab.se>
- Date: 18 Nov 92 12:41:12 GMT
- References: <1992Nov17.190821.18348@informix.com>
- Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
- Lines: 46
- X-Newsreader: Tin 1.1 PL4
-
- cshaver@informix.com (Craig Shaver) writes:
- : In article <3762@news.cerf.net> hlf@nic.cerf.net (Howard Ferguson) writes:
- : >I am working on the early stages of design on an embedded C++
- : >project. One of the decisions which we will have to make in the
- : >near future is whether to make all of the objects inherit from
- : >onie generic object at the top of the tree or to go for the forest
- : >approach.
- : >
- :
- : An embedded system! C++!? JUST USE C!!!!
- :
- : UNLESS ....
- :
- : You have some of the benefits of OOP in mind, such as inheritance, reuse,
- : and information hiding. Then if you are willing to take small dings in
- : performance go all the way and use the tree approach as pioneered by
- : Smalltalk. I recently saw a review of the toy code that comes with the
- : borland compiler. The article's author commented that the tree type
- : libraries were "passe" because of templates. What a stupid thing to say!
- :
- : One of the big wins of OOP is reuse. By using an inheritance structure
- : you can reuse existing code and do incremental development. Related and
- : unrelated classes can be used in the same context where a similar protocol
- : is enforced.
-
- Perhaps you would then kindly enlighten the rest of us:
-
- If I go for the tree approach, with a base class MyObject inherited
- by all my classes, how am I going to reuse _your_ classes, which all
- inherit from class YourObject? Multiple inheritance? What
- if the protocol of my base class conflicts with your base class?
- How do I reuse tree-type libraries from several sources, each with
- it's own base class protocol?
-
- Enforcing a common protocol (by inheritance) for all your classes,
- _hampers_ reuse of your classes by anyone except yourself.
-
- Once a reference to an object has been passed as a generic
- object reference, for example into a collection, how do you (safely)
- call the actual methods of the objects (derived) class?
-
- --
- --------------------------------------------------------------------------
- | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden |
- | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490 |
- --------------------------------------------------------------------------
-