[Course full solution] - UML software modeling design

software modeling

Purpose: UML9 kinds of diagrams describe the software system functions, architecture, and relationships you want to achieve

UML9 diagrams

  1. Use Case Diagram (Static Diagram - Functionality owned by an Actor)
  2. Class diagram (static diagram - object-oriented class function design (JAVA-inheritance, encapsulation, polymorphism))
  3. Sequence Diagram (Dynamic Diagram - time lapse message sending)
  4. Object graph (static graph - relationship between objects and objects (objects are instances of classes))
  5. Component diagrams (static diagrams - links between software modules or physical structures)
  6. Deployment diagram (static diagram - physical hardware deployment relationship (network topology))
  7. Activity Diagram (Dynamic Diagram - Process of events happening)
  8. State Diagram (Dynamic Diagram - Object State Switching Process)
  9. Collaboration Diagram (Dynamic Diagram - Time Lapse Messaging)

4. State Diagram - Dynamic Diagram

Role: describe all possible states of the object, and the connection between state switching between them

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-BMazEgJU-1678712787632)(../note picture/image-20230313190916677.png)]

5. Activity Diagram (Activity Diagram) - Dynamic Diagram

Role: Describe the relationship between use cases in the form of a use case diagram

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-0Wm1JhyP-1678712787633)(../note picture/image-20230313191252867.png)]

6. Sequence Diagram - Dynamic Diagram

Role: Process description of orderly interaction between participants (roles) and system objects, emphasizing how messages are sent and received between objects

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-I9oWa2BV-1678712787633)(../note picture/image-20230313191544344.png)]

7. Communication Diagram - Dynamic Diagram

Function: Similar to sequence diagrams, it is used to describe the dynamic collaboration relationship between objects, a collection of class diagrams and sequence diagrams, focusing on describing the communication process between objects and objects

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-vV9ydLWU-1678712787633)(../note picture/image-20230313191813233.png)]

8. Component Diagram - Static Model

component diagram

Function: A diagram describing the code structure, describing the connection between various code components

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-RA9XO1KN-1678712787634)(../note picture/image-20230313192154655.png)]

9. Deployment Diagram - static model

Role: Describe the physical deployment process of the system, such as computer equipment and how they are connected

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-Qa5SJ0Nm-1678712787634)(../note picture/image-20230313192410953.png)]

software development process

Introduction to Software Engineering Overview - Software Development Process

1. Software process

In order to obtain a series of task frameworks that need to be completed by high-quality software, it stipulates how to better complete the steps of each work

1. Waterfall Model (Linear Model) - Mainstream

Features:

​ There is sequence and dependency between stages

advantage:

​ Can force developers to use a standardized method for implementation; strictly stipulate the documents that need to be produced at each stage

Requirements Analysis—"Summary Design—"Detailed Design—"Coding Phase—"Testing Phase

1. Demand analysis: (output result: demand analysis manual)

​ Understand customer needs, and be able to remove the specific functions and content to be implemented

2. Outline design: (output results: technical design plan, outline design implementation plan—what technology is used to complete what function)

​ Combining existing technologies to analyze how business needs should be realized

  1. Detailed design: (output results: user interface design (UI), UML engineering documents, database design sql code)

    ​ Prototype design diagram (user operation interface), user operation process (UML design-sequence diagram), object-oriented design (UML-class diagram, object diagram, collaboration diagram), database design (PowerDesigner)

  2. Coding phase: (code, packaged software)

    Division of labor, division of modules, and planning

  3. Test (network access security proof, test case output document)

    Black box testing, white box testing (stress, network security...)

2. Rapid prototyping model

Drive software development with prototype interface

Applicable to some software systems with simple functions and a small amount of development

3. Incremental Model - Enterprise Development Mainstream

Each project is an increment, there is no need to overthrow the previous process from a new design

4. Spiral design, fountain model (XXXXX)

Tools for UML Design

MS visio

insert image description here

Online Tools (Free)

​ https://boardmix.cn/

https://app.diagrams.net

1. Use case diagram

effect:

A diagram representing the relationship between use cases and actors in a system

​ It describes the related users in the system and the functions and services provided by the system to different users

1. Elements

1. Role (Participant)

​ is an external entity unit that interacts with the system subject, describing one or a group of users or things that interact externally with the system

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-kJRShNlH-1678712787635)(../note picture/image-20230313202307558.png)]

2. Use case: (function, module)

