当前位置:网站首页>UML 状态图
UML 状态图
2022-07-07 12:12:00 【sinat_36789271】
一、状态图
类定义的是一组对象的抽象,而每个对象时类的一个实例,但对于一个对象而言,它在其整个生命周期中有一系列的状态。状态描绘了对象的动态生命周期。
“人” 就是一个类,而“你”、“我”、“张三” 等都是“人”这个类的一个实例,“站着”、“躺着”等都是对象的一个状态。
在对象的整个生命周期中,它的状态是会发生变化的,而状态机就是用来表示一个对象在它的生命周期中响应的时间所发生的状态变化以及对事件的响应。
二、组成元素、状态机
状态机是一个对象的局部视图、一个将对象与其外部世界分离开来并独立考查其行为的视图。状态机是精确描述行为的一种好办法。
如描述烧水器在工作时的详细行为细节:
状态:是指在对象生命周期中满足某些条件、执行某些活动或等待某些事件的一个条件和状况。
开始状态
结束状态
命名状态
在一张状态机图中,最为核心的元素无外乎有两个:一个是用圆角矩形表示的状态;另一个是在状态之间、包含一些文字描述的有向箭头线,这些箭头成为转换。
一个转换是两个状态之间的一种关系,表示对象将在第一个状态中执行一定的动作,并在某个特定事件发生时且满足条件时进入第二个状态。
三、如何绘制状态图
绘制状态图的理想步骤:寻找主要的状态、确定状态之间的转换,细化状态内的活动与转换,用复合状态来展开细节
1、寻扎主要状态
在绘制状态机图时,最重要的一个活动就是寻找出主要的状态。对于航班机票预订系统而言,显然包括的状态主要有:
a、在确定飞行计划时,显然是没有任何预订的,并且在有人预订机票之前都将处于这种“无预订”状态
b、对于订座而言,显然有“部分预订”和“预定完”两种状态
c、当航班快要起飞时,显然要“预订关闭”
总结:有四种状态:无预定、部分预订、预定完和预订关闭
2、确定状态之间的关系
确定主状态之后分析状态之间的转换,画出相应的状态机图
边栏推荐
- FC连接数据库,一定要使用自定义域名才能在外面访问吗?
- 2022-7-6 beginner redis (I) download, install and run redis under Linux
- 最长上升子序列模型 AcWing 482. 合唱队形
- Wired network IP address of VMware shared host
- Seven propagation behaviors of transactions
- mysql导入文件出现Data truncated for column ‘xxx’ at row 1的原因
- 请问指南针股票软件可靠吗?交易股票安全吗?
- Is the compass stock software reliable? Is it safe to trade stocks?
- XML文件的解析操作
- 为租客提供帮助
猜你喜欢
Wired network IP address of VMware shared host
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
最长上升子序列模型 AcWing 1014. 登山
The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
Evolution of customer service hotline of dewu
AutoCAD - how to input angle dimensions and CAD diameter symbols greater than 180 degrees?
Deep understanding of array related problems in C language
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
随机推荐
Regular expression integer positive integer some basic expressions
Oracle advanced (V) schema solution
PostgreSQL array type, each splice
"Song of ice and fire" in the eleventh issue of "open source Roundtable" -- how to balance the natural contradiction between open source and security?
2022-7-6 Leetcode 977.有序数组的平方
AI talent cultivation new ideas, this live broadcast has what you care about
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
Environment configuration of lavarel env
作战图鉴:12大场景详述容器安全建设要求
Help tenants
最长上升子序列模型 AcWing 482. 合唱队形
Transferring files between VMware and host
Redis只能做缓存?太out了!
Vmware共享主机的有线网络IP地址
请问,在使用flink sql sink数据到kafka的时候出现执行成功,但是kafka里面没有数
Parsing of XML files
手里的闲钱是炒股票还是买理财产品好?
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
566. Reshaping the matrix