UML2.0中的Property和Attribute

仅仅描述原文,进行一定的翻译,细节再慢慢体会:

 

 

1. 元模型中Property的定义[1]:

 

A property is a typed element that represents an attribute of a class.

 

一个特性(property)是一个有类型的元素(typed element),它代表了一个类中的一个属性(Attribute


2. 元模型中:Core::Constructs::Class Diagram[2]

A property is a structural feature of a classifier that characterizes instances of the classifier. Constructs::Property merges the definition of Basic::Property with Constructs::StructuralFeature.

When a property is owned by a class it represents an attribute. In this case it relates an instance of the class to a value or set of values of the type of the attribute.

When a property is owned by an association it represents a non-navigable end of the association. In this case the type of the property is the type of the end of the association.

Property represents a declared state of one or more instances in terms of a named relationship to a value or values. When a property is an attribute of a classifier, the value or values are related to the instance of the classifier by being held in slots of the instance. When a property is an association end, the value or values are related to the instance or instances at the other end(s) of the association (see semantics of Association).

 

Property用来刻画这个类元classifier)实例的结构化特征。Constructs包中的PropertyConstructs::Property)结合了Basic::PropertyConstructs::StructuralFeature的定义。

property属于class时,它代表一个attribute。此时,它将一个class的实例和attribute类型的一个值或一组值关联起来。 

property属于连接(association)时,它表示连接的一个非导向端。此时,property的类型就是连接端的类型。

Property表示通过命名关系将一个或多个实例关联到一个值或多个值的声明状态。当Property为类元的属性(attribute)时,这个值或这些值通过正在槽(slot)中保持的实例联系到类元的实例。当property为连接端时,这个值或这些值关系到连接(association)的另一端的一个或多个实例。


3. Attribute的定义依然存在[3]

A structural feature of a classifier that characterizes instances of the classifier. An attribute relates an instance of a classifier to a value or values through a named relationship.

 

Attribute是刻画类元实例的结构化特征,一个Attribute通过一个命名关系将类元的实例联系到一个或多个值。

 

-------------------------------------------以下为其他参考--------------------------------------------

4. Note that an attribute typically corresponds to public properties in a language that supports properties but to private fields in a language that does not. In a language without properties, you may see the fields exposed through accessor (getting and setting) methods. A read-only attribute will have no setting method (with fields) or set action (for properties). Note that if you don't give a name for a property, it's common to use the name of the target class.[5]


注意:Attribute一般相当于支持properties的语言中的公有properties或不支持properties的语言中的私有字段(Field)。没有properties的编程语言中,需要通过存取器来访问字段,而只读attribute时没有存(set)方法和动作的。如果没有为property命名,它通常就是用目标类的名字。

 

[1].  UML 2.0 Infrastructure Final Adopted Specifcation03-09-15文档111

[2].  UML 2.0 Infrastructure Final Adopted Specifcation03-09-15文档123

[3].  UML 2.0 Infrastructure Final Adopted Specifcation03-09-15文档17

[4].  UML参考手册

[5] .   UML distilled

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值