​ Describes the functional content that can be accessed by a role or thing (a collection of a series of operations)

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-UalZ58zR-1678712787636)(../note picture/image-20230313202423054.png)]

2. Contact method

1. The generalization relationship between roles:

​ Generalization represents an abstract concept, pointing to the method: concrete things pointing to -> generalizing abstract things, more systematic design for generalization

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-Q1cyDTCA-1678712787636)(../note picture/image-20230313202707766.png)]

Dependencies - Contains

​ is the function that should be included in the design of the use case. Use the include description to point to the method A function includes— <<incloud >> --> B function

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-75oE97Me-1678712787636)(../note picture/image-20230313203529632.png)]

Dependencies - Extension

​ It is the expansion of the use case and the enhancement of the functional behavior. The functions added in addition to the necessary functions need to use the expansion

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-ZTN2I2H1-1678712787637)(../note picture/image-20230313204201636.png)]

use case generalization

​ Similar to roles, connect the concrete use case with the abstract use case, and realize the concept of inheritance. The concrete use case is modified on the basis of the parent class use case

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-vNQ2ZlUs-1678712787637)(../note picture/image-20230313204427540.png)]

3. Case

Describe the functionality of an enterprise management system,

​ All employees have the functions of clocking in and checking plans,

​ But the manager has the functions of managing employee information and customizing plans;

​ Boss has all employee and manager functionality

Improve the topic:

​ Based on the previous topic, employees only have permission to view the plan for the plan function.

​ But the manager has plans to add, modify, and delete functions;

​ The boss made a request that the plan can be imported from other systems

design according to the requirement
insert image description here

4. Use case diagram description

After we draw a use case diagram, we need to describe the use case, so that developers who read the use case can understand the description of the event process more clearly

Contents that need to be described in a use case diagram:
1. Use case name : describe the meaning or goal of the use case diagram, usually a verb or an object phrase
2. Use case number : realize the quick index search of multiple use case diagrams
3. Participants : participating roles What are there?
4. Use case description : a simple sentence summarizing who is in what system and what can be done
5. Trigger : Timing node description for triggering a use case
6. Precondition : Description of the system state process before the use case is executed
7. Basic event flow : Describe the regular use case activities clearly in the form of time process
8. Extended event flow : Generally describe the process of errors or business exceptions in the basic event flow
9. Conclusion : When the use case ends
10. Data requirements : There will be some during the use case What data interaction
11. Business constraints : describe the constraints in the business

Use case description in case

Key words description value
use case name Enterprise employee operation management system
use case number CXK001
participant employee, manager, boss
use case description Describe the description of the system function permissions of the three participants
trigger Participants log in to use the management system
Preconditions Participants need to log in to the system
basic event flow 1. Employees can log in to the system to check in and view the currently specified plan content.
2. Managers can log in to the system to manage and distribute employee information and plans.
3. Bosses can view and manage all employee information, and can manage all employee information. plan to customize or view
Extended Event Stream 1. Employees log in to the system, and cannot operate the corresponding business functions due to insufficient authority, and return to the login page
in conclusion After the employee logs in to the system, the operation of the plan or check-in function and the management of employee information are completed, and the use case is completed
data requirements 1. Employee information 2. Punch record 3. Plan information
business constraints Different roles operate with different functions

2. Timing diagram (sequence diagram)

1. What is a sequence diagram

Sequence diagram (Sequence Diagram), also known as sequence diagram,
describes the time sequence of information sent between objects and displays the dynamic collaboration relationship between multiple objects

2. Elements

5 elements of content:

  1. Role (Participant-Actor)
  2. object
  3. Lifeline
  4. Control Focus (Activation)
  5. Message

1. Role

Role: Represented by a small person icon, which can describe things such as people or systems, and is generally used as the starting point for timing diagram triggers

insert image description here

2. Object

The object diagram is at the top of the timing diagram, described by a rectangular box

insert image description here
There are three types of object description content in UML design:

1. Object and class names

Writing method: Object name: class name
can reflect the relationship between classes and classes by describing the calling relationship between specific objects, and then can associate class diagrams

insert image description here

2. Class name

Writing method: Class name
only highlights the call process relationship between classes and describes the call coordination process contained between a class of things

insert image description here

3. Object name

Writing method: object name
to highlight the call coordination relationship between specific objects

insert image description here

3. Lifeline

There will be a dotted line under the rectangular frame of each object. The dotted line describes the time lifeline of the object, and the line from top to bottom describes the time from the past to the future.

insert image description here

4. Control focus

