关于UML中ParameterSet所有者约束及参数类型的技术问询
UML ParameterSet 约束一致性问题
核心矛盾点
- UML规范第9.9.16节第190页的
ParameterSet描述及关联图显示,ParameterSet的所有者可以是BehavioralFeature或Behavior;但9.9.16.5节的约束仅针对BehavioralFeature编写,完全忽略了Behavior作为所有者的场景。 - 原约束示例(针对
input规则):
• input
If a parameterized entity has input Parameters that are in a ParameterSet, then any inputs that are not in a ParameterSet must be streaming. Same for output Parameters.inv: ((parameter->exists(direction = ParameterDirectionKind::_'in')) implies behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::_'in' and p.parameterSet->isEmpty())->forAll(isStream)) and ((parameter->exists(direction = ParameterDirectionKind::out)) implies behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::out and p.parameterSet->isEmpty())->forAll(isStream))
- 原约束还遗漏了
inout和return类型参数:目前没有明确规则禁止这类参数加入ParameterSet,但具体使用方式不明确。
适配双所有者的OCL实现尝试
基于Axel的评论,我尝试修改约束以同时支持BehavioralFeature和Behavior作为所有者,实现代码如下:
inv: if behavioralFeature <> null then ((parameter->exists(direction = ParameterDirectionKind::_'in')) implies behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::_'in' and p.parameterSet->isEmpty())->forAll(isStream)) and ((parameter->exists(direction = ParameterDirectionKind::out)) implies behavioralFeature.ownedParameter->select(p | p.direction = ParameterDirectionKind::out and p.parameterSet->isEmpty())->forAll(isStream)) else ((parameter->exists(direction = ParameterDirectionKind::_'in')) implies behavior.ownedParameter->select(p | p.direction = ParameterDirectionKind::_'in' and p.parameterSet->isEmpty())->forAll(isStream)) and ((parameter->exists(direction = ParameterDirectionKind::out)) implies behavior.ownedParameter->select(p | p.direction = ParameterDirectionKind::out and p.parameterSet->isEmpty())->forAll(isStream)) endif
请问这个实现是否符合UML的设计意图?
另外,我认为inout和return参数不应属于ParameterSet,理想情况下需要新增约束来限制允许加入ParameterSet的参数方向。
内容的提问来源于stack exchange,提问作者Robert Hairgrove
相关产品推荐
相关产品推荐

