Legacy Issue Number: 16240
Source: Brookhaven National Laboratory ( Nikolay Malitsky)
The current DynamicType API allows a type definition to be changed. Such a change can be ambiguous at best and dangerous at worst.
· Suppose that the type already types (DynamicData) objects. Should all of those objects refer to the old version of the type or the new version? If the new version, how shall we address the situation where the new type is inconsistent with the existing data contents?
· Suppose that the type has already been registered with some domain participant. Does the registered type name refer to the old version of the type or the new version? What shall be done about samples that may already have been published or received using the old version?
· Can DynamicTypeFactory cache and reuse identical types that are requested more than once? Ideally yes, but the ability to change a type makes the state management necessary to support this behavior very complicated.
It would be safer, clearer, and more efficient if DynamicType objects were immutable once created. That implies that either the factory must take sufficient inputs to fully create a type in one step, or we must employ a builder or similar pattern.
A builder pattern would give the application more flexibility in how to create new types. It would also nicely encompass the current load_type operations as well as hypothetical PSM-specific operations, such the creation of a DynamicType from a Java Class object.
Proposed Revised Text:
Reported: DDS-XTypes 1.0b2 — Wed, 4 May 2011 04:00 GMT
Disposition: Resolved — DDS-XTypes 1.0
Define a new class DynamicTypeBuilder as a copy of the current definition of DynamicType. Remove from DynamicType all operations that modify an object, and add to DynamicTypeBuilder an operation build that returns a corresponding (immutable) DynamicType.
Update the existing DynamicTypeFactory to create instances of DynamicTypeBuilder instead of DynamicType. Rename this class DynamicTypeBuilderFactory accordingly.
Replace the existing operation DynamicType::clone with a corresponding create operation in DynamicTypeBuilderFactory.
Updated: Fri, 6 Mar 2015 21:48 GMT