A comprehensive example of UML easy entry in Unified Modeling language

Source: Internet
Author: User
Tags abstract contains insert query

"For example, than also" ("Wen"), this series will give a complete example of modeling using UML, comprehensive application of the knowledge learned before, to "give the rest of the case" (Yuan Liu 壎 "seclusion of the Ouyang") purposes.

In our country ten years ago ATM (Automatic teller machine) is a very new thing, now in the streets of cities everywhere. We also often deal with ATM in our daily life. In this chapter we will take the simplified ATM system as an example to apply the use case diagram, class diagram, sequence diagram, state diagram, activity diagram and collaboration diagram knowledge in the previous chapters to this example.

  5.1 Use case diagrams

Participant "Bank savers" and ATM machines. The simplified ATM machine only has withdrawals, deposits and other functions. The remaining features are not described in detail.


Figure 5.1 Automatic Teller machine (ATM) system use case diagram

Bank depositors complete withdrawals, deposits and other operations on ATM machines.

   5.2 Class Diagram

The banking system class diagram shown in Figure 5.2 and figure 3.5 are similar, except that workers are replaced with ATM. The entire banking system consists of account banks, bank depositors, and ATM systems.

Many individual accounts comprise the account library. Account has the account type, account number, balance three attributes, all private, the type is char,int,double. Six operations were Settype, GetType, Getaccountnumbe, Setaccountnumbe, Caculatebalance, GetBalance, Except caculatebalance for protected, the rest are public.

Settype Set Account type, return type is void, parameter type is char, enter account type.

GetType gets the account type, the return type is char, and no parameters.

Setaccountnumbe Set account number, return type void, parameter type int, enter account number.

Getaccountnumbe Gets the account number, returns the type int, and no parameters.

Caculatebalance calculates the balance, the return type is void, the parameter is double, the first parameter is the input access amount, and the second parameter is the deposit balance, both for input and for output.

GetBalance Gets the account balance, returns the type double, and no parameters.

Many bank savers form a library of savers. The ATM system contains many ATM machines. Bank savers and ATM machines two classes contain which properties, which operations, their visibility and the return type of the operation, the number of parameters, and the type of parameters are clear from the class diagram. More attributes and operations can be added to make this class diagram more detailed and complete, so that each member of the participating project can understand the structure of the entire design class without ambiguity. Also for a real banking system, this class diagram is too simple. such as the account type we can first define an abstract class that contains the most basic attributes and operations of an account. Some operations are first defined as abstract, such as the calculation of the balance. And then inherit this abstract class, we can have saving account and checking account, and so on. Different accounts have different methods of calculating the balance, we can add the specific algorithm. For different accounts may also have some of its specific operations, we can also add, such as saving account in the amount of money can enjoy the discount discount tickets. The class diagram can not only make the designer express their design intention clearly, but also help the group to organize their own ideas, enrich and optimize their own design.


Figure 5.2 Banking System class diagram

   5.3 Sequence Diagram

Figure 5.3 Describes the flow of information when a customer withdraws money from an ATM machine. In order of time. Because it's just an example, the whole process is a process without any failures, and only draws to the end of the withdrawal. With this diagram, we can see how the message interacts with different objects in the system.

Through the flow chart we can see very clearly how the system works, the information and control between the parts of the system is sent, the whole process is reasonable. The flow chart has played a very good role in our design. Note that none of the lifeline terminals in this diagram has an "X", because the process has not yet encountered an object life end. When an object's life ends, it is necessary to draw "X" at the corresponding lifeline terminal, indicating that the object was destroyed at this time.

First, a bank depositor inserts an ATM card into the card reader, the reader will pass the information to the customer management, the customer management put forward the query password, the display part will enter the password request to display .... Because this sequence diagram is longer, and very clear, even beginners are easy to read, here is not to do too much interpretation of this map.


Figure 5.3 ATM withdrawal sequence diagram

  5.4 State diagram

Figure 5.4 describes several states that customers will experience when they operate on an ATM machine, and the conditions for transitions between various states. Because it is a simplified example, in addition to waiting for the customer to insert the magnetic card starting state and end the service termination status, the customer will be in the input password, select the type of service, deposit and withdrawal of four states.


Figure 5.4 ATM State diagram

After inserting the magnetic card to enter the password state, when the password is entered correctly enter the choice of service type status, when the input password is incorrect, stay in the original state, but if three times incorrect, service end. After entering the choice of service type, depending on the choice, the customer can enter the deposit and withdrawal status. After the deposit and withdrawal, customers can choose to end the service to the final state, or choose to continue the service to select the service type status.

Through the state diagram we can understand without ambiguity how each active role is converted under different conditions, what is the condition of the conversion, whether there will be deadlock phenomenon, whether the conditions are not considered comprehensive, whether there is a state can not be achieved. State diagrams can help us find problems and correct them in time.

   5.5 activity diagram

Figure 5.5 refers to Randy Miller's "a hands-on Introduction for developers" article, 5.3 figure in the customer management and management of things corresponding to the 5.5 figure in the bank, Figure 5.3 Card reader, display, Input devices and cash registers correspond to the ATM Machina in Figure 5.5, bank savers are customer. The meaning of the expression of the activity diagram and the sequence diagram is very close at first. But we can note that sequential graphs focus on the order of time, and activity diagrams focus on the mutual constraints between the parts, for some parallel activities can be effectively expressed. For example, in the 5.5 Figure fork and join, we can clearly see some of the existence of parallel activities.

This activity diagram starts with a customer insertion card and ends with a customer pickup card. We can see that the focus of the activity diagram is not in the chronological order, but we can also get the time information.


Figure 5.5 ATM banking system activity diagram

   5.6 Collaboration Diagram

In the fourth chapter, we know that collaboration diagram and sequence diagram can be converted without information loss, but their emphasis is different. Sequential graphs focus on the time sequence of message passing between objects, and the collaboration diagram focuses on the static connection between objects. Figure 5.6 Converts the 5.3 figure into a collaboration diagram.

1. Insert ATM Card

2. Accept ATM Cards

3. Query password

4. Display input Password request

5. Enter password

6. Password delivery

7. Request Confirmation Password legality

8. Confirm password Legality

9. Ask Service category

10. Show input Service Service category requests

11. Enter a withdrawal request

12. Withdrawal request

13. Inquire about the amount of withdrawals

14. Show input Amount Request

15. Enter withdrawal amount

16. Transfer the amount of withdrawals

17. Ask for confirmation of withdrawal amount

18. Show Confirmation Amount Request

19. Enter confirmation

20. Delivery Confirmation Information

21. Amount legality Confirmation Request

22. Confirmation of amounts and legal

23. A request for a note

24. Calculate Account Balances

25. Money-Issuing

26. Take notes

27. Transfer balance and ask if additional services are required

28. Displays the account balance and prompts you to select the following services


Figure 5.6 ATM System Collaboration diagram

We can see from the graph that the role of the collaboration diagram and the object of the sequence diagram are one by one corresponding, while the collaboration on each object on the collaboration graph and the message passing on the order graph are one by one corresponding.



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.