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

UML的通用机制(三)

时间:2017-08-19 13:00:01      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:ted   div   use case   new   dict   entity   面向对象   man   structure   



Common Divisions

In modeling object-oriented systems, the world often gets divided in several ways.

First, there is the division of class and object. A class is an abstraction; an object is one concrete manifestation of that abstraction. In the UML, you can model classes as well as objects, as shown in Figure 2-19. Graphically, the UML distinguishes an object by using the same symbol as its class and then simply underlying the objects name.

In this figure, there is one class, namedCustomer, together with three objects:Jan(which is marked explicitly as being aCustomerobject), :Customer(an anonymous Customer object), andElyse (which in its specification is marked as being a kind ofCustomerobject, although its not shown explicitly here).

技术分享

 

Almost every building block in the UML has this same kind of class/object dichotomy. For example, you can have use cases and use case executions, component and component instances, nodes and node instances, and so on.

Second, there is the separation of interface and implementation. An interface declares a contract, and an implementation represents one concrete realization of that contract, responsible for faithfully carrying out the interfaces complete semantics. In the UML, you can model both interfaces and their implementations, as shown in Figure2-20.

技术分享

In this figure, there is one component namedSpellingWizard.dll that provides (implements) two interfaces,IUnknown andISpelling. It also requires an interface,IDictionary, that must be provided by another component.

Almost every building block in the UML has this same kind of interface/implementation dichotomy. For example, you can have use cases and the collaborations that realize them, as well as operations and the methods that implement them.

Third, there is the separation of type and role. The type declares the class of an entity, such as an object, an attribute, or a parameter. A role describes the meaning of an entity within its context, such as a class, component, or collaboration. Any entity that forms part of the structure of another entity, such as an attribute, has both characteristics: It derives some of its meaning from its inherent type and some of its meaning from its role within its context(Figure 2-21).

技术分享

 

通用划分

在构建面向对象的系统时。往往被划分为几个方面.

首先,有类和对象的划分.一个类是一个抽象的概念。而一个对象是抽象的详细表现形式.在UML中,你能够与构建类一样的构建对象,如图2-19所看到的.图形表现上。对象的图形表示与它的类一样。差别在于对象的名称下多了一条下划线.

在这个图中,有一个名为客户的类,三个对象:简(它被明白的标识为客户对象):客户(一个匿名客户对象)。和依丽丝(虽然在这里没有明白的显示,但它的格式已经告诉了我们它是一个客户对象).

在UML中差点儿全部的构建模块都有类和对象的区分.比如,实用例和运行用例,组件和组件实例,节点和节点实例等等.

其次,还有接口和实现的分离.一个接口仅仅定义声明。而实现则表现这个声明的详细实现,它负责如实地运行这个接口完整的语义.在UML中,你能够构建接口和他们的实现,如图2-20所看到的.

在这个图中,有一个名为SpellingWizard.dll的组件。它提供两个接口。IUnknownISpelling. 还须要一个名为IDictionary接口,这个接口必需由还有一个组件提供.

在UML中差点儿全部的构建模块都有接口和实现的区分.比如,实用例和实现这些用例的交互,也有操作和实现这些操作的方法.

第三,类型和角色的区分.类型定义一个实体类。如一个对象,一个属性,或是一个參数.角色描写叙述一个实体在上下文中的含义,如一个类,组件,或是交互.那些组成还有一个实体的结构部分的实体。如属性,它们有两个特征:它来源于它内部的部分含义及角色所描写叙述的上下文中的部分含义.如图2-21所看到的.

UML的通用机制(三)

标签:ted   div   use case   new   dict   entity   面向对象   man   structure   

原文地址:http://www.cnblogs.com/slgkaifa/p/7395648.html

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