09/04/2019
Hello,
I would like to know how to model the following architecture:
ListItemType (subtype of BaseObjectType)
ListType (subtype of BaseObjectType) -HasComponent-> <ListItem> (ListItemType; MandatoryPlaceholder)
When I have another type that uses the ListType as such:
AggregatingType (subtype of BaseObjectType) -HasComponent-> List (ListType; Optional)
Is the AggregatingType modelled correctly already, or does the MandatoryPlaceholder enforce an instance like this:
AggregatingType (subtype of BaseObjectType) -HasComponent-> List (ListType; Optional) -HasComponent-> ListItem (ListItemType)
For my understanding, the MandatoryPlaceholder shall not enforce the “ListItem” as in the second case, but please correct me if I’m wrong.
Thanks
05/30/2017
If you create an instance of a ListType in another type then that instance shall have one instance of ListItemType since every instances must honour the contract set by ListType.
If this does not make sense you need to use OptionalPlaceholder in ListType .
It is also not clear why you would would create generic List classes when the elements often need to be redefined with a subtype of ListItemType for each contained list (i.e. AggregatingListItemType). In this case you would add a second OptionalPlaceholder on the instance in AggregatingType. The interpretation of the API is both OptionalPlaceholder criteria need to be satisfied in instances of AggregatingType.
09/04/2019
Thanks for the quick reply. The type names are just illustrating the problem, the list is not supposed to be generic.
Let’s say, I remove the ListType and create the model like this:
ListItemType (subtype of BaseObjectType)
AggregatingType (subtype of BaseObjectType)
-HasComponent-> List (FolderType; Optional)
-HasComponent-> <ListItem> (ListItemType; MandatoryPlaceholder)
Then, an instance of the AggregatingType must only instantiate at least one ListItemType, if it also instantiates the List?
But I will probably just change to OptionalPlaceholder.
05/30/2017
Yes, every instance of AggregatingType would have to have at least 1 instance of ListItemType.
When designing a model with MandatoryPlaceholder it often makes sense to add a “Default” instance node into the type.
i.e.
“ListType”
+ “Default” (ListItemType, Mandatory)
+ “<ItemName>” (ListItemType, MandatoryPlaceholder)
This will ensure the minimum 1 instance is automatically created on instantiation and you do not need special logic.
If that design pattern does not make sense for you then OptionalPlaceholder may be a better fit.
1 Guest(s)