码迷,mamicode.com
首页 > 其他好文 > 详细

UML基本架构建模--关联的术语和概念(一)

时间:2015-01-13 07:55:07      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:



A relationship is a connection among things. In object-oriented modeling, the three most important relationships are dependencies, generalizations, and associations. Graphically, a relationship is rendered as a path, with different kinds of lines used to distinguish the kinds of relationships.

关联是事物之间的联系.在面向对象建模中,三个最重要的关联依次是依赖,泛化和联合.图形表现上,关联被显示为一条路径,使用不同的线条来区分关联的类别.

 

Dependencies

依赖

A dependency is a relationship that states that one thing ( for example, class Window ) uses the information and services of another thing ( for example, class Event ), but not necessarily the reverse. Graphically, a dependency is rendered as a dashed directed line, directed to the thing being depended on. Choose dependencies when you want to show one thing using another.

依赖关联表明一个事物(如窗口类)使用另一个事物(如事件类)的信息和服务,反之则不然.图形表现上,依赖呈现为一条虚线指示线,箭头所指为被依赖的事物.在你想显示一个事物使用另一个事物的时候选择依赖关联.

 

Most often, you will use dependencies between classes to show that one class uses operations from another class or it uses variables or arguments typed by the other class; see Figure 5-2. This is very much a using relationship ---- if the used class changes, the operation of the other class may be affected as well, because the used class may now present a different interface or behavior. In the UML you can also create dependencies among many other things, especially notes and packages.

大多数情况下,你将使用类之间的依赖显示一个类使用来自另一个类的操作或是它使用的变量或是其它类的类型参数;如图5-2显示.这是非常有用的关联---如果被使用的类改变,可能会影响到其它类的操作,因为被使用的类现在呈现出的是不同的接口或行为.在UML中,你还可以创建其它许多事物间的依赖关系,尤其是备注和包.

技术分享

 

Note: A dependency can have a name, although names are rarely needed unless you have a model with many dependencies and you need to refer to or distinguish among dependencies. More commonly, you’ll use stereotypes to distinguish different flavors of dependencies.

备注:依赖可以有名称,尽管很少关联需要名称,除非你有一个模型有很多的依赖,而你需要指出或是区分它们.更多的时候,你使用模式化来区分不同的依赖关联的特点.

 

Generalizations

泛化

A generalization is a relationship between a general kind of thing ( called the superclass or parent ) and a more specific kind of thing ( called the subclass or child ). Generalization is sometimes called an is-a-kind-of relationship: one thing ( like the class BayWindow ) is-a-kind-of a more general thing (for example, the class Window ). An objects of the child class may be used for a variable or parameter typed by the parent, but not the reverse. In other words, generalization means that the child is substitutable for a declaration of the parent. A child inherits the properties of its parents, especially their attributes and operations. Often--but not always--the child has attributes and operations in addition to those found in its parents. An implementation of an operation in a child overrides an implementation of the same operation of the parent; this is known as polymorphism. To be the same, two operations must have the same signature ( same name and parameters ). Graphically, generalization is rendered as a solid directed line with a large unfilled triangular arrowhead, pointing to the parent, as shown in Figure 5-3. Use generalizations when you want to show parent/child relationships.

泛化是一种普遍的事物(被称为超类或是父节点)和一个更具体的事物(被称为子类或是子节点)之间的关系.泛化有时候被称为从属关系:一个事物(如中断窗口)从属于更普遍的事物(如窗口类).一个子类的对象可能使用来自父类的变量或参数类型,但是父类不能使用子类的变量或参数类型.换句话说,泛化的含义是子类替代了父类的声明.一个子类继承它父类的特性,尤其是它们的属性和操作.通常--但不总是--子类拥有除在父类中已存在之外的属性和操作.在子类中某个操作的实现会覆盖父类中同样的操作实现;这被称之为多态性.为了保持一致,两个操作必须有同样的标识(同样的名称和参数).图形表现上,泛化呈现为一条实线指示线,空心三角形箭头指向父类,如图5-3显示的.在你想显示父/子关系时使用泛化关联.

技术分享

 

A class may have zero, one, or more parents. A class that has no parents and one or more children is called a root class or a base class. A class that has no children is called a leaf class. A class that has exactly one parent is said to use single inheritance; a class with more than one parent is said to use multiple inheritance.

一个类可能没有,也可能有一个或多个父类.一个没有父类并且有一个或多个子类的类被称为根类或基类.没有子类的类被称为叶类.只有一个父类的类被称为使用单一继承.有多个父类的类被称为使用多重继承.

 

Most often, you will use generalizations among classes and interfaces to show inheritance relationships. In the UML, you can also create generalizations among other kinds of classifiers, such as nodes.

大多数情况下,你将会使用泛化来显示类之间的继承关系.在UML中,你还可以创建其它事物之间的泛化,如节点.

 

Note: A generalization with a name indicates a decomposition of the subclasses of a superclass on a particular aspect, called a generalization set. Multiple generalization sets are orthogonal; the superclass is intended to be specialized using multiple inheritance to select one subclass from each generalization set. This is an advanced topic that we do not cover in this book.

备注:带有名称的泛化表示一个子类分解于一个父类的一个特定方面,被称为泛化组.多个泛化组允许相交;这种超类是专门用于多重继承来从每个泛化组中选择一个子类.这是更深层的问题,不在本书范围之内.

 

UML基本架构建模--关联的术语和概念(一)

标签:

原文地址:http://blog.csdn.net/listen_snow/article/details/42671479

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!