[Clam-devel] dynamic types

Greg Kellum greg.kellum at gmail.com
Mon Jul 16 03:20:11 PDT 2007


Hi,

I wanted to ask a general question about what benefits dynamic types
provide.  Um...  I can remember seeing an explanation somewhere in the CLAM
documentation where it said that dynamic types were used in CLAM to save
memory.  In some cases CLAM used objects where not all attributes were
needed, and dynamic types made it possible to instantiate only those
attributes one needs.  I could also imagine that dynamic types make the XML
serialization easier as they provide a reflection mechanism to see what
attributes an object has...  Are there any other benefits of using dynamic
types?

If these are the only benefits that dynamic types offer though, I'm
beginning to feel that the drawbacks outweigh the benefits.  The main
drawback I've seen being that dynamic types violate the principle of
encapsulation.  A client class never knows whether a dynamic type actually
has the attributes that it needs to work with, and it really shouldn't be
the responsibility of a client to make sure that the dynamic type has
allocated its members.  And I've seen some pretty bizarre behavior when
trying to allocate new attributes.  The Spectrum class has a strange bug for
instance where if one tries to add a magnitude and phase buffer some time
after an array of complex objects has already been created the array of
complex objects gets erased...  Furthermore, if you think about the benefits
I listed above, the first one has become less relevant as CLAM has moved
away from using Segment objects, and the second one -- the XML serialization
-- can be achieved nearly as easily by automatically generating
serialization classes from class definitions.

Any one have anything to say about this?

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20070716/88bf9f4d/attachment.html>


More information about the clam-devel mailing list