Designing an RWCollectable Class
Classes that derive from
RWCollectable give you much of the functionality of such Smalltalk namesakes as
Bag and
SortedCollection, along with some of the strengths and weaknesses of C++.
The two greatest advantages are that they can be used by the Smalltalk-like collections, which also derive from
RWCollectable, and that they are the only set of collection classes able to use the powerful polymorphic persistence machinery. Their biggest disadvantages are their relative lack of type-safety, and their relatively large object code size. Large code is typical even when these classes are used in only small doses because of their initially high overhead in code machinery.
Before we get to the nuts and bolts of
how to design an
RWCollectable class, let's discuss a concrete example of why you might choose to design
RWCollectable classes.