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

来源:互联网 发布:js控制标签隐藏 编辑:程序博客网 时间:2024/04/28 23:47


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 eachPerson may be a member of zero or moreTeams and that eachTeam must have at least onePerson as a member. This diagram goes on to indicate that eachTeam must have exactly onePerson as a captain and everyPerson may be the captain of zero or moreTeams. 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 theTeam, 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就不能表达这种情况.鉴于这种情况,你不得不写个约束来显示这位领导作为团队成员的一个子集,用一个约束连到两个关系中.还有一个约束就是领导必须成为成员至少满一年.

 

 

 
0 0
原创粉丝点击