π Interaction Diagrams (OOAD)
πΉ 1. Definition
Interaction Diagrams are UML diagrams that show how objects communicate with each other by sending messages to perform a task.
π Simple idea:
They describe how the system behaves (dynamic view) β who talks to whom and in what order.
πΉ 2. Purpose of Interaction Diagrams
- Show object collaboration
- Describe flow of messages
- Help understand system behavior
- Validate system design
πΉ 3. Types of Interaction Diagrams β
There are mainly two important types:
πΈ 3.1 Sequence Diagram
Wikipedia
β
Definition:
A Sequence Diagram shows how objects interact in a time sequence (step-by-step order).
πΉ Key Elements:
| Element |
Description |
| Object |
Participant in interaction |
| Lifeline |
Vertical dashed line showing object life |
| Message |
Communication between objects |
| Activation |
Time an object is active |
πΉ Diagram Description:
- Objects are placed horizontally
- Time flows top to bottom
- Arrows show messages
User β Login System β Database
πΉ Example: ATM System
- User inserts card
- System asks for PIN
- User enters PIN
- System verifies
- Cash is dispensed
πΉ Types of Messages:
- Synchronous (wait for response)
- Asynchronous (no wait)
- Return message
πΈ 3.2 Communication Diagram (Collaboration Diagram)
β
Definition:
A Communication Diagram shows interaction between objects focusing on relationships rather than time.
πΉ Key Elements:
| Element |
Description |
| Objects |
Connected with links |
| Messages |
Labeled arrows |
| Sequence Numbers |
Show order of messages |
πΉ Diagram Description:
- Objects are connected like a network
- Messages are numbered (1, 2, 3β¦)
1: request()
2: process()
3: response()
πΉ 4. Sequence vs Communication Diagram
| Feature |
Sequence Diagram |
Communication Diagram |
| Focus |
Time sequence |
Object relationships |
| Layout |
Vertical |
Network-like |
| Message Order |
Top β Bottom |
Numbered |
πΉ 5. Steps to Create Interaction Diagrams
πΉ Step 1: Identify Scenario
πΉ Step 2: Identify Objects
- List participating objects
πΉ Step 3: Determine Messages
- Define communication steps
πΉ Step 4: Arrange Order
- Show sequence or numbering
πΉ Step 5: Draw Diagram
πΉ 6. Example (Library System)
πΉ Scenario: Borrow Book
πΉ Sequence Diagram:
Member β Librarian β Book
Steps:
- Member requests book
- Librarian checks availability
- Book is issued
πΉ Communication Diagram:
1: requestBook()
2: checkAvailability()
3: issueBook()
πΉ 7. Advantages of Interaction Diagrams
- Clear understanding of system flow
- Helps in debugging design
- Improves communication
- Shows real-time interactions
πΉ 8. Important Rules / Guidelines
- Keep diagrams simple and clear
- Use meaningful object names
- Show correct message order
- Avoid unnecessary complexity
πΉ 9. Likely Exam Questions
- Define interaction diagram.
- Explain sequence diagram with example.
- What is a communication diagram?
- Difference between sequence and communication diagrams.
- Explain elements of sequence diagram.
- Describe types of messages.
- Steps to create interaction diagrams.
- Draw sequence diagram for ATM system.
- Advantages of interaction diagrams.
- Role of interaction diagrams in OOAD.
πΉ 10. Quick Revision Summary π§
π Key Points:
- Objects send messages
- Show dynamic behavior
π Trick to Remember:
"SC β Sequence & Communication"