标签:
Stereotypes
模式化
The UML provides a language for structural things, behavioral things, grouping things, and notational things. These four basic kinds of things address the overwhelming majority of the systems you’ll need to model. However, sometimes you’ll want to introduce new things that speak the vocabulary of your domain and look like primitive building blocks.
UML为结构事物﹑行为事物﹑群组事物和注释事物提供了一门语言.这四个基本事物类型处理你所需建模系统的绝大多数.然而,有时你会想为了说自己领域的词汇而引进新事物,让其看起来象是初始的构建块.
A stereotype is not the same as a parent class in a parent/child generalization relationship. Rather, you can think of a stereotype as a metatype (a type that defines other types), because each one creates the equivalent of a new class in the UML’s metamodel. For example, if you are modeling a business process, you’ll want to introduce things like workers, documents, and policies. Similarly, if you are following a development process, such as the Rational Unified Process, you’ll want to model using boundary, control, and entity classes. This is where the real value of stereotypes comes in. When you stereotype an element such as a node or a class, you are in effect extending the UML by creating a new building block just like an existing one but with its own special modeling properties (each stereotype may provide its own set of tagged values), semantics (each stereotype may provide its own constraints), and notation (each stereotype may provide its own icon).
在父类/子类泛化关系中,模式化与父类是不一样的.相反,你可以将模式化想象成一个元类型(定义其它类型的类型),因为每个创建等价于在UML的元模型中的新类.举例来说,如果你正在建模一个商业过程,想要引进象工作﹑文档和政策这类事物;如果你正在跟踪一个开发过程,如合理的统一过程,想利用边界类﹑控制类和实体类建模.这是模式化的真正价值所在.当你为节点或类这样的元件模式化时,你实际上是在通过创建象已存在的元件一样的新构建块来扩展UML,与现有的元件不同的是,新构建块拥有它自己的特定建模属性(每个模式化可能提供有自己的一组标签值),语义(每个模式化可能提供有自己的约束)及标记(每个模式化可能提供有自己的图标).
In its simplest form, a stereotype is rendered as a name enclosed by guillemets (for example, ?name? ) and placed above the name of another element. As a visual cue, you may define an icon for the stereotype and render that icon to the right of the name (if you are using the basic notation for the element) or use that icon as the basic symbol for the stereotyped item. All three of these approaches are illustrated in Figure 6-5.
在它的最简单的形式里,一个模式化被表现为由尖括号包含起来的一个名称(如,《名称》),被置于另一个元件名称之上.作为图形标识(如图6-5 a),你可能为模式化定义一个图标,放在那个代表元件名称的右边(如果你为这元件使用了基本的标记,如图6-5 b)或是使用那个图标作为模式化项目的基本符号(如图6-5 c).
Note: When you define an icon for a stereotype, consider using color as an accent to provide a subtle visual cue (but use color sparingly). The UML lets you use any shape for such icons, and if your implementation permits it, these icons might appear as primitive tools so that users who create UML diagrams will have a palette of things that look basic to them and speak the vocabulary of their domain.
备注:当你为一个模式定义图标时,可以考虑为不是很明显的图形标识使用颜色来标注重点(但要尽量地少用颜色).UML允许你为这类的图标使用任何形状,并且如果你的实现允许的话,这些图标可以以原始工具出现,以便创建UML图的用户有一个基本事物的面板和使用他们领域的词汇表.
Tagged Values
标签值
Every thing in the UML has its own set of properties: classes have names, attributes, and operations; associations have names and two or more ends, each with its own properties; and so on. With stereotypes, you can add new things to the UML; with tagged values, you can add new properties to a stereotype.
在UML中每个事物都有它自己的属性集:类有名称,属性和操作;关联有名称和两个或更多个终端,每个终端又有自己的属性等等.用模式化,你可以加新的事物到UML中;而用标签值,你可以加新的属性到一个模式化中.
You define tags that apply to individual stereotypes so that everything with that stereotype has that tagged value. A tagged value is not the same as a class attribute. Rather, you can think of a tagged value as meta-data because its value applies to the element specification, not to its instances. For example, as Figure 6-6 shows, you can specify the required capacity of a server class or require that only one kind of server be used in a given system.
你定义的标签是应用到个人的模式化中,以便每个带有模式化的事物拥有标签值.一个标签值与一个类的属性并不一样.相反,你可以把标签值想像成元数据,因为它的值是应用到元件的描述中,而不是它的实例.如图6-6显示的.你可以描述一个服务类的容量需求或仅仅是服务中的一种被使用于一个给定系统中的需求.
Tagged values are placed in a note attached to the affected element, as shown in Figure 6-7. Each tagged value comprises a string that includes a name (the tag), a separator (the symbol =), and a value(of the tag).
标签值被放在备注里,而备注是附属于它所影响的元件上.如图6-7所示.每个标签值组成一个字符串,这个字符串包含一个名称(标签),一个分隔符(符号=)和一个值(标签的).
Note: One of the most common uses of tagged values is to specify properties that are relevant to code generation or configuration management. For example, you can use tagged values to specify the programming language to which you map a particular class. Similarly, you can use tagged values to specify the author and version of a component.
备注:一个标签值最常见的用途是指定有关代码生成的属性或是配置管理.例如,你能使用标签值指定编程语言绘制一个特定的类.同样你能使用标签值指定组件的作者和版本号.
标签:
原文地址:http://blog.csdn.net/listen_snow/article/details/44077473