What happens on the timeline or the operation performed during a certain period of time when each object interacts is described by a long rectangle

insert image description here

5. Message

messages sent between objects

There are three types of messages:

1. Synchronization message

Drawing method: solid line + solid arrow
The sending object sends a message to the receiver, and the receiver must give the sender a response (reply), otherwise the sender will wait forever
Note: the synchronization process will appear that the object must wait for another object to return the result to continue

insert image description here

2. Asynchronous messages

Drawing method: Realize + greater than symbol arrow
After the sender of the message sends the message, he continues to perform his own activities

insert image description here

3. Return message

Drawing method: dotted line + less than symbol arrow
The return message indicates the return from the procedure call

insert image description here

4. Self-associated messages

Drawing method: draw in a synchronous and asynchronous manner, and send and receive messages by yourself. When the
function of sending a message to your own object appears during the call, you can use the self-association description

insert image description here

3. Combining fragments

Composite fragments are used to address the conditions and modes of interactive execution, allowing direct representation of logical components in sequence diagrams, and are used to define special conditions and sub-processes for any part of any lifeline by specifying the application area of ​​the condition or sub-process.
There are 13 types of combined fragments:

type name describe
(must learn)Opt options Contains a sequence that may or may not occur
(must learn)Alt to choose Contains a list of fragments, these lists contain alternative information sequences, only one of the sequences can occur in any scenario, the first fragment Alt and the else fragment cooperate, the critical point needs to describe an expression, when the result of the expression changes Select the corresponding sequence to operate
(must learn)Loop cycle The fragment repeats a certain number of times, and the repeated conditions can be described at the critical point. The Loop fragment must have Min and Max attributes. If these two attributes are not described, it will be an infinite loop.
(must learn)Par parallel Parallel processing, multiple event fragments can be interleaved

Choice
insert image description here
Parallel
insert image description here

3. Class diagram (object-oriented design)

Role: Represents the static relationship view between classes, class diagram is a programming model diagram

class composition

Class name, attributes (fields) and behavior (methods)

Modifiers in class diagrams

Four access modifiers

public (public) visible to everyone: use "+" in the class diagram
private (private) only visible to yourself: use "-" in the class diagram
protected (protected) yourself and subclasses: use in the class diagram "#"
default (default) does not use access modifiers: use "~" or not write in the class diagram

attribute field type

Text type:
(1) String: String
(2) char: Character
Numerical type:
(1) int: Integer type
(2) double: Floating point type (decimal type)
Others:
(1) Date: Date
(2) Boolean Value: boolean
(3) Object type: Object
(4) Array collection: Array

insert image description here

method description

There are methods

For example: the description of eating: you can use
+eat(food) for the behavior of giving food to someone

No parameter method

For example: running is a behavior that can be completed without external conditions
+ run()

method with return value

For example: calculating the sum of two numbers will get a result, and the result is the data returned through the calculation process

  • sum(num1:int,num2:int) : int
    modifier method name (parameter list): return value type

method without return value

No return value method, the described behavior focuses on the process and has no result
For example: describe the behavior of walking
+ run (): void
modifier method name (parameter list): void

relationship between classes

There are 6 relationships:

  1. Association: solid line
  2. Aggregation: Rhombus Hollow Solid Arrow
  3. Combination: Rhombus Solid Solid Line Arrow
  4. Inheritance: Triangular Hollow Solid Arrow
  5. Implementation: triangular hollow dotted arrow
  6. Dependency: small dotted arrow

insert image description here

1. Association

One-way association: If only A is associated with B, B is not associated A
two-way association: AB is associated with each other

Two-way association case
insert image description here
: the driver can rent a car and the car is waiting to be rented, the two categories are two-way association, write 1 on both sides of the solid line. Will change because of penguins, this is a one-way association

insert image description here

2. Dependency

Description: If the change of one class will affect another class, there is a dependency relationship between the two classes. Generally speaking, the dependency relationship is one-way. If the dependency is two-way, consider using the association relationship description

Case: The car depends on gasoline, but gasoline does not depend on the appearance of the car
insert image description here

3. Aggregate

What is described is: changeable group
The description is the relationship between the whole and the part. When an entity is aggregated into another entity, the entity can also be a part of another entity.
Hollow rhombus + solid arrow
insert image description here

4. Combination

The description is: multi-group one
also describes the relationship between the whole and the part. The combination is more strict than the aggregation. When an entity is combined into another entity, the two have the same life cycle

insert image description here

5. Inheritance Generalization

