Referencing common interactions within others to support behavioral reuse
Interaction Use (also called Interaction Occurrence or ref) is a powerful reuse mechanism in UML 2.5 behavioral modeling. It allows you to reference an entire interaction—typically a sequence diagram, communication diagram, or even another interaction overview diagram—from within a different interaction diagram. This promotes modularization, reuse, consistency, and maintainability of behavioral specifications, much like calling a subroutine or method in code.
Key characteristics:
- Represented by a reference frame: a rectangle with the keyword ref in the top-left corner, followed by the name of the referenced interaction (e.g., ref LoginSequence).
- Can appear inside sequence diagrams, communication diagrams, or interaction overview diagrams.
- Parameters can be passed (actual gates or arguments) to make the referenced interaction generic and reusable.
- The referenced interaction is executed in-line at that point in the calling diagram (substitution semantics).
- Gates (entry/exit points) allow message passing in/out of the ref box.
- Supports behavioral composition without duplication—change the referenced interaction once, and all usages update.
In Agile & use-case-driven projects, Interaction Use is extremely valuable because:
- Common patterns (login, error handling, payment authorization, notification) appear in many scenarios → define once, reuse everywhere.
- Keeps detailed diagrams focused and short (extract repetitive parts).
- Improves traceability: one source of truth for shared behavior.
- Facilitates incremental refinement: stub a ref early, detail it later.
- Enables team collaboration: different developers own different reusable interactions.
Practical Examples of Interaction Use in Real Projects
Here are numerous concrete examples showing how Interaction Use supports reuse across scenarios:
- E-commerce – Reusable Payment Authorization
- Reusable sequence diagram: ref PaymentAuthorization
- Lifelines: :OrderService, :PaymentGateway, :BankAdapter
- Messages: authorize(amount, card), approved/declined, token returned
- Gates: in amount:Money, card:CardDetails; out result:AuthorizationResult Usage in multiple diagrams:
- Checkout sequence: … → ref PaymentAuthorization(amount=total, card=customerCard) → [result.approved] confirmOrder()
- Subscription renewal sequence: … → ref PaymentAuthorization(amount=monthlyFee, card=savedCard) → …
- One-click reorder sequence: … → ref PaymentAuthorization(amount=cartTotal, card=defaultCard) → … Practical benefit: Payment logic defined/tested once; any change (e.g., adding 3D Secure) updates all payment points instantly.
- Mobile Banking – Reusable Authentication with MFA
- Reusable diagram: ref AuthenticateWithMFA
- Participants: :MobileApp, :AuthService, :NotificationService
- Flow: requestOTP → sendOTP → enterOTP → validateOTP → return token Usage examples:
- Transfer funds sequence: … → ref AuthenticateWithMFA(user, device) → executeTransfer()
- View sensitive account details: … → ref AuthenticateWithMFA(user, device) → displayBalance()
- Change password: … → ref AuthenticateWithMFA(user, device) → updatePassword()
- Add new payee: … → ref AuthenticateWithMFA(user, device) → savePayee() Outcome: Single MFA flow enforces consistent security across all sensitive operations.
- Ride-Sharing – Reusable Real-Time Location Tracking
- Reusable sequence: ref UpdateLocationAndETA
- Lifelines: :DriverApp, :MatchingService, :RiderApp
- Loop: every 5s: sendLocation → calculateETA → pushToRider Usage:
- Driver en route sequence: … → loop [ride active] ref UpdateLocationAndETA(driver, ride)
- Ride in progress monitoring: … → ref UpdateLocationAndETA(driver, ride)
- Post-ride safety check (share trip): … → ref UpdateLocationAndETA(driver, ride) Practical: Ensures consistent tracking behavior; easy to adjust polling interval globally.
- Healthcare – Reusable Patient Identity Verification
- Reusable diagram: ref VerifyPatientIdentity
- Includes DOB check, insurance scan, photo ID validation, fraud flags Usage in:
- New patient registration sequence
- Telemedicine login sequence
- Prescription refill request sequence
- Appointment check-in kiosk sequence Benefit: HIPAA-compliant identity verification reused across portals and in-person flows.
- Task Management SaaS – Reusable Notification Broadcast
- Reusable communication diagram: ref NotifySubscribers
- Participants: :TaskService, :NotificationService, :EmailAdapter, :PushAdapter
- Messages: collectSubscribers → sendEmail → sendPush → logDelivery Usage:
- Card moved sequence: … → ref NotifySubscribers(task, event=”moved”)
- Comment added sequence: … → ref NotifySubscribers(task, event=”comment”)
- Due date approaching sequence: … → ref NotifySubscribers(task, event=”dueSoon”) Practical: One notification pattern supports email, push, Slack, Teams—change delivery channels once.
- IoT Device Management – Reusable Firmware Update Handshake
- Reusable sequence: ref FirmwareUpdateHandshake
- Device ↔ Server: checkVersion → if newer: downloadURL → verifyChecksum → applyUpdate Usage in:
- Scheduled update campaign sequence
- Manual update trigger sequence
- Post-reboot verification sequence Benefit: Ensures safe, atomic update protocol reused across rollout strategies.
- Real-Time Trading – Reusable Risk Check Before Execution
- Reusable diagram: ref PerformPreTradeRiskCheck
- Includes position limits, margin check, exposure limits, compliance flags Usage:
- Market order placement
- Limit order submission
- Algo-trading signal execution
- Bulk order batch processing Practical: Regulatory risk gate reused everywhere; audit trail consistent.
- Library System – Reusable Loan Eligibility Check
- Reusable sequence: ref CheckLoanEligibility
- :LibrarySystem → :MemberRecord: checkOverdues, checkLimits, checkBlacklist Usage:
- Self-checkout kiosk
- Online reservation confirmation
- In-person desk borrowing Practical: One place to update borrowing rules (e.g., max items per member type).
In Visual Paradigm:
- Create a standalone sequence/communication diagram for the reusable part.
- In another diagram, drag Interaction Occurrence (ref) from toolbox.
- Name it to match the reusable interaction (auto-hyperlink in repository).
- Add parameters/gates if needed (e.g., ref PaymentAuthorization(amount=$total)).
- Use in alt/opt/loop/par fragments for conditional reuse.
- Semantic backplane ensures changes to the referenced diagram propagate to all usages.
Interaction Use turns behavioral modeling into composable, maintainable modules—eliminating duplication, enforcing consistency, and making complex systems easier to understand, evolve, and test in Agile environments.
This completes the core elements of behavioral modeling in Module 4. With reuse mechanisms like Interaction Use, you can now efficiently scale detailed interaction modeling without redundancy—setting the stage for architecture-centric workflows and implementation in Module 5.
