[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (OT) Re: memory management







>I don't know why, but the idea of a common superclass (like the Object
>class in Java) doesn't occur too much with C++ programmers... Ok, the
>native types can't be put in one, but that's life (and if they HAVE to,
>you can wrap them in objects).

It does, but mostly when one is looking to implement polymorphic persistence in
some way. The problem is that deep hierarchies of classes can get unmanageable
very easily, and this is complicated when they all have a common base class
(there is a word for it: homogenous?). Current OO design tends towards the
"forest" approach - a collection of related trees of objects rather than one big
tree.

{ The most easily recognisable problem is what happens if you change the
definition of Object... everything needs recompiling... }

I've tried it and honestly wouldn't recommend it. For one thing, a base object
heavyweight enough to support persistence and so on is probably overkill for the
kinds of lightweight objects you want to be throwing around inside the program
(bear in mind you're going to want to return things by value sometimes).

A carefully tended shrubbery of different classes seems to work much better in
the general case - trying to fit everything into one big inheritance tree is a
"one-size-fits-all" solution.