STL question

Rob Wehrli rwehrli@azpower.com
Sat, 10 Mar 2001 21:33:38 -0700


Lucas Vogel wrote:
> 
> Thanks to Rob for the very well-detailed answer! I will definitely look into
> those references. I also don't think there's a need to apologize, since the
> plug-devel traffic is pretty miniscule - besides, (someone correct me if I'm
> wrong) this is the kind of topic this list was built for.
> 
> Thanks again!
> Lucas
> 

The one thing that I tend to find annoyance with when using the STL is
that for some <T> you must be completely homogeneous in order for the
"built-in" iterators to be useful...not that I'm an STL expert at
all...so if there is someone else with strong STL experience, please
feel free to dump any amount of light down this tunnel.  My uses for
objects in C++ are generally a couple of simple things:  I like to
manage collections of homogenenous that tend to act more as "data
wrapper" classes with the appropriate accessor/mutator and explicit
object interaction functionality--and in that management use iterators
for various work including sorting and searching collections for useful
bits of info--even to the point of building object collection indices;
and on the other side of the planet, I like to use "collections" of
heterogeneous objects as "transportable" storage mechanisms where I can
simply hand off the pointer to the collection to someone, ask that code
to do something with it, then, as is typical in my case, have that code
populate new objects into the collection as a result of its processing
and return to me.  I tend to write my own, fairly simply collection
objects which are little more than "dynamic" arrays of pointers to
objects that implement a common interface for auto alloc/dealloc.  This
enables me to stuff any kind of object's pointer into the array, but it
tends to require either the known "common" interface (it doesn't have to
be truly common, but that is a whole "nother" subject!) or a "mother of
all objects" class hierarchy, such as that used by Java and Objective C,
which comes with its own bag of tricks and follies.

I'd recommend reading up on interface inheritance and uses of it for
your code...and at the same time be sure to become versed in the use of
interface pointers.  I've yet to find a really good book on II (anyone
know of one?) but you can at least try Jeff Alger's "C++ for Real
Programmers," which is a retitled/revised edition of his earlier
book...my personal guaranty is that it will improve anyone's C++ code
(from beginner to beginning master!) while bringing all of the
"self-appointed C++ gurus" to their knees...or perhaps to their senses? 
Also, if you're really just getting started with C++, I'd strongly
recommend Stan Lippman's most excellent book "Essential C++."  The last
time I talked to Stan was at the C++ World Conference in Miami late
November, early December 1999.  While it was kinda fun rubbing elbows
with all of the greats in the C++ "World" ...I also learned first-hand
how much about C++ I didn't know then and still don't know now.  People
like Angelika Langer, Herb Schildt, Bob Martin, Kent Beck, Martin
Fowler, Elliot Koffman, Scott Meyers and Matt Austern...and so many more
were there that I suddenly reduced my level of knowledge in C++ from
"expert" to "infant" in one fell-swoop.  I've been trying to get another
C++ World conference going hosting it here in Phoenix...say October-ish?
...but it won't happen this year!  Maybe, if there is enough interest,
we can talk about organizing it for 2002...I'm sure that I'd love it. 
The last conference that I took part in organizing was in 1995, and I
can tell you that it is pure hell...but for 3 days of bliss during the
conference, it is definitely worth it!  October is a good time to be in
Phoenix!

Take Care.

Rob!