[Nine types of UML diagrams]: How to use three layers to draw class diagrams and time sequence diagrams?

Source: Internet
Author: User

 

UML concurrency View: The Interaction between objects. It is dynamic. It can be divided into Sequence Chart, collaboration chart, status chart, and activity chart.

I. Time Sequence diagram:

Sequence digoal: Describes the interaction behavior between objects in chronological order.

Element:

Role: person/System

Object ):

Lifeline: time when an object exists

Focusofcontrol: indicates the time period symbol.

Message ):

Synchronousmessage: waits for the result.

Asynchronousmessage: does not wait for the result.

Returnmessage: returned from a process call

Self-associated message: calls/mutual calls of methods in a unified object.

Ii. How to draw a sequence chart?

How is a sequence chart drawn? What is the relationship between it and the class chart? How can I draw a sequence chart and connect it to a three-tier architecture? The following content will answer all your questions:

Use onePure Layer 3Example descriptionSequence ChartHow to ImplementSystem LoginOf:

1. First, draw a class chart:

Role of the U layer:Input + display + simple judgment, such as the frmlogin class

Role of layer B:BusinessLogic (it is important to understand what business is, and to draw a sequence chart !) Is a unique function in the system. For example, loginbll

Role of layer d: Adds, deletes, modifies, and queries data in tables in the database. For example, userdal and userjobrecorddal.


2. Second, draw a sequence diagram: (Note: A transmits a message to B = A calls B's method)

PS:The message passed in the figure is parsed as follows:

The frmlogin class belongs to the U layer., The parsing is as follows:

Isempty: determines whether it is empty

Isrightful: judge the validity of the input (whether it contains invalid characters)

The loginbll class belongs to layer B and is parsed as follows:

Login (username, password): log in and pass the username and password entered by the user.

Queryuserbyusername (username): transmits the username passed by the U layer to the D layer to obtain the user information (password and status) of the system ).

Isempty: determines whether the obtained information is null. If it is null, the user name does not exist in the database, and the login fails.

Ispasswordright: Determine whether the user name and password match.

Isonduty: determines whether the user is in the computer status. If the user is already in the computer status, secondary login is not allowed. 

The userdal and userjobrecorddal classes belong to layer D and are parsed as follows:

Queryuserbyusername (username): query by user name. The user table contains username information.

Modifyuser (userstate): If logon is successful, the user table is modified. The status of this username is "on duty ",

Adduserjobrecord: Add a machine record about this username in the userjobrecord table.

 

3. How do I determine what classes should be put on the layer-3?

1. entity: if there are n tables in the database, there are N classes in the Entity layer, which correspond to the tables in the database one by one.

2. layer D: layer D adds, deletes, modifies, and queries databases. layer D has N classes, corresponding to N tables, and adds, deletes, modifies, and queries respectively. Of course, you can also add static data, enumeration type ...... Object Class.

3. U layer: It mainly includes form classes, M forms, and m classes in the U layer.

The figure is as follows:

So how should classes in layer B be divided? There are two partitioning methods:

1. Classes in layer B can be derived from the functions/Use Cases of the system. For example, logging on to login is a user's function. Therefore, you can write the loginbll class in layer B. This division is characterized by the number of use cases and the number of classes in layer B. The classification granularity of the class is relatively small, the method of the class is relatively small, and the function responsibility is single. However, the number is large.

2. Another method is to export data from layer D, that is, the number of classes in layer D and the number of classes in layer B, that is to say, classes in layer B correspond to classes in layer D in a one-to-one relationship. This division method is characterized by the fact that the number of classes in layer B is relatively small and the method is relatively large, which violates the single responsibility principle.

The two methods have their own advantages and disadvantages and are for reference only. If you have any suggestions, please refer to them.

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.