首页 > 技术文章 > UML基本架构建模--类的术语和概念

xfgnongmin 2019-04-09 18:51 原文



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.

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

 

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 classs 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.

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

 

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 Javasawt 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 objects 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.

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

 

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显示的.

 

推荐阅读