Heterogenous collections 
Author Message
 Heterogenous collections

Quote:
>I'm curious -- how often are truly heterogeneous collections needed?

>Most of the time, when I'm writing a program, I want to know that a
>particular collection has only Shape objects.  I don't want to allow ints or
>strings into my Shape list.

I don't think one often wants TRULY heterogenous collections, but the
notion of "heterogenous" in C++ is limited by the rigid inheritance
mechanism and the (usual) inability to tweak externally-maintained code.
For example, you might have a collection of objects that all respond to a
particular method, but that can't share a common superclass.

As a case in point, in one drawing program I wrote, I wanted to put
instances of a preexisting view class together with instances of a "shape"
class in the same queue, and wanted them both to respond to the "drawSelf"
method. I didn't want the baggage of subclassing Shape from View, and I
couldn't get into the app framework to add a superclass to View that it
could share with Shape. Fortunately, I was working in Objective-C, so I
could use a heterogenous list, and the problem was solved.

If I were working in C++, even though I could have arranged the inheritance
hierarchy as I wished if I had written the app framework myself, my
inability to control the inheritance hierarchy in the existing code would
have left me in a tough spot.

The workaround in C++ would have been to make wrappers for the heterogenous

would have taken three different classes, just to make wrappers! This is an
example of why it's so hard to make reusable C++ software components.

-Anthony



Fri, 11 Sep 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Strong type checking + Heterogenous con

2. Distributed programming in heterogenous platforms

3. heterogenous system with glade

4. Heterogenous file IO in Ada83

5. RM A.12.1 Heterogenous I/O

6. How to construct a heterogenous list?

7. Vstruct module: unpack heterogenous, variable-length binary data

8. Collection of collections, how to collect?

9. collection inside a collection: how to selectively collect?

10. VAST: BIG collection

11. extracting sql query result from ordered collection

12. Creating collections - dynamic list operator {...}

 

 
Powered by phpBB® Forum Software