System Analysis and Design: Interpreting Activity and Sequence Diagrams
Tags: beginners, design, diagrams, school
Published: 2021-05-30 22:16:14

For my assignment this week in System Analysis and Design I was tasked with analyzing and creating UML diagrams.  The diagrams provided below are a UML activity and sequence diagram for an ATM.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gswl7ov2x6f6eseukxnc.png)

Both diagrams describe the same use case but from different viewpoints.  Activity diagrams display the primary activities and the relationships among the activities in a process.  Actions and activities are done due to business rules or requirements.  They represent actions that are performed automatically by a computer or manually by a human.  These are shown in the diagram by the rounded edged rectangles.  Object nodes are actions when objects are modified and are represented by diamonds.  Arrows show the flow of the processes or decision making in the use case.  In the ATM example, the process verifies the PIN provided.  If it is the wrong PIN, it terminates otherwise the system then asks for an amount of cash to dispense.  If the amount is available, the cash will be dispensed otherwise the process skips that step and goes straight to generating a receipt.  Once the receipt is generated a paper copy is printed and the process ends. 

Sequence diagrams are a behavior model that illustrate the objects used and the messages that pass between them for that specific use case.  The square boxes at the top are actors which can represent a person or system that gains from the use case.  The vertical rectangles are an execution occurrence which denotes when an object is sending or receiving a message.  The arrows connecting the execution occurrences are messages.  Full arrows are messages being sent with dashes indicating that the message is being received.  In the context of the ATM sequence diagram, the user object is interacting with the ATM and the ATM is interacting with the bank.  When the user inserts their card, the ATM responds by asking for their PIN.  The PIN is inserted, and the ATM then sends a message to the bank to verify the PIN.  The bank lets the ATM know the PIN is valid and then the ATM completes the message asking for the amount to be dispensed.  Once that amount is entered then the cash is dispensed. 

Both diagrams describe one basic design for the use case.  By analyzing the design, I can identify at least two deficiencies in the logic or functionality.  Looking at the activity diagram, when the decision is made on whether there is enough cash in the account to dispense the amount asked for it completes the task and ends the process.  If the user does not have enough cash a receipt is printed and the process terminates.  This is not useful if the user wants to change the amount to something that is available.  At the decision where the user inputs the amount they want dispensed there should be a branch to an activity that displays an error message if not enough funds are available.  In-between dispense cash and generate receipt ideally there would be an action that asks if they are finished with the transaction.  The error message action then leads to this as a way to loop back to correct the amount inputted if the user wants.  This action will then lead to a decision node that goes to generate receipt if yes is chosen otherwise it loops back to ask the amount to be dispensed.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmz1dplijrahnnkfjhyb.png)

For the sequence diagram, it is lacking a confirmation between the ATM and the bank that verifies enough funds are in the users account before dispensing the cash.  At the execution occurrence in-between enter amount and dispense cash there should be a set of messages to the bank and back to the ATM.  The message to the bank is “Verify enough funds available” and the response should be “Funds valid”.  If you liked this post please make sure to like and comment down below!

Source:

1. Dennis, A., Wixom, B. H., & Tegarden, D. (2011). Systems analysis and design with Uml. Wiley.