- First, preface
- Two, UML introduction
- Three, use case diagram
- 4、Time sequence diagram
- 5、class diagram
- 6、Activity diagram (Activity Diagrams)
- 7、Component diagram
- 8、state diagram
- Nine. Other
UML：Unified Modeling Language（Unified Modeling Language) what are the functions of UML modeling?
- A better understanding of the problem
- Early detection of errors or missing points
- It is more convenient to communicate among the members of the group
- Supporting object oriented software development modeling can better describe the scenario of display programming.
- For complex systems, if the summary model is done well, the model of the whole system is very clear.
Two, UML introduction
UML Specifications define two kinds of UML diagrams: structure diagrams and behavior diagrams.
Structure diagram (structure diagrams)
The structure diagram describes the static structure of a system and system from different abstractions and implementation, and describes how they are directly linked together.
Behavior diagram (behavior diagrams)
A behavior diagram shows the dynamic behavior of an object in a system. It describes how the objects in a system change with time.
Next, borrow the official map of the next UML2.5 to illustrate the classification of UML diagrams:
Domain model, also known as conceptual model, is a description of the real world concept class, not a software object description, and a domain model is not a data model. In UML, the domain model is described as a set of class diagrams without operation, specifically, not the software objects in Java or objects with duties and behaviors. He can show itA domain object or a concept class, a concept class, an attribute of a concept class.
Three elements, class name, attribute, association.
Any attribute does not represent a foreign key, and it should be directly associated with the foreign key class.
Three, use case diagram
In the whole process of the software lifecycle, use case diagrams are the first step in software requirements analysis to software delivery. The main purpose of the use case diagram is to explain who the user is, the user needs to use those functions, and what functions the user needs to provide to the software. Use the use case view to make it clear to the userTo understand what the software can provide, not to meet your needs, on the other hand, for developers, it is better to understand the needs and to better achieve these requirements.
A use case diagram has six main elements: Actor, use case (Use Case), Association (Association), inclusion (Include), extended relation (Extend), and generalized relationships (Generaliza)Tion).
Participants in the UML are marked with the names of the small persons below, which mainly represent people, organizations or external software systems interacting with your software system.
Use case (Use Case)
The use case in UML is marked by the use of ellipses, which mainly explains the function of your software system. It is the function of using the text description to explain the function of your system.
Association relationship (Association)
In UML, the use case diagram is marked with arrows, which mainly describes the relationship between the participants and the use cases.
【Arrow pointing]: point to the use case
Inclusion relationship (Include)
In UML, the inclusion of a relationship is expressed as a dotted arrow with < < include> > and sometimes a use case is large, then we can block the use cases and decompose the complex use cases into several small use cases to describe
【Arrow pointing]: the arrow points to the included use case
The extended relationship in UML is expressed as a dashed arrow and < < extend> > the extension refers to inserting new function points on the basis of the basic use case function, and the new function points can be seen as an extension of the basic use case.
【Arrow pointing]: the arrow points to the basic use case
In UML, use case generalization uses a hollow triangular arrow to point to a parent case with a subcase, generalization is the inheritance relationship, and the child use case can use the attributes, behavior, and relationships in the father use case.
【Arrow pointing]: the arrow points to the parent use case
Include、Extend、InheritanceSum up and contrast
The relationship emphasizes the relationship between the whole and the part, that is to say, the whole function is superimposed on the function of a sub case. For example, the previous trial function includes the online video trial, the online speech trial, the offline voice hearing function, and the trial case itself is a summary of the sub functions, and the specific function points are in the child.Use case implementation.
The extended relationship emphasizes the addition of new functions on the basis of the basic function, the basic function itself provides the function, the basic function and the extension function are directly invisible, but the extension function is to happen under one condition of the basic function, for example, the court hearing of the above basic service video has already provided the work of the trial.Yes, now there is an extended speech recognition function to identify what users say is text. The reason why it is extended is that even without voice recognition, the video court function can operate normally. The reason why the extension function is conditional is that only a video court is opened for speech recognition.The extension function of speech recognition can be returned
The generalization relationship emphasizes the reusable relationship, which means that the subcase is based on a part of the function of the parent use case and has added or overlaid the function of the parent use case. In particular, the previous video trial has a record writing function, which itself is an independent function point, and the clerk and the judge can reuse this.Function and customize it.
4、Time sequence diagram
A time sequence diagram is an interactive graph that emphasizes message timing. He is composed of objects (Object), message (Message), lifeline (Lifeline) and Combined Fragments, which mainly describe the interaction between objects and objects in the system, whichInteractive modeling into message exchange.
The sequence diagram shows the interaction relationship into a planar two-dimensional graph, which indicates the time axis vertically, and the time goes up and down along the vertical line. The lateral axis indicates the various objects in the interaction. The object is represented by the lifeline. The arrow from the lifeline of an object to the lifeline of another object indicates that the arrow is time bound.The order is arranged from top to bottom in the graph, from left to right.
Objects (Object) and lifeline (Lifeline)
The square in the square on the lifeline is the object. The object has its own name. The lifeline is actually a dotted line from top to bottom. Lifeline marks the lifecycle of an object, and the two lifeline is connected by message.
Messages are used to pass information between objects, and intercommunication between objects is through messages, messages can be divided into Synchronous Message, asynchronous message (Asynchronous Message) and return message (Ret)Urn Message) autocorrelation message (Self-Message)
Synchronization message: the object that sends the message will be hung after sending the message, and the message receiving object will be returned after receiving the message to return to its work.
Asynchronous message: the object sending messages will continue to work after sending the message, and the message will be returned without the message receiving object.
Return message: the action returned after sending the message.
Self associated message: the situation where an object is self invocation.
The message is marked with certain conditions.
- Alternative fragment（denoted “alt”） Mark if… Then… Else
- Option fragment (denoted “opt”) Mark Switch
- Parallel fragment (denoted “par”) Sign at the same time
- Loop fragment(denoted “loop”) Mark for
- BreakSign out the exit cycle
When no specified cyclic boundary is specified, the default range is [0, infinity]:
If only one value is specified, then the number of times it is executed by default:
When the loop boundary is specified, the minimum value is executed at least, and the maximum number of times is executed at most.
To achieve dowhile, execute at least once, if size< 0 exit:
If the condition is judged, if n> 0 executes the agree function, executes the reject function.
switch，Different methods are implemented when different conditions are met:
n=10Time to execute save and exit the loop
At the same time, for example, multiple threads perform tasks simultaneously.
Class diagram is an important diagram in object oriented system modeling, and is the basis for defining other diagrams. Class diagrams are mainly used to represent classes, interfaces and static structures between software classes.
In UML class diagrams, the relationships among classes are as follows: Generalization, Realization, Association, Aggregation, combination (Compositio).N), dependency (Dependency)
Generalization is a kind of inheritance relationship. Subclasses inherit all actions and attributes of the parent class. Subclasses can add new functions or overwrite the parent class function.
umlA real line marking with a hollow triangular arrow
【Arrow pointing]: the arrow points to the parent class
Implementation is the relationship between interface and class. It means that the class implements the interface defined in the interface, and the dotted line with hollow triangular arrows in UML.
【Arrow pointing]: the arrow points to the interface class
In the process of modeling, there must be links between classes, so that classes can perceive behaviors and attributes of other classes.
Bi-directional Association (standard)
For two-way correlation, the two classes associated can perceive each other’s existence.
For each end of the graph, a role and multiple values are placed at each end. For Route, we should look at the role and multiple values at the bike side. For Route, each cycling route corresponds to 0 or more bicycles, and the 0 is because the riding route may be first set up, but there are more than one driving.It’s because many people can ride the same route. For bike, we should look at the role and multiple values of the route side. For a bike, each bike is for 0 or more riding routes, and the 0 is that although there is a bicycle, I can not ride, and do not specify the way to ride.Line, there are many because I can specify multiple riding routes on a bicycle.
The above multiple values are 0… *, and in fact, there are other multiple values as follows:
|0..1||0One or 1|
|0..*||0One or more|
|*||0One or more|
|1..*||1One or more|
|0..5||0To the 5|
|5..15||5To the 15|
For a one-way Association, the two classes are related, but only one class knows the existence of such a relation.
For example, the unidirectional association is represented by an open arrow with an open arrow with a known class. The unidirectional Association contains only one role name and multiple value, one can have 0 or more accounts, and the person can perceive the existence of the account, but the account is not aware of the existence of the person.
Aggregation is a kind of relationship. Aggregation mainly describes the direct relationship between the whole and the parts.
Basic aggregation: the life cycle of a partial class corresponds to the life cycle of the whole class for the basic aggregation. In UML, a solid line from the whole class to a partial class is used, and an unfilled prism is painted at the end of the association of the whole class:
A car has 4 wheels, and the life cycle of wheels does not depend on cars, because wheels can exist independently of cars.
Combinatorial aggregation: combined aggregation is a case of aggregation. The difference lies in the life cycle of a partial class depending on the whole class. In UML, a solid line from the whole class to a partial class is used, and a filled prism is drawn at the end of the association of the whole class.
A company has at least one department, and the department depends on the existence of the company. There will not be a department and it does not belong to a company.
Self association involves a class, which is the situation where the class itself relates itself.
An employee can have 0 or more managers, and the manager himself is also an employee.
Dependency, the implementation of a class, requires the assistance of other classes, usually as a method parameter, a local variable, a static method call, a util class call, a dotted line with an arrow in UML, and a dependent class from the dependent side.
A domain model map is made from the official website of UML
Following this graph based on the class Library class analysis, first library is associated to the Catalog class by combination, which shows that the class cannot be independent of the existence of the library, so there is no aggregation using the combination. In addition, library is polymerizedIt is associated with the Book Item class and the Account account class, which means that the library is composed of 0 or more books and accounts. It uses aggregation instead of combination because books and accounts can exist independently of the library. For example, I have a school number account, but it is not necessarily in the library.Your account number.
Following the Catalog analysis, the items are associated with bookitem through a two-way Association, indicating that there may be 0 or more books in a category, and a Book corresponding to one category. In addition, classes have implemented search classes and mana through realization.The Ge class interface enables the class to have search and management functions. Class Search searches will depend on the name and address of the Patron class book donor or the name and address of the Libraian librarian. Library management class will depend on the information of librarians.
And Patron Book donors may be a student, students have their own accounts, so the patron class will converge to Account..
bookItemThe class inherits the common part information in Book by generalization. It has been linked to account by association. It shows that an account can only receive 0 books and a maximum of 12 books, which can book up to 3 books.
Finally, the Book class is related to the Author class. The number of authors has written at least 1 books (strictly speaking, 0).
AccountThe account class has a class that relies on an enumeration value of AccountState to store account status.
6、Activity diagram (Activity Diagrams)
Activity diagram is a behavior diagram in UML, which shows control flow and object flow, and emphasizes their order and conditional control flow.
Here is another way to introduce elements in activity diagrams by introducing UML official examples.
Start (inital) and end state (final)
Activity (action): marking action
Control flow (control flow): link activity
Decision making (decison): condition judgment
Merge (merge): any node arriving at that point continues to move down, regardless of other branches.
Swimming path (swimlanes): when there are multiple objects in the model, it is more suitable to use.
It is divided into horizontal and vertical
Join: when all branches reach that point, they continue to move down, and continue to move down after CountDownLatch.await.
Diffluence (fork): like fork, multiple threads are executed into thread pools.
Reception signal (acceptsignal)
__6.2 online shoppingAn example
Here’s an example of UML’s official online shopping shopping online.
If the black circle in the upper left corner of the graph starts with the activity, it is first to judge whether to search or browse through the conditions of the decision, if the search is to search the goods through the merge node and then judge the goods through the decision node and search the commodity information or add in the commodity information.Shopping Cart。 After joining the shopping cart, you can choose to enter B to continue
Search for other products, or check the contents of shopping cart. Then, after shopping, enter C to pay, then the process ends.
In addition, you can receive signals at any time to view the information of shopping cart entering A, or you can receive signals to checkout products at any time.
__6.3 Activation of Trial ProductAn example
The following is an example of UML’s official Activation of Trial Product activation trial product.
First, in this activity diagram, because the model involves three objects of Order Management, Customer Service and Customer, vertical swimlanes is used.
First, the customer request activates the probationary product that you are using (it is estimated that the probation period is over and can not be used), and then the customer service object opens two processes through the fork, one process is to let Order Management create a product order, one is to let the user produceC2V file. Then Customer Service is waiting for both to complete at join, where all the products are activated with the product secret key and the C2v file, and the file is passed to the user through email and so on. The user can activate both the file and the end of the activity.
A component diagram is a diagram to show the components, the interface (provided inerfaces) provided by the component and the interface (required interfaces) that needs to be invoked, a diagram of the relationship between the port (ports), the componentThe graph is mainly used for describing SOA system based on component development.
__7.1 Introduction of elements
A component is a class that represents a module in a system, and the performance of a component (such as implementation) is replaceable in the context of its environment, and the component has its own behavior, such as providing interfaces and using other component interfaces, which are potentially exposed or used through a port (ports)..
As the figure speech recognition service component provides the getPort interface for the other component calls, the Internet court shows that it needs to use the getPort interface to implement its own functions.
A port represents an interaction point between a class and its environment or other classes.
As shown in figure Accounting, the Customers inside the component provides Account services while the Orders component uses the Account service.
Connection line (Connector)
The connecting line is used to connect two or more instances so that they can communicate and collaborate directly. It is mainly used to connect two ports to direct communication
__7.2 An example
The following analysis of an official example of UML
As shown in the online shopping mall system, there are three subsystems: webstore, accounting, warehouses;
WebStoreThe subsystem includes three crew members, search engine, shopping cart and authentication system. Search engine components search and view goods by providing an ProductSearch interface to other components to run other components, and this is the Search Inve provided by the search engine components using the inventory component.The ntory interface is implemented. The shopping cart element encapsulates the function of the Manage Orders interface that invokes the order component, and encapsulates its own onllineShopping interface to the outside world, and the authentication component allows the user to create an account, log in or exit, and bind the order toSpecific users.
accountingThe subsystem provides external Manage Orders and Manage Customers interfaces, and connects to the Orders and customers components inside the subsystem through agents. The Orders component calls the Customers componentThe Manager customers interface, Customers calls the Accounts module Manager Accounts module.
WarehousesThe subsystem proposes Search Inventory and Manage Inventory components, and relies on the interface service of Accounting subsystem.
A state machine diagram is a behavior graph that shows some discrete behavior of a module in a system by using a limited state transfer. There are two state machine diagrams in UML2.4: behavioral state machine, protocol state machine (PRotocol state machine).
8.1 Introduction of elements
__ Behavior state (Behavioral State)
- Simple state (Simple State)
There are no sub state machines and domains in simple state. In UML, a rectangle with inflection points is used to indicate a simple state, and the state name is written inside the rectangle.
- Combined state (Composite State)
The combination state is defined as a state behavior that uses a substate or nested state, a substate can occur in a sequence or can be concurrency, with at least one domain in a combined state, such as the lower graph contains a domain.
__ The initial state (Initial Pseudostate), the termination state (Final State), (behavior transfer) Behavioral Transition
If the black solid is the starting state, the end double ring circle is terminated and the middle connection line is the behavior transfer, in which isAuthed is a guard explaining that the condition will be transferred and then the function auidt is executed.
8.2 Behavior state machine (behavioral state machine)
A finite state transition is used to represent the transformation of discrete behavior in a system, and behavior is modeled as a state connected by a series of transfer lines.
A simple behavior state machine:
8.2 Protocol state machine (Protocol State Machine)
A protocol state machine is a subclass of a behavior state machine. It is an extension of the state of behavior to describe the life cycle and protocol of a class. He describes which action of a class can be called under the specified condition under which state.
8.3 Official example
As shown below is a Java thread state machine diagram (protocol state machine diagram).
As shown in figure New, state is a time when a thread is created but not executing start () method.
In JVM it seems that when a thread is running at Runnable, it does not necessarily appear in OS, because the thread may not get the processor. So you can consider Runnable as a combination state with two sub states internally, when a thread state goes to Runn.At able, first into the Ready state (other resources are ready, CPU), the thread scheduling policy determines when the thread transforms the thread from the Ready to the running state, and the function Thread.yield () is the knowledge thread scheduling to temporarily fix the current threadExecute, change thread from running state to Ready state.
To be continued..
Source: Jane book
The copyright is owned by the author. For commercial retransmission, please contact the author for authorization.
- Introduction to UML visual language
- Introduction to UML visual language
- Six relationships of UMl class diagrams
- Six relationships of UMl class diagrams
- (turn) UML class diagram
- (turn) UML class diagram
- A summary of several relationships in the UML class diagram
- A brief introduction of a use case diagram
- A brief introduction of a use case diagram
- A summary of several relationships in the UML class diagram