当前位置:网站首页>UML 状态图
UML 状态图
2022-07-07 12:12:00 【sinat_36789271】
一、状态图
类定义的是一组对象的抽象,而每个对象时类的一个实例,但对于一个对象而言,它在其整个生命周期中有一系列的状态。状态描绘了对象的动态生命周期。
“人” 就是一个类,而“你”、“我”、“张三” 等都是“人”这个类的一个实例,“站着”、“躺着”等都是对象的一个状态。
在对象的整个生命周期中,它的状态是会发生变化的,而状态机就是用来表示一个对象在它的生命周期中响应的时间所发生的状态变化以及对事件的响应。
二、组成元素、状态机
状态机是一个对象的局部视图、一个将对象与其外部世界分离开来并独立考查其行为的视图。状态机是精确描述行为的一种好办法。
如描述烧水器在工作时的详细行为细节:
状态:是指在对象生命周期中满足某些条件、执行某些活动或等待某些事件的一个条件和状况。
开始状态
结束状态
命名状态
在一张状态机图中,最为核心的元素无外乎有两个:一个是用圆角矩形表示的状态;另一个是在状态之间、包含一些文字描述的有向箭头线,这些箭头成为转换。
一个转换是两个状态之间的一种关系,表示对象将在第一个状态中执行一定的动作,并在某个特定事件发生时且满足条件时进入第二个状态。
三、如何绘制状态图
绘制状态图的理想步骤:寻找主要的状态、确定状态之间的转换,细化状态内的活动与转换,用复合状态来展开细节
1、寻扎主要状态
在绘制状态机图时,最重要的一个活动就是寻找出主要的状态。对于航班机票预订系统而言,显然包括的状态主要有:
a、在确定飞行计划时,显然是没有任何预订的,并且在有人预订机票之前都将处于这种“无预订”状态
b、对于订座而言,显然有“部分预订”和“预定完”两种状态
c、当航班快要起飞时,显然要“预订关闭”
总结:有四种状态:无预定、部分预订、预定完和预订关闭
2、确定状态之间的关系
确定主状态之后分析状态之间的转换,画出相应的状态机图
边栏推荐
- 566. Reshaping the matrix
- Supply chain supply and demand estimation - [time series]
- Excusez - moi, l'exécution a été réussie lors de l'utilisation des données de puits SQL Flink à Kafka, mais il n'y a pas de nombre dans Kafka
- Es log error appreciation -limit of total fields
- postgresql array类型,每一项拼接
- Learning breakout 2 - about effective learning methods
- Is it safe to open an account online now? Which securities company should I choose to open an account online?
- PHP中用下划线开头的变量含义
- Help tenants
- IP and long integer interchange
猜你喜欢
2022-7-6 使用SIGURG来接受外带数据,不知道为什么打印不出来
一个简单LEGv8处理器的Verilog实现【四】【单周期实现基础知识及模块设计讲解】
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
Parsing of XML files
Redis can only cache? Too out!
Dry goods | summarize the linkage use of those vulnerability tools
最长上升子序列模型 AcWing 482. 合唱队形
高等數學---第八章多元函數微分學1
2022-7-6 Leetcode27. Remove the element - I haven't done the problem for a long time. It's such an embarrassing day for double pointers
随机推荐
Laravel5 call to undefined function OpenSSL cipher IV length() error php7 failed to open OpenSSL extension
XML文件的解析操作
Parameter keywords final, flags, internal, mapping keywords internal
Take you to master the three-tier architecture (recommended Collection)
How to check the ram and ROM usage of MCU through Keil
PC端页面如何调用QQ进行在线聊天?
Use day JS let time (displayed as minutes, hours, days, months, and so on)
[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?
Laravel Form-builder使用
Environment configuration of lavarel env
供应链供需预估-[时间序列]
干货|总结那些漏洞工具的联动使用
How does MySQL control the number of replace?
566. 重塑矩阵
What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
IP and long integer interchange
2022-7-7 Leetcode 844. Compare strings with backspace
Toraw and markraw
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis