ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Object Oriented Analysis and Design
    COMP3150
    Progress0 / 17 topics
    Topics
    1. Principles of Object Technology2. OOP Review3. Principles of Modeling4. OOA&D Overview5. OO Development Process6. Requirements Engineering: Use Cases and Prototyping7. Class Models8. Interaction Diagrams9. Verification and Validation10. Architectural and Detailed Design11. Class Diagrams12. State Machines and Diagrams13. Implementation and Package Diagrams14. Activity Diagrams15. OO Patterns16. Object Diagram, Component Diagram, and Deployment Diagram17. Network Diagram
    COMP3150›State Machines and Diagrams
    Object Oriented Analysis and DesignTopic 12 of 17

    State Machines and Diagrams

    3 minread
    532words
    Beginnerlevel

    📘 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 load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time3 min
      Word count532
      Code examples0
      DifficultyBeginner