It describes a description process in which an abstract thing is continuously visualized, and it is the same concept as inheritance
insert image description here

6. Interface realization (Realization)

What is an interface:
only describe the unique behavior, and let the class implement it.
insert image description here
The class will implement the public interface method behavior, and different behavior effects will appear in each class
insert image description here

4. State diagram

Overview:
State diagram (State diagram)
is used to describe the various states of a specific object in its life cycle and the transition process of switching between states.
Note: When describing the state diagram, it must be clear who the specific object of the state you describe is
insert image description here

Role:
1. Clearly describe the relationship and sequence of switching between states
2. Understand the logic of the business call process, and know the causal relationship between sequence and state switching
3. Clearly understand the necessary behavior content when switching states

1. Common elements

1.1 Initial state (circle or hollow circle)

insert image description here
It is a must have, because all businesses have trigger points, and there is only one

1.2 End state (solid circle plus a hollow outer ring)

insert image description here
It is not necessary to have, but a state diagram may have multiple terminal states
. For example: the order may be destroyed or the payment may be completed
insert image description here

1.3 Status Box

Refers to a certain condition or situation in the life cycle of an object, and the state is the result of a series of activities performed by the object
insert image description here

1.4 State transition (solid triangle arrow description)

The connection between one state and another state, the event expression of the transition should be expressed on the transition (behavior process description)
insert image description here

2. Whether the state diagram has a terminator classification

1. No termination state

insert image description here

2. has a terminated state

insert image description here
State diagram case: the process of Zhang San withdrawing money at the ATM machine (observation perspective: ATM machine)
insert image description here

5. Activity Diagram

Introduction
Activity Diagram (Activity Diagram) is another kind of graphics that models the dynamic behavior of the system. It describes the sequence of activity behavior and shows the control flow from one activity to another. The activity diagram itself is a kind of flow chart.

b

insert image description here

1. Common elements

1.1 Action status

The action state is generally an atomic operation that cannot be split again in the activity diagram, and it is an uninterruptible action behavior. The action behavior will be converted into another behavior drawing
method:
a rounded rectangle describes
insert image description here
the characteristics of the action state:

  • 1. The action state is atomic
  • 2. The time in the action state is very short
  • 3. There must be an entry state and an exit state
  • 4. There can be no in and out actions, as long as the arrow points to it

1.2 Initial node

The hollow circle marks the starting point of the business, and there is only one initial state.
insert image description here

1.3 Endpoints

A hollow ring, expressing the termination of a business process, can have one or more
insert image description here

1.4 Judgment and merger

(1) Judgment process
Make decisions based on judgments, and execute different processes based on decisions.
insert image description here
(2) Process merging
Two or more processes point to nodes, and nodes point to terminal nodes or other behavior nodes.
insert image description here

1.5 Forking and combining

(1) Fork
means that a process is divided into multiple parallel sub-branches to complete the transaction
insert image description here
(2) Combine
multiple execution streams are aggregated into one behavior result, and the combination can only be completed when all branch processes are executed, so as to continue to execute
insert image description here

1.6 Conversion

When an activity ends, the control flow is passed to the next activity node immediately, described by a straight line with an arrow
insert image description here

1.7 Lanes

It is used to isolate the content of behavioral operations between different objects or roles. You can intuitively see what operations each role has performed in this activity. Note that swim lanes cannot be described repeatedly

(1) Vertical swimming lane

Lane 2: user, system
User logs in to the system, fills in the results and exits the system
insert image description here

(2) Horizontal swimming lanes

During the operation of the activity, there will be a role change, which is generally realized by combining horizontal swimming lanes with vertical swimming lanes.
It is also possible to distinguish the phases of the activity
insert image description here
insert image description here

6. Component Diagram

Component Diagram, also known as component diagram, describes physical and replaceable software modules in a software system that comply with a set of interfaces.
Construction diagram = construction (Component) + interface (interface) + relationship (Relationship) + connector (Connector)

insert image description here

1. Common elements

1. Component

Some modules in the system design hide the content of the module implementation and provide a set of interfaces to the outside world. The components are replaceable, which means that the components are not coupled

insert image description here

component type
  • Source Code Component : A component consisting of one or more source code files or packages
  • Binary component : an object code file or static library file
  • Executable component : A program unit that can run on a machine

Component drawing distinction

insert image description here
UML2.X, drawing method, the drawing method of component elements that appear in most component diagrams now, omits the interface blocks provided in the component to the outside or sent to the component from the outside.

2. Interface

