1. Ref
Ref.1 EA UML Tutorial
Ref.2 Enterprise Architect 15.1 User Guide
Ref.3 什么是UML?
Ref.4 What is UML 2?
Ref.5 Information Hub
2. 目标
本专题的目标是介绍关于UML的基本知识点,并结合实际案例介绍其在嵌入式系统设计中的基本用途。
3. UML
3.1 UML 是什么?
The Object Management Group (OMG) specification states:
The Unified Modeling Language (UML) is a graphical language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive system. The UML offers a standard way to write a system's blueprints, including conceptual things such as business processes and system functions as well as concrete things such as programming language statements, database schemas, and reusable software components.
按照OMG官方组织的定义,UML是一种专用于系统(软件相关)建模的图形化的语言,可描述系统设计初期阶段的概念,或者功能,系统设计阶段的系统架构。
其核心特征在于图形化。俗话说的好,“一图胜千言”,有了图,就可以按图索骥,避免出现讨论时的空洞无物,鸡同鸭讲,建立一个系统设计沟通话语体系,让工程师可以同频共振。
其二,其方法论是OOP(Object Oriented Programming),也就面向对象设计。描述的基本对象是抽象的对象,类,或者组件。
UML 分为两种类型,也就是结构类型(structural Modeling Diagrams)和动态类型(Behavioral Modeling Diagrams)两种类型,共14种图形。分类如下:
- UML
- Structural Modeling Diagrams
- Package Diagrams
- Component Diagrams
- Class or Structural Diagrams
- Deployment Diagrams
- Composite Structure Diagrams
- Object Diagrams
- Profile Diagrams
- Behavioral Modeling Diagrams
- Use Cases Diagrams
- Sequence Diagrams
- Activity Diagrams
- Timing Diagrams
- State Machine Diagrams
- Interaction Overview Diagrams
- Communication Diagrams
- Structural Modeling Diagrams
结构类型的UML图用于描述系统结构,换言之,也就是静态架构,包括各组件,组件之间的接口。
动态类型的UML图用于描述系统行为,即动态行为,包括系统行为,系统内部各组件的行为。
3.3 为什么要使用UML
UML, why?
个人认为原因如下:
- 统一建模语言,使嵌入式系统从业人员,有一个描述沟通设计语言,而非只有代码。当然,有人可能会说,使用代码自说明系统设计,不也可以吗?我会说,你说的没错。但是随着嵌入式系统功能越来越复杂,投入到一个项目的人员越来越多,角色越来越多,包括系统需求工程师,架构工程师,软件开发工程师,测试工程师,维护工程师,项目管理等等。涉及的角色越来越多,不是所有的人都可以看得懂代码。
- 面向对象设计,封装 ,继承,提高系统组件设计复用率;
3.4 UML 有哪些工具
UML工具有哪些呢,网上开源工具有很多,如StarUML;收费的如EA,Enterprise Architect。
3.5 Structural Diagram
结构类型UML图共有7种,按照EA UML官方定义,各个图的用途如下:
Structure diagrams define the static architecture of a model. They are used to model the 'things' that make up a model - the classes, objects, interfaces and physical components. In addition, they are used to model the relationships and dependencies between elements.
ID | Diagram | Description |
---|---|---|
1 | Package Diagrams | Package diagrams are used to divide the model into logical containers, or ‘packages’, and describe the interactions between them at a high level. |
2 | Component Diagrams | describes the software (and sometimes hardware components) that make up the system. Component diagrams are used to model higher level or more complex structures, usually built up from one or more classes, and providing a well defined interface. |
3 | Class or Structural Diagrams | Class or Structural diagrams define the basic building blocks of a model: the types, classes and general materials used to construct a full model. |
4 | Deployment Diagrams | describes the physical architecture and the deployment of components on that hardware architecture. Deployment diagrams Deployment diagrams show the physical disposition of significant artifacts within a real-world setting. |
5 | Composite Structure Diagrams | Composite Structure diagrams provide a means of layering an element’s structure and focusing on inner detail, construction and relationships. |
6 | Object Diagrams | Object diagrams show how instances of structural elements are related and used at run-time. |
7 | Profile Diagrams | Profile diagrams provide a visual way of defining light-weight extensions to the UML specification. UML Profiles are often used to define a group of constructs with domain-specific or platform-specific properties and constraints, which extend the underlying UML elements. |
3.6 Behavioral Diagram
Behavior diagrams capture the varieties of interaction and instantaneous states within a model as it 'executes' over time; tracking how the system will act in a real-world environment, and observing the effects of an operation or event, including its results.
ID | Diagram | Description |
---|---|---|
1 | Use Cases Diagrams | describes the boundary and interaction between the system and users. |
2 | Sequence Diagrams | |
3 | Activity Diagrams | |
4 | Timing Diagrams | |
5 | State Machine Diagrams | State charts describe the states or conditions that classes assume over time. |
6 | Interaction Overview Diagrams | describes how objects in the system will interact with each other to get work done. |
7 | Communication Diagrams | describes how objects in the system will interact with each other to get work done. |