Use case diagram
The use case diagram describes a functional unit provided by the system. The purpose of the use case diagram is to help the development team understand the functional requirements of the system in a visualized manner, including "Roles" based on basic processes (actors, other entities that interact with the system) relationship and the relationship between use cases in the system. The use case diagram generally shows the Organizational Relationship of Use Cases-either all use cases of the entire system, or a group of Use Cases with functions (for example, all security management-related use cases. To display a use case in the use case diagram, you can draw an elliptic, and place the name Of the use case in the center of the elliptic or in the center of the elliptic. To draw a role (representing a system user) on the Use Case chart, you can draw a humanoid symbol. The relationship between roles and use cases is described using simple line segments, as shown in 1.
Figure 1: Example
Graph (top to bottom): the CD sales system; view the sales statistics of the band's CD; the band manager; view the Billboard 200 ranking report; the recording manager; view the sales statistics of the specific CD; retrieve the latest Billboard 200 ranking report; ranking report service
The use case diagram is usually used to express advanced functions of the system or system category. 1 shows the functions provided by the system. This system allows the band manager to view the sales statistics report of the band CD and the report of the Billboard 200 ranking. It also allows the recording manager to view the sales statistics of a specific CD and the reports of these cd in the Billboard 200 ranking. This figure also tells us that the system will provide the billboard ranking report through an external system named "ranking report service.
In addition, the use cases not listed in the use case diagram indicate that the system cannot complete the functions. For example, it cannot provide a channel for band managers to listen to songs from different albums on Billboard 200-that is, the system does not reference a use case called "Listen to songs on Billboard 200. This lack is not a trivial matter. The project sponsor can easily see whether the system provides necessary functions by providing clear and brief case descriptions in the use case diagram.
Class Diagram
A class chart shows how different entities (people, things, and data) are related to each other. In other words, it shows the static structure of the system. Class diagrams can be used to represent logical classes. Logical classes are usually the types of things that business personnel talk about-rock bands, CDs, radio dramas, loans, housing mortgages, auto credit, and interest rates. A class chart can also be used to represent an implementation class. An implementation class is an entity processed by a programmer. The implementation class diagram may display some of the same classes as the logical class diagram. However, implementation class diagrams do not use the same attributes for description, because they may have references to things such as vector and hashmap.
Class is described using a rectangle that contains three parts in the class diagram, as shown in figure 2. The top part shows the class name, the middle part includes the class attributes, and the bottom part contains the class operations (or "methods ").
Figure 2: EXAMPLE Class Object in the class diagram
In my experience, almost every developer knows what the class diagram is, but I find that most programmers cannot correctly describe the class relationship. For a class chart like figure 3, you should use a line segment with vertices pointing to the parent class arrow to draw inheritance relationship 1, and the arrow should be a complete triangle. If both classes know each other, you should use a solid line to indicate the association. If only one of the classes knows the association, use an open arrow.
Figure 3: A complete class diagram, including the Class Object shown in Figure 2
In Figure 3, we also see the inheritance and two associations. The cdsalesreport class inherits from the Report class. A cdsalesreport class is associated with a CD class, but the CD class does not know any information about the cdsalesreport class. Both the CD class and the band class know each other, and both classes can be associated with one or more other classes.
A class chart can be integrated with many other concepts, which will be introduced in subsequent articles in this series.
Sequence Diagram
The sequence diagram shows the detailed process of a specific use case (or a part of the use case. It is almost self-describing and displays the call relationships between different objects in the process. It also shows different calls to different objects in detail.
A sequence chart has two dimensions: the vertical dimension displays the message/call sequence in the order of occurrence, and the horizontal dimension displays the object instance to which the message is sent.
It is very easy to draw sequence diagrams. Across the top of the graph, each box (see figure 4) represents the instance (object) of each class ). In the box, the class instance names and class names are separated by spaces, colons, and spaces. For example, myreportgenerator: reportgenerator. If a class instance sends a message to another class instance, draw a line with an open arrow pointing to the receiving class instance and place the name of the message/method on the line. For some particularly important messages, you can draw a dotted line with an open arrow pointing to the launch class instance and mark the return value on the dotted line. As far as I am concerned, I always like to draw a dotted line that includes the returned values. This additional information makes the sequence diagram easier to read.
Reading the sequence diagram is also very simple. Start the "driver" class instance in the upper left corner and read each message. Remember: although the sample sequence diagram shown in Figure 4 shows the returned messages of each sent message, this is only optional.
Figure 4: A sample sequence diagram
By reading the sample sequence diagram in figure 4, you can understand how to create a CD sales report ). The aservlet object indicates the driver class instance. Aservlet sends a message to the reportgenerator class instance named Gen. The message is marked as generatecdsalesreport, indicating that the reportgenerator object implements the message processing program. Further understanding, we can find that the generatecdsalesreport message tag contains a cdid in brackets, indicating that aservlet transmits a parameter named cdid with the message. When the gen instance receives a generatecdsalesreport message, it then calls the cdsalesreport class and returns an acdreport instance. Then, the gen instance calls the returned acdreport instance and transmits parameters to it during each message call. At the end of the sequence, the gen instance returns an acdreport to its caller aservlet.
Note: The sequence diagram in Figure 4 is too detailed than the typical sequence diagram. However, I think it is easy enough to understand, and it shows how to express nested calls. For junior developers, it is necessary to break down a sequence into such details, which helps them understand the relevant content.
Status chart
The status chart indicates the status transition information of a class and its status. Some people may argue that every class has a state, but not every class should have a state chart. The status chart is described only for classes in the "interested" state (that is, classes with three or more potential States during system activity.
As shown in figure 5, the symbolic set of a state chart contains five basic elements: the initial start point, which is drawn using a solid circle; the transition between States is drawn using a line segment with an open arrow; status, it is drawn using a rounded rectangle, a judgment point, which is drawn using a hollow circle, and one or more termination points, which are drawn using a circle containing a solid circle. To draw a state chart, first draw the starting point and a line segment that points to the initial state of the class. The status itself can be drawn anywhere on the graph, and then you only need to use the status conversion line to connect them.
Figure 5: status chart showing various states of a class through a function system
The status chart in figure 5 shows some potential information they can express. For example, we can see that the loan processing system is initially in the loan application state. When the pre-approval process is completed prior to approval, it is either transferred to the loan pre-approved State or to the loan rejected state based on the results of the process. This judgment (which is made during the conversion process) uses a judgment point to represent the hollow circle between the conversion lines. The status chart shows that, without loan closing, the loan cannot go from loan pre-approved to loan in maintenance. In addition, all loans will end with loan rejected or loan in maintenance.
Activity diagram
An activity diagram shows the process control flow between two or more objects when processing an activity. Activity diagrams can be used to model higher-level business processes at the business unit level, or to model lower-level internal operations. Based on my experience, activity diagrams are best suited for modeling high-level processes, such as how the company operates its business or how the business operates. This is because, compared with sequence diagrams, activity diagrams are "not technical enough" in representation, but business-minded people tend to understand them more quickly.
The symbolic set in the activity chart is similar to that in the status chart. Like a status chart, an activity chart starts from a solid circle connected to the initial activity. An activity is represented by a rounded rectangle (the activity name is included in it. An activity can be connected to another activity by converting a line segment or a judgment point. These judgment points are connected to different activities protected by the conditions of the judgment point. Activities in the end process are connected to a termination point (just like in the status chart ). As an option, an activity can be grouped into a swimming Lane. A swimming Lane is used to indicate the objects that actually execute the activity, as shown in 6.
Figure 6: Activity diagram, with two swimming channels, showing activity control for two objects: band manager and reporting tool
Figure (along the arrow): band manager; report tool; select "view band Sales Report"; Retrieve the band managed by the band manager; display report condition selection screen; select the band whose sales report you want to view, search for sales data from the sales database, and display the sales report.
There are two swimming paths in the activity diagram, because two objects control their respective activities: the band manager and the reporting tool. The whole process starts with the selection of the band manager to view his band sales report. Then the report tool retrieves and displays all the bands he manages and asks him to select a band from them. After the band manager selects a band, the report tool retrieves the sales information and displays the sales report. The activity chart shows that the report is the last step in the process.
Component Diagram
The component diagram provides a physical view of the system. Its purpose is to display the dependency of software in the system on other software components (such as library functions. A component diagram can be displayed at a very high level, so that only coarse-grained components are displayed, or at package Level 2.
The modeling of component graphs is best described by examples. Figure 7 shows four components: reporting tool, billboard service, Servlet 2.2 API, and jdbc api. From the reporting tool component to the lines with arrows of the billboard service, Servlet 2.2 API, and jdbc api component, it indicates that the reporting tool depends on the three components.
Figure 7: component diagram shows the dependencies between various software components in the system.
Deployment Diagram
The deployment diagram shows how the software system is deployed in the hardware environment. Its purpose is to show where different components of the system will run physically and how they will communicate with each other. Because the deployment diagram is used to model the physical operation, the production personnel of the system can make good use of the diagram.
The symbols in the deployment diagram include the symbol elements used in the component diagram, and several symbols are added, including the concept of nodes. A node can represent a physical machine or a virtual machine node (for example, a mainframe node ). To model a node, you only need to draw a three-dimensional cube with the node name at the top of the cube. The naming conventions used are the same as those in the sequence diagram: [Instance name]: [instance type] (for example, "w3reporting.myco.com: Application Server ").
Figure 8: Deployment diagram. Since the reporting tool component is drawn inside IBM WebSphere and the latter is drawn inside node w3.reporting.myco.com, we know that users will access the reporting tool through a browser running on the local machine, the browser establishes a connection with the reporting tool through the HTTP protocol on the company's intranet.
The deployment chart in figure 8 shows that you access the reporting tool using a browser running on a local machine and connect to the reporting tool component through the HTTP protocol on the company intranet. The tool runs on the application server named w3reporting.myco.com. This figure also shows that the reporting tool component is drawn inside IBM WebSphere, and the latter is drawn inside the w3.reporting.myco.com node. Reporting tool uses the Java language to connect to its reporting database through the JDBC interface of the IBM DB2 database, and then the interface uses the local DB2 communication mode, communicates with the actual DB2 database running on a server named db1.myco.com. In addition to communicating with the Report database, the report tool component also communicates with the billboard service through soap on HTTPS.
Conclusion
Although this article only provides a brief introduction to the Unified Modeling Language (UML), we encourage you to apply the basic information you have learned from this article to your own projects and study UML in depth. There are already a variety of software tools that can help you integrate UML diagrams into the software development process, but even if there is no automated tool, you can also use the labels, paper, and pen on the whiteboard to manually draw UML diagrams.