UML基本架构建模--通用机制的术语和概念(四)

Constraints

约束

Everything in the UML has its own semantics. Generalization (usually, if you know what’s good for you) implies the LisKov substitution principle, and multiple associations connected to one class denote distinct relationships. With constraints, you can add new semantics or extend existing rules. A constraint specifies conditions that a run-time configuration must satisfy to conform to the model. For example, as Figure 6-8 shows, you might want to specify that, across a given association, communication is secure; a configuration that violates this constraint is inconsistent with the model. Similarly, you might want to specify that among a set of associations connected to a given class, a particular instance may have links of only one association in the set.

在UML中的每个事物都有它自己的语义.泛化(通常,如果你知道什么对你是好的)意味着里氏代换原则和多个关联连到一个类指示出不同的关系.用约束你可以增加新的语义或是扩展已存在的规则.约束所描述的条件是必须满足符合模型运行时的配置.举个例子,如图6-8所显示的,你也许想说明:在一个给定的关联中通信是安全的;一个配置违反了约束与模型的一致性.同样地,你也许想说明在一组连接到一个给定类的关系中,一个特定的实例是可能只有一个与组中的关联相联系.

Constraints may be written as free-form text. If you want to specify your semantics more precisely, you can use the UML’s Object Constraint Language (OCL), described further in The Unified Modeling Language Reference Manual.

A constraint is rendered as a string enclosed by brackets and placed near the associated element. This notation is also used as an adornment to the basic notation of an element to visualize parts of an element’s specification that have no graphical cue. For example, some properties of associations (order and changeability) are rendered using constraint notation.

 约束被表现为由一对大括号框起来的一个字符串,并被放置在相关的元件附近.这个标志也被作为修饰一个元素的基本符号,显示一个元素的说明书中没有图形表示的那部分.举个例子,一些关联的属性(顺序和可变性)使用约束标志来表现.

Standard Elements

标准元件

The UML defines a number of standard stereotypes for classifiers, components, relationships, and other modeling elements. There is one standard stereotype, mainly of interest to tool builders, that lets you model stereotypes themselves.

UML已为分类器,组件,关系和其它模型元素定义许多标准模式.这有一个标准模式,主要是工具建造者感兴趣,允许你为模式化自己建模.

Specifies that the classifier is a stereotype that may be applied to other elements.

l版式

You’ll use this stereotype when you want to explicitly model the stereotypes you

当你想为你的项目明确的建模你已定义的模式时,就可以使用这个版式.

Profiles

摘要

Often it is useful to define a version of UML tailored to a particular purpose or domain area. For example, if you want to use a UML model for code generation in a particular language, it is helpful to define stereotypes that can be applied to elements to give hints to the code generator (like an Ada pragma). The stereotypes you define would be different for Java and C++, however. As another example, you might want to use UML for modeling databases. Some of the UML capabilities, such as dynamic modeling, are less important, but you want to add concepts such as candidate keys and indexes. You can tailor UML using profiles.

因为一个特定的目的或是领域范围而调整UML,为这个调整过的UML定义一个版本是非常有用的.举个例子,如果你想使用UML模型的代码生成一个特定的语言,,定义版式是很有帮助的,它可以被应用于元素提示代码生成器(象Ada程序).你定义的这个版式对Java和C++是不同的.然而,做为另一个例子,你可能想使用UML为数据库建模.UML的一些功能,如动态建模,虽然不重要,但你会想加点如候选键和索引这样的概念.你可以使用摘要来调整UML.

A profileis a UML model with a set of predefined stereotypes, tagged values, constraints, and base classes. It also selects a subset of the UML element kinds for use so that a modeler is not confused by element kinds that are not needed for the particular application area. A profile defines, in effect, a specialized version of UML for a particular area. Because it is built on ordinary UML elements, it does not represent a new language, and it can be supported by ordinary UML tools.

那些曾经以为念念不忘的事情就在我们念念不忘的过程里,被我们遗忘了。

UML基本架构建模--通用机制的术语和概念(四)

相关文章:

你感兴趣的文章:

标签云: