ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCOMP3150State Machines Diagram…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    COMP3150

    Object Oriented Analysis and Design

    Progress0 / 17 done
    Topics17
    1Principles of Object Technology2OOP Review3Principles of Modeling4OOA&D Overview5OO Development Process
    6Use Cases and Prototyping7Class Models8Interaction Diagrams9Verification and Validation10Architectural and Detailed Design11Class Diagrams12State Machines and Diagrams13Implementation and Package Diagrams14Activity Diagrams15OO Patterns16Object Diagram, Component Diagram, and Deployment Diagram17Network Diagram
    3 min read
    Topic 12 of 17
    Topic Study Note Illustration
    12

    State Machines and Diagrams

    A State Machine (Finite State Machine) is a behavioral model that describes how an object changes its state in response to events over time.

    πŸ“˜ State Machines and State Diagrams (OOAD)


    πŸ”Ή 1. Definition

    A State Machine (Finite State Machine) is a behavioral model that describes how an object changes its state in response to events over time.

    πŸ‘‰ Simple idea: It shows what an object is doing at any point in time and how it moves from one condition to another.

    A State Diagram (UML State Machine Diagram) is the graphical representation of this behavior.


    πŸ”Ή 2. Key Idea

    • Objects do not behave the same all the time
    • They exist in different states
    • Events cause transitions between states

    πŸ”Ή 3. Real-Life Example

    πŸ‘‰ Example: ATM Machine

    • Idle β†’ Card Inserted β†’ PIN Entered β†’ Transaction β†’ Idle

    Each step is a state, and actions move it forward.


    πŸ”Ή 4. Components of State Machine Diagram ⭐


    πŸ”Έ 4.1 State

    A condition or situation of an object.

    Example:

    • Idle
    • Processing
    • Active
    • Locked

    πŸ“Œ Represented as rounded rectangles.


    πŸ”Έ 4.2 Initial State

    • Starting point of the system
    • Shown as a black dot (●)

    πŸ”Έ 4.3 Final State

    • End of process
    • Shown as a bullseye (β—Ž)

    πŸ”Έ 4.4 Transition

    • Movement from one state to another
    • Triggered by an event

    Example:

    Idle β†’ (Insert Card) β†’ Active
    

    πŸ”Έ 4.5 Event

    • Something that causes a change

    Example:

    • Button press
    • Login request
    • Timeout

    πŸ”Έ 4.6 Action

    • Activity performed during transition

    πŸ”Ή 5. State Diagram Notation

    ● β†’ Initial State
    β—‹ β†’ Final State
    [State] β†’ Rounded rectangle
    β†’ β†’ Transition arrow
    

    πŸ”Ή 6. Example: ATM System ⭐


    πŸ”Ή States:

    • Idle
    • Card Inserted
    • PIN Verification
    • Transaction
    • Exit

    πŸ”Ή Transitions:

    Idle β†’ Insert Card β†’ Card Inserted  
    Card Inserted β†’ Enter PIN β†’ PIN Verification  
    PIN Verification β†’ Success β†’ Transaction  
    Transaction β†’ Finish β†’ Idle  
    

    πŸ”Ή 7. Example Diagram Description

    • Start at Idle (●)
    • Card inserted β†’ move to next state
    • PIN entered β†’ system verifies
    • Transaction happens
    • Ends or returns to Idle

    πŸ”Ή 8. Types of States


    πŸ”Έ 8.1 Simple State

    • No internal structure

    πŸ”Έ 8.2 Composite State

    • Contains sub-states

    πŸ”Έ 8.3 Concurrent State

    • Multiple states active at the same time

    πŸ”Ή 9. State vs Activity Diagram

    Feature State Diagram Activity Diagram
    Focus Object states Workflow/process
    Behavior Event-driven Action-driven
    Level Object level System level

    πŸ”Ή 10. Where State Diagrams are Used

    • ATM systems
    • Traffic lights
    • Online shopping carts
    • Vending machines
    • User login systems

    πŸ”Ή 11. Advantages of State Diagrams

    • Shows dynamic behavior clearly
    • Helps in system understanding
    • Useful for real-time systems
    • Detects invalid states
    • Improves design accuracy

    πŸ”Ή 12. Important Rules / Guidelines

    • Identify all possible states first
    • Define events carefully
    • Avoid unnecessary states
    • Ensure all transitions are valid
    • Always define initial and final state

    πŸ”Ή 13. Likely Exam Questions

    1. Define state machine in OOAD.
    2. What is a state diagram?
    3. Explain components of state machine diagram.
    4. Draw state diagram of ATM system.
    5. Difference between state and activity diagram.
    6. What is a transition?
    7. Explain initial and final state.
    8. What are events in state diagrams?
    9. Types of states in UML.
    10. Advantages of state diagrams.

    πŸ”Ή 14. Quick Revision Summary 🧠

    • State Machine = Behavior of object over time
    • State = Condition of object
    • Event = Trigger for change
    • Transition = Movement between states

    πŸ‘‰ Trick to Remember: "SET" β†’ State, Event, Transition


    ← Previous topic 11
    Class Diagrams
    Next topic 13 β†’
    Implementation and Package Diagrams

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    3mremaining
    532words
    Beginnerlevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Object Oriented Analysis and Design