What UML

UML作为一种可视化的面向对象建模语言,用于描述系统的静态结构和动态行为。本文介绍了UML的基本构造块,包括事物、关系和图,并详细解释了关联、聚合、组合、依赖、泛化和实现等关键概念。
  • UML是一种可视化的面向对象建模语言。(不是一个程序设计语言,更不是一个形式化语言。)
  • UML描述了一个系统的静态结构和动态行为。
  • UML用图形方式表现典型的面向对象系统的整个结构。
  • UML从不同角度为系统建模,并形成系统的不同视图。这些图包括:类图(它以继承结构、关联、组成和聚集为特色)、时序图、协作图和状态图等。

UML基本构造块

1)事物:是对模型中最具有代表性的成分的抽象,包括(结构事物,行为事物,分组事物,注释事物)

2)关系:关系是把事物结合在一起,包括(泛化关系,实现关系,依赖关系,关联关系)

3)图: 图是聚集了相关的事物。

UML关系:

  1. 关联:关联可以使用单箭头表示单向关联,使用双箭头或不使用箭头表示双向关联,不建议使用双向关联。关联有两个端点,在每个端点可以有一个基数,表示这个关联的类可以有几个实例。
    1.1 聚合关系:是关联关系的一种,是一种强关联关系。聚合关系是整体和部分之间的关系。他体现的是整体与部分、拥有的关系,即has-a的关系,聚合关系是关联关系的一种,是强的关联关系;关联和聚合在语法上无法区分,必须考察具体的逻辑关系。
    1.2 组合关系:也是关联关系的一种,但他是比聚合关系更强的关系。要求聚合关系中代表整体的对象要负责代表个体的对象的整个生命周期。

  2. 依赖:一个类或者包依赖另一个类或者包。

  3. 泛化:即继承关系。是一种特殊/一般关系,特殊元素的对象可代替一般元素的对象。继承指的是一个类(称为子类、子接口)继承另外的一个类(称为父类、父接口)的功能,并可以增加它自己的新功能的能力,继承是类与类或者接口与接口之间最常见的关系之一;通过关键字extends明确标识。

  4. 实现:一个类实现了一个接口。通过关键字implements明确标识。

UML九种图:

这里写图片描述

### UML Duration Message Usage and Examples In the context of Unified Modeling Language (UML), duration messages are used to represent time intervals during which certain conditions hold or actions occur. These elements provide valuable information about timing constraints within sequence diagrams. #### Definition and Purpose A **duration message** is depicted as a dashed line with two endpoints labeled by expressions indicating start and end times. This graphical notation helps modelers specify how long particular interactions should last, ensuring precise temporal relationships between objects involved in communication scenarios[^1]. For instance: ```plaintext [time-expression] / [event] ``` Where `time-expression` defines when this interval begins relative to other events on the timeline; while `/ event` marks its conclusion point where another significant occurrence takes place. #### Example Scenario Consider an online shopping system wherein after placing an order, customers receive confirmation emails immediately followed by shipping notifications once items leave warehouses. To illustrate such behavior using UML's syntax for expressing durations one might write: ```plaintext orderPlaced : Order -> Customer <<create>> : ConfirmationEmail; {start} / sendConfirmationEmail(); [start+5min] / shipItems(); // Assuming it always ships exactly five minutes later. ``` Here `{start}` represents the moment at which sending starts whereas `[start+5min]` indicates precisely 300 seconds afterward – just enough delay before dispatching goods outwards according to business rules set forth by logistics departments. This approach not only clarifies expected sequences but also enforces adherence through automated checks against actual runtime data captured via profiling tools like JProfiler mentioned earlier. Such practices contribute significantly towards optimizing application performance under varying load conditions without compromising user experience quality standards established beforehand. --related questions-- 1. How can we apply similar concepts found in n-ary associations into designing more complex systems? 2. What role does micro-architecture play in enhancing modularity across different domains? 3. Are there any best practices recommended when implementing these features specifically inside enterprise-level projects?
评论 39
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值