Itc 505

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Information

Technology
Centre

ACTIVITY DIAGRAM AND STATE CHART DIAGRAM

Submitted to: Sir Zeeshan Nizamani

Subject: OOAD

Course Code: ITC:505

Submitted By:
SHAMAN ALI MAHAR | 2K21-IT-188
Differentiate between activity diagram and state chart diagram with examples.

Activity diagrams and state chart diagrams are both types of behavior diagrams used in
software engineering and system modeling. While they both describe the behavior of a
system, they have different focuses and are used in different contexts. Here's a
breakdown of each with examples:

1. Activity Diagram:
• Focus: Describes the flow of activities or actions within a system or
process. It emphasizes the sequence of actions, decision points, and
concurrency.
• Components:
• Activities: Represented by rounded rectangles, they denote actions
or steps in the process.
• Control Flows: Represented by arrows, they show the flow of
control from one activity to another.
• Decision Nodes: Represented by diamonds, they depict points
where the flow of control can diverge based on conditions.
• Usage: Used to model the workflow of a system, business processes, or
use cases.
• Example: Consider the process of online shopping. An activity diagram
can illustrate the steps involved, such as browsing products, adding items
to the cart, entering shipping details, and making payment. Decision
points might include checking for item availability or choosing a payment
method.
Modeling a Vending Machin by an Activity
Diagram
The given Activity Diagram represents the flow of events in a vending
machine system. It starts with the start node, and the user is first required to
insert coins. The diagram then shows an if condition to check if the user has
inserted sufficient funds. If the funds are sufficient, the user is allowed to select
a product.
The next if condition checks if the selected product is available. If the product
is available, the vending machine dispenses the product, and the diagram
shows a transition to the stop node, indicating that the transaction is
complete. If the selected product is not available, the vending machine
refunds the coins and then transitions to the stop node.
If the user does not insert sufficient funds, the vending machine directly
refunds the coins and transitions to the stop node. In either case, the
transaction is complete, and the user can collect their refund if applicable.

State Chart Diagram:


• Focus: Describes the various states that an object or system can be in and
the transitions between these states. It emphasizes the dynamic behavior
of an entity.
• Components:
• States: Represented by rounded rectangles, they denote the
conditions or situations in which an object can exist.
• Transitions: Represented by arrows, they show the movement of an
object from one state to another triggered by events or conditions.
• Events: Triggers that cause transitions between states.
• Usage: Used to model the behavior of individual objects or system
components over time.
• Example: Consider a traffic light system. A state chart diagram can
illustrate the different states of the traffic light (e.g., green, yellow, red) and
the transitions triggered by events such as a timer or a pedestrian crossing
button. The states would include "Green," "Yellow," and "Red," and
transitions would occur based on events like "Timer Expired" or
"Pedestrian Button Pressed."

Modeling a Vending Machin by a State Chart

In this State Chart, the vending machine starts in the Idle state where the user can
insert coins. If the user inserts sufficient funds, the vending machine transitions to
the Funds Received state where the user can select their product. If the selected
product is available, the vending machine transitions to the Dispensing state to
dispense the product and then returns to the Idle state once the transaction is
complete. If the selected product is unavailable, the vending machine transitions to
the Refunding state to refund the coins and then returns to the Idle state once the
transaction is complete. If the user doesn’t insert sufficient funds, the vending
machine transitions directly to the Refunding state to refund the coins and then
returns to the Idle state once the transaction is complete.
Key Differences:

You might also like