UML的通用机制(三)



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 object’s
name.

In this figure, there is one class, named
Customer, together with three objects:
Jan(which is marked explicitly as being a
Customer
object), :Customer
(an anonymous
Customer object), and
Elyse
(which in its specification is marked as being a kind of
Customer
object, although it’s 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 interface’s 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 named
SpellingWizard.dll that provides (implements) two interfaces,
IUnknown and
ISpelling. 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的组件,它提供两个接口,IUnknown
和ISpelling. 还需要一个名为IDictionary的接口,这个接口必需由另一个组件提供.

在UML中几乎所有的构建模块都有接口和实现的区分.例如,有用例和实现这些用例的交互,也有操作和实现这些操作的方法.

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

UML的通用机制(三)

时间: 2024-12-21 08:55:38

UML的通用机制(三)的相关文章

UML基本架构建模--通用机制概述

 Common Mechanisms 通用机制 The UML is made simpler by the presence of four common mechanisms that apply throughout the language: specifications, adornments, common divisions, and extensibility mechanisms. This chapter explains the use of two of these

在UML系统开发中有三个主要的模型

http://www.cnblogs.com/Yogurshine/archive/2013/01/14/2859248.html 在UML系统开发中有三个主要的模型: 功能模型: 从用户的角度展示系统的功能,包括用例图.  对象模型: 采用对象,属性,操作,关联等概念展示系统的结构和基础,包括类图.对象图.包图.  动态模型: 展现系统的内部行为. 包括序列图,活动图,状态图. UML的重要内容可以由以下五种类图定义 用例图:从用户角度描述系统功能,并指各功能的操作者. 静态图:包括类图,包图

Thinking in UML 学习笔记(三)——UML核心视图之类图

类图的作用:用于展示系统中的类及其相互之间的关系. UML在解决面向对象的方法中对类理解为三个层次,分别是:概念层.说明层.实现层.在UML中,从开始的需求到最终设计类,类图也是围绕这三个层次的观点进行建模的. 一.概念层类图 在概念层上类图着重于对问题领域的概念化理解,而不是实现,因此类名称通常都是问题领域中实际事物的名称. 网上购物主要由商品.订单.支付卡这几个关键类构成,这几个类的交互能够完成网上购物这个业务目标. 二.说明层类图 这一层是类的接口而不是实现,类图中表达类和类之间的交互接口

C++实现委托机制(三)——lambda表达式封装

C++实现委托机制(三)——lambda表达式封装1.引言:              其实原本没打算写这一章的,不过最后想了想,嗯还是把lambda表达式也一并封装进去,让这个委托也适应lambda表达式的注册.不过在之前还是需要先了解lambda表达式. 2.lambda表达式:              如果大家还有对lambda表达式不了解的可以先去了解lambda表达式的基本语法和用法.这里我们只讲跟lambda表达式封装相关的知识.我们先来看看使用lambda表达式的好处吧:1.la

UML基本架构建模--通用机制的通用建模技术(三)

 Modeling New Semantics 新语义建模 When you create a model using UML, you work within the rules the UML lays down. That's a good thing, because it means that you can communicate your intent without ambiguity to anyone else who knows how to read the UML.

UML基本架构建模--通用机制的术语和概念(三

 Stereotypes 模式化 The UML provides a language for structural things, behavioral things, grouping things, and notational things. These four basic kinds of things address the overwhelming majority of the systems you'll need to model. However, sometime

UML基本架构建模--通用机制的术语和概念(四)

 Constraints 约束 Everything in the UML has its own semantics. Generalization (usually, if you know what's good for you) implies the LisKov substitution principle, and multiple associations connected to one class denote distinct relationships. With c

UML基本架构建模--通用机制的通用建模技术(二)

 Modeling New Properties 新特性建模 The basic properties of the UML's building blocks-----attributes and operations for classes, the contents of packages, and so on----are generic enough to address most of the things you'll want to model. However, if yo

UML基本架构建模--获得通用机制

 Sometimes you just have to color outside the lines. For example, at a job site, an architect might scribble a few notes on the building's blueprints to communicate a subtle detail to the construction workers. In a recording studio, a composer migh