Hi there,
I have the following "software reality in working code" (also no access to it):
There is a class Class1 with different attributes
AttributeA - sums up all "ordinary attributes"
EnumType
DataType
AttributeValue
It is realized that there are some objects John... of type Class1, so they all have these 4 attributes. They can be set via GUI. The tricky part is: First EnumType has to be chosen. Depending on this choice the possible choices for DataType might be reduced. And the "attribute type" of AttributeValue might differ:
EnumType = None => DataType: int | char && AttributeValue: Field
EnumType = List => DataType: int | char | double | String && Value: []-Array
EnumType = Diction => DataType: int | char | double | String | XML && Value: DictCollection
That means:
If "None" than Value is only a single "field" of some possible data types.
If "List" than Value is like an []-Array where there is a long list of storable entries, it is gui chosen which data type this instantiation gets (and than all entries have same), possible data types are a bit more than "None".
If "Diction" than Value is like a collection of attribute pairs, it is gui chosen which data type this instantiation gets (and than each pair has the same combination), possible data types are more than "List".
Example:
JohnA: None=>Field | => char ='a' | AttributeA
JohnB: None=>Field | => int = 23 | AttributeA
JohnC: List=>[]Array | => String =["hello","world","list"] | AttributeA
JohnD: Diction=>DictCollection | => {XML, double} = {(<length>, 2.34); (<width>, 5.43)} | AttributeA
How to model Class1 in UML class diagram?Additional info: this Class1 also needs to be used in another class as data type of attributes over there as well - just in case that is relevant to ensure that while using it as data type the class structure and inner dependencies are coming into affect.
I read a bit and got some hints, I just don't understand them fully:
- when (not) to use a "refine"?
- when (not) to use a "derive"?
I understood, that a "refine" is useful in specialization where the subclass attribute has same name and different data type.
I understood, that a "derive" is useful in case an attribute depends on e.g. values of another like it gets calculated (calc "age" from "birthday" and "today").
I understood that a "readonly" is useful e.g. in a specialization in combination with a default value when this default is the only one possible for this subclass. (despite "query" which just describes that the attribute has no changing effect to this class).
The hints are summarized in this approach:

As you might see,
- the Class1 became abstract
- there are three specializations for each EnumType
- ClassDiction has no "redefines Value" (due to my lack of understanding)
- DictCollection is shown as separate class as pair of key, counterkey
- the enums for data types got specializations the way down
I have the feeling that "Value" needs two attributes: one aspect is: it defines the structure, second aspect is: it defines the data type inside the structure.
Or is this stored in "DataType" because this attribute is there to determine the data type of "Value" - and then it needs somehow an information to store this piece for just 'Field' / '[]-Array' or more data types for DictCollection as well?
Thank you very much for clarification, Shegit