UML基本架构建模--通用机制的通用建模技术(三)



Modeling New Semantics

新语义建模

 

When you create a model using UML, you work within the rules the UML lays down. Thats a good thing, because it means that you can communicate your intent without ambiguity to anyone else who knows how to read the UML. However, if you find yourself needing to express new semantics about which the UML is silent or that you need to modify the UMLs rules, then you need to write a constraint.

在你用UML创建模型的时候,你工作在UML的规则之下.这是一件好事,因为这意味着你可以与懂得如何读UML的人毫无障碍的表达你的意图.然而,如果你发现你需要表达的新的语义,UML却无法体现或是你需要修改UML的规则,这时你需要写一个约束.

 

To model new semantics,

lFirst, make sure theres not already a way to express what you want by using basic UML.

lIf youre convinced theres no other way to express these semantics, write your new semantics in a constraint placed near he element to which it refers. You can show a more explicit relationship by connecting a constraint to its elements using a dependency relationship.

lIf you need to specify your semantics more precisely and formally, write your new semantics using OCL.

 

 为新语义建模,

l首先,确保所使用的基本的UML没有已存在的方法表达你的想法.

l如果你确信没有其他的方式来表达这些语义,写下你的新的语义约束放置在它所引用的元素附近.你可以使用依赖关系将元素和它的约束连接起来,以显示更清楚的关系.

l如果你需要更精确地更正式地指定你的语义,使用对象约束语言来写你的新语义.

 

For example, Figure 6-11 models a small part of a corporate human resources system.

比如,如图6-11一个公司人力资源体系中的一小部分模型.

This diagram shows that each Person may be a member of zero or more Teams and that each Team must have at least one Person as a member. This diagram goes on to indicate that each Team must have exactly one Person as a captain and every Person may be the captain of zero or more Teams. All of these semantics can be expressed using simple UML. However, to assert that a captain must also be a member of the same team is something that cuts across multiple associations and cannot be expressed using simple UML. To state this invariant, you have to write a constraint that shows the manager as a subset of the members of the Team, connecting the two associations with a constraint. There is also a constraint that the captain must be a member for at least 1 year.

这个图显示每个可能成为零个或一个团队的成员,每个团队必须至少有一个作为成员.这张图还表明必须有一个作为领导的,每个都可能成为零个或多个团队的领导.所有这些语义都可以使用简单UML来表达.然而,想要说明一个领导必须也是同一个团队的成员,这会跨越多个关联,用简单UML就不能表达这种情况.鉴于这种情况,你不得不写个约束来显示这位领导作为团队成员的一个子集,用一个约束连到两个关系中.还有一个约束就是领导必须成为成员至少满一年.

 

 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值