Interface Type:

  • Provide interface: the component provides an interface that is conveniently called by other components
  • Requirements interface: content or data that requires the use of external components

insert image description here

provide interface

insert image description here

Requirement interface

insert image description here

component link

insert image description here

3. port

Ports indicate the nodes that components interact with the outside, because components can provide one or more services, in order to provide visibility descriptions, different functions need to be described in the form of ports.
insert image description here
Drawing method:
Use a square connection interface for externally exposed ports.

Port connection drawing method:

insert image description here
The drawing method that needs to expose the port generally appears when the component provides multiple service interfaces externally, or when the component needs to obtain multiple services through external components.

How to draw a one-to-many component link

insert image description here

Component dependencies
(1) Dependencies between components and components

The way the dotted arrow points, the demand side points to the service provider
insert image description here

(2) Dependencies between components and interfaces

Similar to the description, the behavior of the component interface and the requirement interface
insert image description here
is as shown in the figure above, which can be described using dependencies
insert image description here

insert image description here

Component Packages (Component Blocks)

When there is a containment relationship between components, the following description can be used.
insert image description here

Method for component blocks to expose service ports

insert image description here

The subcomponents in the component block can be linked normally

insert image description here

7. Deployment diagram

insert image description here

1 Overview

The deployment diagram describes a hardware node when the system is running, and a diagram of the interactive connection between software and hardware in the node.
A deployment diagram consists of two elements:

  • 1. Nodes: such as hardware physical hosts, routers, etc.
  • 2. Connection: network, request, line

2. Function

The main purpose of the deployment diagram is to do overall system planning at the physical level

    1. Describe hardware topology
  • 2. Describe the association between the hardware in the deployed software
  • 3. Describe the hardware interaction relationship

3. Common elements

1. Node

There are two types of nodes: processing nodes (processors), service nodes (device)
insert image description here
processors

Refers to a node that has computing power and can execute various software, such as a server. The processor is capable of processing data and business.

equipment

Refers to nodes that do not have processing functions themselves, such as: printers

2. Relationship

insert image description here

Indicates the hardware connection between two nodes, and generally describes the connection between networks, lines, optical cables, etc.
Drawing method: Just realize the connection

4. Case introduction

Describe the connection relationship between the sales host of multiple stores and each service component of the server
insert image description here
Distributed microservice deployment mode

Distributed microservices: Each module in distributed operation will be specified as an independently running service module, IP, and port, and each service module will call each other to achieve the effect of collaborative operation between microservices in a distributed scenario.

SpringCloud

  1. SpringCloud Netflix (paid)
  2. SpringCloud Alibaba (Alibaba team)
  3. dobue
  4. SpringCloud serverMS

8. Collaboration Diagram

Collaboration diagram: Cooperation diagram is a dynamic diagram. Emphasizes the organization of objects between sending and receiving messages, a collaboration diagram showing a set of objects and the connections between these objects

insert image description here
From the analysis of the above figure, it can be seen that
the description method of the collaboration diagram and the sequence diagram is similar (object + time + message).
The message uses a digital mark to describe the order in which the message is sent.

8.1 Features

Collaboration diagram has no concept of lifeline, but only describes the relationship of messages between objects.
Collaboration diagram highlights the organizational structure.
Collaboration diagram describes the connection and message sending relationship between objects.
Collaboration diagram describes the relationship of message sending.

8.2 Common Elements
(1) object

A collection of behaviors or participants that appear in order to complete specific functions, such as: e-commerce platforms, people, Cai Xukun
insert image description here

(2) link

Represents an independent connection between objects and represents one or more connected lines or arcs. Arcs
insert image description here
represent self-invocations
insert image description here

(3) news

The method of describing the behavior of the system is to send a message from one object to another object, which may be a method or an instruction of an operation; the message consists of a sender, a receiver, and an active content
insert image description here

Case explanation

Describe the checkout process of the administrator
1. Log in to the system
2. Return - after successful login
3. View the checkout information
4. The checkout information needs to be checked from the database
5. After the database checks and confirms the information
6. The administrator checkout
7. The system records the checkout content
8. Checkout completed

(1) Timing drawing method

insert image description here

(2) Collaborative drawing method

insert image description here

Collaborative Drawing Diagram Steps

  1. Determine who to participate in the interaction
  2. Identify objects and link relationships between objects
  3. When each message is sent, it should be drawn according to the link relationship, and pay attention to the direction of message sending

Guess you like

Origin blog.csdn.net/gjb760662328/article/details/129506717