UML Basics: Unified Modeling Language Introduction

xiaoxiao2021-03-06  96

UML foundation:? Unified modeling language profile

By the 21st century - accurately said that in 2003, UML has gained an industry recognition. In the resume I have ever seen, 75% claims to have UML knowledge. However, after interview with the vast majority of job seekers, it can clearly see that they don't really understand UML. Typically, they use UML as a term or a semi-solving of UML. Everyone lacks this situation of UML to promote this fast entry article about UML 1.4. When reading this article, you don't have enough knowledge to claim that you have mastered UML on your resume, but you have further drilled the language.

Some background knowledge

As mentioned earlier, the original meaning of UML is to be a standard unified language that enables IT professionals to model computer applications. The main founders of UML are Jim Rumbaugh, Ivar Jacobson and Grady Booch, who initially had their own modeling methods (OMT, OOSE, and BOOCH), competition between each other. In the end, they jointly created an open standard. (I sound is not very familiar? This phenomenon is similar to J2EE, SOAP and Linux.) UML is one of the reasons why the "standard" modeling language is that it is independent of programming language. (IBM Rational's UML modeling tool is widely used in J2EE and .NET development.) Moreover, the UML symbol set is just a language rather than a methodology. This is important because language is different from ways, it can easily adapt to any company's business operation mode without any changes.

Since UML is not a methodology, it does not require any formal working product (ie IBM Rational Unified Process® "" Workpiece "as defined in terms). Moreover, it also provides a variety of model descriptions (DIAGRAM), which makes it easier to understand when using these pictures in some given methodology. UML's connotation is not just these model descriptions, but for entry, these images provide a good introduction to the basic principles behind this language and their usage. By putting standard UML patterns into your work products, proficient in UML is easier to join your project and quickly enter the role. The most commonly used UML diagrams include: use case diagrams, class diagrams, sequence diagrams, state diagrams, active diagrams, components, and deployment diagrams.

In-depth discussion details of each type of diagram have exceeded the scope of this entry. Therefore, only a brief description of each type of diagram is given below, and more detailed information will be discussed in future articles.

Use case

A functional unit provided by the system is described with example. The main purpose of the example is to help the development team understand the functional requirements of the system in a visual manner, including the "role" based on the basic process (ACTORS, other entities with the system interaction), and the internal use of the system relationship. Modal examples generally represent the tissue relationship of the use case - either all the use of the entire system, or a set of cases with functions (eg, all security management related use cases). To display an ellipse on the use case, you can draw an ellipse, then place the name of the usage in the center of the ellipse or the intermediate position below the ellipse. To draw a role (representing a system user) on the case map, you can draw a humanoid symbol. The relationship between roles and use cases uses a simple line segment, as shown in Figure 1.

Figure 1: Illustration example

Image (from top to bottom): CD sales system; view the sales statistics of the band CD; the band manager; see the Billboard 200 leaderboard report; record manager; view sales statistics for specific CDs; retrieve the latest Billboard 200 leaderboard report; line The example of the list reporting service example is usually used to express system or system category. As shown in Figure 1, it is easy to see the functions provided by the system. This system allows the band manager to view the sales statistics report of the band CD and the Billboard 200 leaderboard report. It also allows a record manager to view a sales statistical report for a particular CD and the report of these CDs in the Billboard 200 list. This picture also tells us that the system will provide Billboard leaderboard reports through an external system called "Leaderboard Report Services".

In addition, in the example of the example, the use cases that are not listed indicate the functionality that the system cannot be completed. For example, it does not provide the band manager to listen to the songs in the different albums in Billboard 200 - that is, the system does not quote a use case called "Listening to Billboard 200". This lack is not a small thing. In the case of the example, it provides a clear, brief use example description, and the project sponsors can easily see if the system provides a necessary function.

Class Diagram

Class diagrams indicate 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 talked about business people - rock band, CD, radio drama; or loans, housing mortgage, car credit, and interest rates. The class diagram can also be used to represent the implementation class, and the implementation class is the entity processed by the programmer. Implementation class diagrams may display some of the same classes with logical class diagrams. However, implementation class diagrams do not describe the same properties because it is likely to have references to things such as Vector and HashMap.

The class is described in the class diagram to describe the rectangle containing three parts, as shown in Figure 2. The uppermost part displays the name of the class, the middle part contains the properties of the class, the bottom part contains the operations of the class (or "method").

Figure 2: Examples objects in class diagrams

According to my experience, almost every developer knows what this class is, but I found that most of the programmers cannot correctly describe the relationship. For class diagrams like Figure 3, you should use a line segment with a vertex to point to the parent class to draw inheritance 1, and the arrow should be a complete triangle. If both classes know each other, the solid line should be used to represent the associated relationship; if only one of the classes know the association, the open arrow is represented.

Figure 3: A complete class diagram, including the class object shown in Figure 2

In Figure 3, we also see inheritance relationships and two associated relationships. 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. The CD class and the BAND class know each other each other, and the two classes can be associated with one or more other classes.

A class diagram can integrate many other concepts, which will be introduced in subsequent articles in this series.

Sequence Diagram

The sequence diagram shows the detailed flow of the specific use case (or part of the use case). It is almost described, and it shows the call relationship between different objects in the process, and it can also display different calls to different objects in detail.

The sequence diagram There are two dimensions: the vertical dimension displays the sequence of messages / calls in the time of occurrence of the occurrence; the horizontal dimension displays the object instance sent to the message.

The drawing of the sequence diagram is very simple. Express the top of the diagram, each box (see Figure 4) represents an instance of each class (object). In the box, class instance names and class names are separated by spaces / colons / spaces, for example, MyReportGenerator: ReportGenerator. If a class instance sends a message to another class instance, a connection with an open arrow that points to the receiving class instance is drawn, and the name of the message / method is placed on the connection. For some particularly important messages, you can draw a dotted line with an open arrow pointing to the initiating instance, labeled the return value on the dotted line. As far as I said, I always like to draw a dotted line including the return value, which allows the sequence diagram to read it easier to read. Reading sequence diagrams are also very simple. Start with the "Drive" class instance of the starting sequence of the upper left corner, then read it down in each message. Remember: Although the example sequence diagram shown in FIG. 4 shows the return message of each sent message, it is only optional.

Figure 4: One example sequence diagram

By reading the example sequence diagram in Figure 4, you can understand how to create a CD sales report (CD Sales Report). The ASERVLET object represents the driver instance. ASERVLE sends a message to the ReportGenerator class instance named Gen. This message is labeled GenerateCDSalesReport, indicating that the ReportGenerator object implements this message handler. Further understanding can be found that the GenerateCdsalesReport message tag includes a CDID in parentheses, indicating that the ASERVLET passes a parameter named CDID with the message. When the GEN instance receives a GenerateCDsalesReport message, it will then call the CDSalesReport class and return an instance of ACDREPORT. The GEN instance is then called to the returned ACDREPORT instance, and the parameters are passed when each message is called. At the end of this sequence, the GEN instance returns an ACDREPORT to its caller ASERVLET.

Note: The sequence diagram in Figure 4 is too detailed relative to a typical sequence diagram. However, I think it is enough to understand enough, and it shows how to indicate nested calls. For primary developers, it is sometimes necessary to decompose a sequence to this level of detail, which helps them understand the relevant content.

State diagram

The state diagram represents the different status of a class and the status conversion information of the class. Some people may argue that each class has a state, but not each class should have a state diagram. Only the state diagram is performed only for the class of "interested" state (that is, the class having three or more potential states during system activity) is described.

As shown in FIG. 5, the symbol set of the state diagram includes 5 basic elements: the initial starting point, it uses a solid circle to draw; the transition between states, it uses a line segment with an open arrow to draw; state, it uses rounded rectangles To draw; judgment point, it uses a hollow circle to draw; and one or more termination points, they use the internal contained circle to draw. To draw a status diagram, first draw the starting point and a conversion line segment pointing to the initial state of this class. The status itself can be drawn anywhere on the graph, and then connect them simply using the status conversion line.

Figure 5: Show the state diagram of various states through a function system

The state diagram in Figure 5 shows some of the potential information they can express. For example, it can be seen from which the loan processing system is originally in the Loan Application status. When the pre-approval process is completed, depending on the result of the process, or go to the Loan Pre-Approved state, or go to the Loan Rejected state. This judgment (which is made during the conversion process) uses a judgment point to represent the hollow circle between the conversion lines. By this state map, it is known that if there is no Loan Closing state, the loan cannot enter the Loan In Maintenance state from the Loan Pre-AppROVED state. Moreover, all loans will end in the Loan Rejected or Loan In Maintenance state. Activity map

The active diagram represents the process control flow between two or more class objects when processing a certain activity. Active map can be used to model a higher level of business processes at the level of the business unit, or modeling low-level internal class operations. According to my experience, the activity map is best suited to model the higher level process, such as how the company is currently working, or how the business is working. This is because the active map is "less technical" than the sequence diagram, but people with business head tend to understand them more quickly.

The symbol set of the active diagram is similar to the symbol set used in the state diagram. Like a state diagram, the active map will start from a solid circle connected to the initial activity. The activity is represented by a rounded rectangle (included in the name). Activity can be connected to other activities through the conversion line segment, or connect to the judgment point, which connects the different activities protected by the criterion. The activity of the end process is connected to a termination point (just like in the state diagram). As an option, the activity can be packet into a swimlane, a lane is used to represent an object actually performing the activity, as shown in Figure 6.

Figure 6: Activity diagram, with two lanes, representing the activity control of two objects: Band Manager, and Report Tool

Image (along the arrow): Band Manager; Reporting Tool; Select "View the Sale Report of the Band"; retrieve the band management of the band manager; display the report condition selection screen; choose the band to view the sales report; from the sales database Search sales data; show the sales report.

There are two lanes in the event, because there are two objects to control their activities: the band manager and reporting tool. The whole process first starts from the band manager to check his band sales report. Then report the tool to retrieve and display all the bands that he managed and ask him to choose a band. After the band manager chooses a band, the report tool will retrieve sales information and display the sales report. The activity map shows that the display report is the last step in the whole process.

Component map

Component diagram provides physical views of the system. Its use is the dependency of software in the system to other software components (eg, library functions). The assembly map can be displayed at a very high level, thereby only displaying the coarse particle size, or can be displayed on the component packet level 2.

The modeling of the component map is best suited to describe it by example. Figure 7 shows 4 components: Reporting Tool, Billboard Service, Servlet 2.2 API, and JDBC API. From the Reporting Tool component point to the line segment of the Billboard Service, Servlet 2.2 API, and JDBC API components, indicating that Reporting Tool depends on the three components.

Figure 7: Component diagram shows the dependencies of various software components in the system

Deployment diagram

The deployment diagram indicates how the software system is deployed into a hardware environment. Its use is to show that the components of the system will be physically run, and how they will communicate with each other. Because the deployment diagram is modeling the physical operation, the system producers can take advantage of this picture. The symbols in the deployment diagram include the symbol elements used in the component diagram, and also add several symbols, including the concept of nodes. A node can represent a physical machine or represent a virtual machine node (for example, a large unit node). To model the node, just draw a three-dimensional cube, the name of the node is located at the top of the cube. The naming convention used is the same in the sequence diagram: [Example Name]: [Instance Type] (for example, "w3reporting.myco.com: Application Server").

Figure 8: Deployment diagram. Since the Reporting Tool component is drawn inside IBM WebSphere, the latter is drawn in the node w3.reporting.myco.com, so we know that users will access the Reporting Tool through the browser running on the local machine, the browser passes the company Intranet The HTTP protocol is established with the Reporting Tool

The deployment chart in Figure 8 shows that the user accesses the Reporting Tool using the browser running on the local machine and connects to the Reporting Tool component through the HTTP protocol on the company Intranet. This tool actually runs on Application Server named w3reporting.myco.com. This figure also shows that the Reporting Tool component is drawn inside the IBM WebSphere, the latter to draw inside the w3.reporting.myco.com node. Reporting Tool Connects to its report database using the Java language JDBC interface through the IBM DB2 database, and then the interface uses local DB2 communication methods, communicating with actual DB2 databases running on servers named DB1.MYCO.COM. In addition to communication with the report database, the Report Tool component also communicates with the Billboard Service on HTTPS.

Conclude

Although this article only provides a brief introduction to the unified modeling language UML, you still encourage you to apply basic information learned from here to your own project, and more deeply drilled UML. There are already a variety of software tools to help you integrate UML diagrams to software development, but you can also use tags or paper and pen to manually draw UML images even if you don't have automated tools. .

Note

1. ?????? For more information on inheritance and other object-oriented principles, see: http://java.sun.com/docs/books/tutorial/java/concepts/inheritance.html

2. ?????? "Component Package Hierarchy" refers to a namespace such as .NET (such as system.web.ui) or Java package (such as Java), in a way that is independent of programming language. Util) This type of container level.

Reference

http://www.uml.org - Official UML Web Site.

http://www.rational.com/UML/Resources/Documentation/index.jsp - A variety of different versions of the specific UML specification.

Http://www.rational.com/rose - Information about IBM Rational Rose? This business UML modeling tool.

Http://www.rational.com/xde - About IBM Rational XDE? This is a commercial UML modeling tool with IBM's Eclipse development platform.

http://argouml.tigris.org - About ARGO UML This open source UML modeling tool built with Java. http://uml.sourceforge.net/index.php - About UMBRELLO UML MODELLER This open source UML modeling tool for KDE is used.

?

转载请注明原文地址:https://www.9cbs.com/read-123162.html

New Post(0)