您的位置:首页 > 运维架构 > 网站架构

UML基本架构建模--类的术语和概念

2014-06-19 12:04 579 查看


Terms and Concepts

术语和概念

A classis a description of a
set of objects that share the same attributes, operations, relationships, and semantics. Graphically, a class is rendered as a rectangle.

一个类描述一组对象,这组对象共享相同的属性,操作,关系和语义.图形上,一个类被表达为一个矩形.

Names

名称

Every class must have a name that distinguishes it from other classes. Aname
is a textual string. That name alone is known as a simple name;
aqualifiednameis
the class name prefixed by the name of the package in which that class lives. A class may be drawn showing only its name, as Figure 4-2 shows.

每个类必须有一个名称以区别于其它的灯.一个名称是一个文本字符串.这个名称被称为一个简单的名称;一个合格的名称是带有这个名称所在包的前缀的名称.一个类可能只画出它的名称,就像图4-2显示的.



Note:A class name may be text consisting of any number of letters, numbers, and certain punctuation
marks (except for marks such as the double colon, which is used to separate a class name and the name of its enclosing package) and may continue over several lines. In practice, class names are short nouns or noun phrases drawn from the vocabulary of the system
you are modeling. Typically, you capitalize the first letter of every word in a class name, as inCustomer
orTemperatureSentor.

备注:一个类名可以是由任意个字母,数字和某些标点符号组成(除了双冒号,它通常用来分隔类名和封装此类名的包)的文本,类名也可能超过多行.在实际中,类名通常来自你正在建模的系统的词汇表中的短名词或名词短语.通常类名的每个单词的首字母需大写,如Customer或TemperatureSentor.

Attributes

属性

Anattribute
is a named property of a class that describes a range of values that instances of the property may hold. A class may have any number of attributes or no attributes at all. An attribute represents some property of the thing you are modeling that is shared by
all objects of that class. For example, every wall has a height, width, and thickness; you might model your customers in such a way that each has a name, address, phone number, and date of birth. An attribute is therefore an abstraction of the kind of data
or state an object of the class might encompass. At a given moment, an object of a class will have specific values for every one of its class’s
attributes. Graphically, attributes are listed in a compartment just below the class name. Attributes may be drawn showing only their name, as shown in Figure 4-3.

一个属性确定一个类的特性,用来描述特性实例值的范围.一个类可能有多个属性也可能根本没有属性.一个属性表示的是你正在构建的类的所有对象共享的那些特性.例如,每面墙有高度,宽度和厚度;你也许在以这样一种方式构建你的客户模型:每个客户有一个名字,地址,电话号码和出生日期.一个属性是数据类型的抽象或是这个类的对象所包含的状态.在给定的时刻,一个类的一个对象将为它的每一个类属性设定特定的值.图形表现上,属性被列在类名称下的分隔栏内.属性可以只显示它们的名称,如图4-3显示的那样.



Note:An attribute name may be text, just like a class name. In practice, an attribute name is
a short noun or noun phrase that represents some property of its enclosing class. Typically, you capitalize the first letter of every word in an attributes name except the first letter, as inname
orloadBearing.

备注:一个属性的名称就象类名一样可以是文本.在实际中,一个属性的名称是短名词或名词短语,代表封装它的类的一些性质.通常属性名称除了第一个单词外的其它单词的首字母需大写,如name或loadBearing.

You can further specify an attribute by stating its class and possibly a default initial value, as shown Figure 4-4.

你可以通过类的状态和默认初始值来进一步说明属性,就如图4-4显示的.



Operations

操作

Anoperationis
the implementation of a service that can be requested from any object of the class to affect behavior. In other words, an operation is an abstraction of something you can do to an object that is shared by all objects of that class. A class may have any number
of operations or no operations at all. For example, in a windowing library such as the one found in Java’sawt
package, all objects of the classRectangle can
be moved, resized, or queried for their properties. Often (but not always), invoking an operation on an object changes the object’s
data or state. Graphically, operations are listed in a compartment just below the class attributes. Operations may be drawn showing only their names, as in Figure 4-5.

一个操作是一种服务,可以实现来自这个类的任何对象请求,以影响其行为.另一方面,一个操作是你对一个对象的动作被该类的所有对象所共享的抽象行为.一个类可以拥有任何数量的操作,也可以根本没有操作.举个例子,在窗口库中,如在Java
AWT包中找到的,类Rectangle的所有对象都可以被移动,可调整大小,或者查找它们的属性.通常(但不总是)在一个对象上调用一个操作改变这个对象的数据或是状态.图形表示上,操作被列在类属性下的分隔栏内.操作可以只显示它们的名称,如图4-5显示的.



Note:An operation name may be text, just like a class name. In practice, An operation name is
a short verb or verb phrase that represents some behavior of its enclosing class. Typically, you capitalize the first letter of every word in an operation name except the first letter, as inmove
orisEmpty.

备注:一个操作的名称就象类名一样可以是文本.在实际中,一个操作的名称是简单动词或动词短语,代表封装它的类的一些行为.通常操作名称除了第一个单词外的其它单词的首字母需大写,如move或isEmpty.

You can specify an operation by stating its signature, which includes the name, type, and default value of all parameters and (in the case of functions) a return type, as shown
in Figure 4-6.

你可以通过描述它标签说明一个操作,标签包括名称,类型,所有参数的默认值和(在函数的情况下)返回类型,象图4-6显示的.



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: