UML Practice----Use case diagrams, Sequence diagrams, state diagrams, class diagrams, Package diagrams, collaboration diagrams __UML

Source: Internet
Author: User

The key to the processing of object-oriented problem is the modeling problem. Modeling can abstract many important details in a complex world. Many modeling tools encapsulate UML (that is, unified modeling language™), a course designed to showcase the highlights of UML.

UML has nine modeling icons, namely: Use case diagram Class Diagram object graph order diagram Collaboration diagram state diagram activity diagram Component Diagram configuration diagram

Some sections of this course contain a page link to the details of these diagrams. And each part has a little problem, and test your understanding of this part.

why UML is important.

To answer this question, let's look at the construction industry. The designer designed the house. The builders used the design to build the house. The more complex the building, the more important the communication between the designer and the builder. The blueprint becomes a required course for designers and builders in this industry.

Writing software is like building buildings. The more complex the system, the more important the communication between the people involved in writing and configuring the software. In the past decade, UML has become a "blueprint" for analysts, designers and programmers. Now it has become a part of the software industry. UML provides a common language between analysts, designers, and programmers in software design.

UML is applied to the solution of object-oriented problem. To learn UML must be familiar with the fundamental principles of object-oriented problem-solving-all from the construction of the model. A model is the abstraction of a fundamental problem. Domain domains are the real world where the problem is.

The model is composed of object objects, which interact with each other by sending message messages to each other. Remember to think of an object as "alive". Objects have things they know (attributes attributes) and things they can do (acts or operations behaviors or operations). The value of the property of the object determines its status state.

The class classes is the "blueprint" for the object. A class encapsulates attributes (data) and behavior (methods or functions) in a separate entity. An object is an instance of a class instances.

use case diagram

Use case diagram diagrams describes the impression of the system as an external observer's perspective. Emphasize what this system is and not how it works.

A use case diagram is closely related to the plot. Plot scenario refers to what happens when someone interacts with the system. Below is the plot of a hospital clinic.

A patient calls the clinic to make an appointment for a yearly checkup. The receptionist finds out the most recent unscheduled time on the booking book and remembers the appointment record for that time. ”

Use cases are the sum of a series of episodes that are designed to accomplish a job or achieve a purpose. Character actor is the person or thing that launches events related to this work. The role simply acts as a person or object. The following figure is a clinic make appointment use case. The role is the patient. The relationship between roles and use cases is Communication Contact Communication Association (or simply Communication communication)

A role is a human icon, a use case is an ellipse, and communication is a line that connects roles and use cases.

A use case diagram is a collection of roles, use cases, and the connections between them. We have made make appointment as part of a graph that contains four roles and four use cases. Note that a single use case can have multiple roles.

Use case diagrams are useful in three areas. Determine the characteristics (requirements). When the system has been analyzed and molded, new use cases generate new requirements for customer communications. Using use case diagrams can easily represent the relationship between developers and customers. Generate Test Cases. The plot of a use case may produce a batch of test cases for these episodes.

class Diagram

Class Diagram class diagram represents the system by displaying the system's classes and the relationships between those classes. Class diagrams are static-they show what can have an impact but won't tell you when the impact is.

The following is a class diagram of a customer's model for ordering goods from a retailer. The Center class is order. It is the customer and payment who purchased the goods. There are three forms of payment: Cash,check, or credit. The order includes OrderDetails (line item), each of which is attached to the item.

The symbol of a UML class is a box that is divided into three blocks: class name, attribute, and operation. The name of an abstract class, like payment, is italic. The relationship between classes is a connection line.

There are three kinds of relationships in class diagrams. The association association-represents the relationship between two kinds of instances. An association is used when an instance of a class must use an instance of another class to complete the work. In the diagram, the association is represented by a connection between two classes. Aggregation aggregation-A special relationship when a class belongs to a container. Aggregation is a line with a diamond that points to a class with a whole character. In our diagram, the order is the OrderDetails container. Generalization generalization-an inheritance line that points to another class as a superclass. A generalization relationship points to a superclass with a triangle. Payment is a super class of Cash,check and credit.

An association has two trailing ends. Each end can have a role name roles name to describe the role of the association. For example, a OrderDetail instance is a project of an order instance.

The directional navigability arrows on the association indicate the direction of the Association pass or query. The OrderDetail class can query for his item, but it cannot be queried in turn. The arrow direction can also tell you which class has the implementation of the Association; that is, OrderDetail owns the item. The Association of Arrows without directionality is bidirectional.

The number at the end of the association indicates that an instance of the other side of the association can correspond to the number of instances of the numeric end, and in this way expresses the multiplicity multiplicity of the association. A variety of numbers can be a separate number or a range of numbers. In the example, there is only one customer per order, but a customer can have any number of more.

The following table gives the most common examples of diversity.

Diversity meaning
0..1 0 or 1 instances. N.. The M symbol indicates that there are n to M instances
0..* or * There is no limit on the number of instances (including none).
1 Only one instance
1..* At least one instance

Each class diagram includes classes, associations, and multiplicity representations. directionality and roles are optional items to make the diagram clearer.

packages and Object graphs

To simply represent complex class diagrams, you can combine classes into package packages. A package is a collection of logically related components on UML. The following diagram is a business model that combines classes into packages.

dependencies relationship. If another package B change may result in a change in package A, package a relies on package B.

The package is represented by a rectangle with a small label above it. The package name is written on the label or inside the rectangle. The Attunement line arrows indicate dependency

Object diagrams is used to represent an instance of a class. They are useful in interpreting small problems of complex relationships, especially when it comes to recursive relationships.

This class shows that a university department can include many other departments.

This object illustrates an instance of the class diagram above. A lot of concrete examples are used.

The instance name in UML is underlined. As long as the meaning is clear, the class or instance name can be omitted from the object graph.

The rectangles for each class diagram correspond to a single instance. The UML diagram that is highlighted in the instance name. The name of a class or instance may be an elliptical object diagram as long as the meaning of the diagram is still clear.

Order Diagram

Class diagrams and object graphs are views of the static model. The interaction diagram is dynamic. They describe the interaction between objects.

A sequence diagram represents an interactive relationship as a two-dimensional graph. The portrait is the timeline, and the time extends downward along the vertical bar. The transverse axis represents the metamodel roles of individual objects in collaboration. The class meta role is represented by a lifeline. When an object exists, the role is represented by a dotted line that, when the object's procedure is active, is a two-way line.

Messages are represented by arrows from the lifeline of one object to the lifeline of another object. Arrows are arranged from top to bottom in the graph in chronological order.

Collaboration Diagram

A collaboration diagram is also an interactive diagram. They also pass the same message like a sequence diagram, but they don't care when the message is delivered and only the role of the object is concerned. In a sequence diagram, the role of an object is placed above and the message is a connector.

The object role rectangle is marked with a class or object name (or both). The class name is preceded by a colon (:).

Each message in a collaboration diagram has a serial number. The number of top-level messages is 1. Messages of the same rank (that is, messages in the same call) have the same number prefix, and then add a suffix to the order in which they appear, 1,2, and so on.

State Diagram

objects have behavior and status. The state of an object is determined by the current action and condition of the object. The state diagram Statechart diagram shows the possible state of the object and the transitions caused by the state change.
Our model diagram establishes a bank's online login system. The login process involves entering a valid password and personal account and submitting it to the system for verification information.

The login system can be divided into four non-overlapping states: Getting SSN, getting PIN, validating, and rejecting. Each state has a complete set of transfer transitions to determine the order of the States.

The state is represented by rounded rectangles. The transfer is represented by a line with an arrowhead. The event or condition that triggers the transfer is written next to the arrow. There are two self shifts on our diagram. One is in the getting SSN and the other is on the getting PIN.

The initial state (the Black circle) is the virtual start of the action. The end state is also the virtual end of the action.

When an event or condition triggers an action, it is represented by (/action). When entering the validating state, the object does not wait for external events to trigger the transfer. Instead, it produces an action. The result of the action determines the state of the next step.

activity Diagram

Activity diagram Active diagram is a very special flowchart. There is a relationship between the activity diagram and the statechart diagram. The state diagram focuses on the objects in the process, while the activity diagram concentrates on an individual process action flow. The activity diagram tells us the dependencies between activities.

For our example, we use the following procedure.

"To withdraw money from ATM. ”

This activity has three categories of customer, ATM and Bank. The whole process begins with a black circle and ends with a black and white concentric circle. The activity is represented by a rounded rectangle.

Activity diagrams can be decomposed into many object lane swimlanes to determine which objects are responsible for those activities. Each activity has a separate transfer transition connection to this other activity.

The transfer May branch branch into more than two mutually exclusive transfers. The protection expression (in []) indicates that the transfer is drawn from a branch. The merge merge at the end of a branch and branch is represented in a diamond in the diagram.

The transfer can also decompose fork into more than two concurrent activities. Decomposition and the thread-binding join at the end of the decomposition are represented in a rough black line in the diagram

components and configuration diagrams

Component component is a code module. A component diagram is a physical implementation of a class diagram.

The configuration diagram deployment diagrams is the display software and hardware configuration.

The following configuration diagram illustrates the relationship between the software and hardware components related to real estate transactions.

The physical hardware uses the node nodes representation. Each component belongs to one node. The component is represented by a rectangle with two small rectangles in the upper-left corner.

Original link: http://edn.embarcadero.com/article/31863

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.