๐ŸŽฌ Lecture 06 ยท Dynamic view of UML

UML Sequence Diagrams

ุฑุณู… Class diagram ุจูŠูˆุฑูŠูƒ structure ุงู„ู†ุธุงู…. ูˆุฑุณู… Sequence diagram ุจูŠูˆุฑูŠูƒ ุฅุฒุงูŠ ุงู„ู€ objects ุจุชุชูุงุนู„ ุนุจุฑ ุงู„ุฒู…ู† ู„ุชู†ููŠุฐ use case. ู…ู‡ู… ุฌุฏุงู‹ ููŠ Question 2 (4 marks).

9
Chapters
4
Message Types
3
Frame Types
8
Practice Qs
01

Why Model Software?

Modeling ูŠุนู†ูŠ ุจู†ุงุก abstraction ู„ู„ูˆุงู‚ุน: ุจู†ุชุฌุงู‡ู„ ุงู„ุชูุงุตูŠู„ ุบูŠุฑ ุงู„ู…ู‡ู…ุฉ ูˆู†ุญุชูุธ ุจุงู„ู…ู‡ู…ุฉ.

๐Ÿ“– What is Modeling?
  • Modeling = building an abstraction of reality.
  • Abstractions = simplifications because:
    • ุจู†ุชุฌุงู‡ู„ irrelevant details.
    • ุจู†ุฑูƒุฒ ุนู„ู‰ relevant details ุจุณ.
  • ู…ุนู†ู‰ Relevant ุจูŠุชุญุฏุฏ ุญุณุจ ู‡ุฏู ุงู„ู€ model.
๐Ÿ“ˆ Why Model Software?
  • ุงู„ู€ Software ุจู‚ู‰ ุฃูƒุชุฑ ุชุนู‚ูŠุฏุงู‹ โ€” Windows 10 ุฃูƒุชุฑ ู…ู† 50 ู…ู„ูŠูˆู† ุณุทุฑ ูƒูˆุฏ.
  • ู…ุจุฑู…ุฌ ูˆุงุญุฏ ู…ุง ูŠู‚ุฏุฑุด ูŠูู‡ู… ูƒู„ ุงู„ูƒูˆุฏ ุฏู‡ ู„ูˆุญุฏู‡.
  • ุงู„ูƒูˆุฏ ู…ุด ุณู‡ู„ ุงู„ูู‡ู… ู„ู„ู…ุทูˆุฑูŠู† ุงู„ู„ูŠ ู…ุง ูƒุชุจูˆุด.
  • ู†ุญุชุงุฌ ุชู…ุซูŠู„ุงุช ุจุณูŠุทุฉ ู„ุฃู†ุธู…ุฉ ู…ุนู‚ุฏุฉ.
๐ŸŒ Application Domain vs Solution Domain

๐Ÿข Application Domain

ุงู„ู€ environment ุงู„ู„ูŠ ุงู„ู†ุธุงู… ุจูŠุดุชุบู„ ููŠู‡ โ€” ู…ุซู„ุงู‹ Air Traffic Control: ุงู„ุทูŠุงุฑุงุชุŒ ุงู„ุฃุจุฑุงุฌุŒ ุงู„ุฑุงุฏุงุฑ.

โ†’ ูŠุณุชุฎุฏู… ููŠ Requirements Analysis.

๐Ÿ’ป Solution Domain

ุงู„ู€ technologies ุงู„ู…ุชุงุญุฉ ู„ุจู†ุงุก ุงู„ู†ุธุงู… โ€” Classes, Databases, APIs, frameworks.

โ†’ ูŠุณุชุฎุฏู… ููŠ System Design & Object Design.

02

UML 80/20 Rule (Pareto)

ุชู‚ุฏุฑ ุชู…ุฐุฌ 80% ู…ู† ุงู„ู…ุดุงูƒู„ ุจุงุณุชุฎุฏุงู… 20% ู…ู† UML. ู‡ู†ุฑูƒุฒ ุนู„ู‰ ุงู„ู€ 20% ุงู„ู…ู‡ู…ูŠู†.

๐ŸŽฏ ุงู„ู€ 4 Diagrams ุงู„ุฃุณุงุณูŠุฉ
DiagramViewุงู„ุบุฑุถ
Use CaseFunctionalุงู„ู€ behavior ูƒู…ุง ูŠุฑุงู‡ ุงู„ู…ุณุชุฎุฏู…
ClassStatic Structureุงู„ู€ objects ูˆ attributes ูˆ associations
Sequence โญDynamicุชูุงุนู„ ุงู„ู€ objects ุนุจุฑ ุงู„ุฒู…ู† ู„ุชู†ููŠุฐ use case
StateDynamicุงู„ู€ behavior ุงู„ุฏุงุฎู„ูŠ ู„ู€ object ูˆุงุญุฏ
๐Ÿ“š ุชุฑุชูŠุจ ุงู„ู…ุญุงุถุฑุงุช ุบุทูŠู†ุง Use Cases ููŠ Lec 3ุŒ ูˆ Class diagrams ููŠ Lec 5. ุฏู„ูˆู‚ุชูŠ Sequence diagramsุŒ ูˆุจุนุฏู‡ุง State diagrams.
03

Interaction Diagrams

Sequence + Communication diagrams. ุจู†ุณุชุฎุฏู…ู‡ู… ู„ู†ู…ุฐุฌุฉ ุงู„ู€ dynamic aspects.

๐ŸŽฌ What are Interaction Diagrams?

ุจุชูุณุชุฎุฏู… ู„ู†ู…ุฐุฌุฉ ุงู„ู€ dynamic aspects ู„ู„ู†ุธุงู…:

  • ุจุชุนุฑุถ ุฅุฒุงูŠ ุงู„ู†ุธุงู… ุจูŠุดุชุบู„.
  • ุบุงู„ุจุงู‹ ุจุชูุจู†ู‰ ู…ู† use case + class diagram.
  • ุงู„ู‡ุฏู: ู†ูˆุถุญ ุฅุฒุงูŠ ู…ุฌู…ูˆุนุฉ objects ุจุชู†ูุฐ ุงู„ู€ interactions ุงู„ู…ุทู„ูˆุจุฉ ู…ุน actor.
๐Ÿ“ฆ 2 Types

๐Ÿ“ˆ Sequence Diagram

ุฃูƒุชุฑ ุดูŠูˆุนุงู‹. ุจูŠุฑูƒุฒ ุนู„ู‰ ุงู„ุชุฑุชูŠุจ ุงู„ุฒู…ู†ูŠ ู„ู„ู€ messages. ุงู„ู…ุญูˆุฑ ุงู„ุฑุฃุณูŠ (vertical axis) = ุงู„ุฒู…ู†.

๐Ÿ•ธ๏ธ Communication Diagram

ุจูŠุฑูƒุฒ ุนู„ู‰ ุงู„ู€ relationships ุจูŠู† objects. ุงู„ุฒู…ู† ู…ุด explicitุŒ ูˆุจุฏู„ ูƒุฏู‡ ุจู†ุฑู‚ู‘ู… ุงู„ู€ messages.

๐Ÿงฑ Elements of Sequence Diagrams
  • Instances of classes โ€” boxes ููŠู‡ุง object identifier ุชุญุชู‡ ุฎุท (underline).
  • Actors โ€” stick figures ุฒูŠ Use Case diagrams.
  • Messages โ€” ุฃุณู‡ู… ู…ู† actor ู„ู€ objectุŒ ุฃูˆ ู…ู† object ู„ู€ object.
  • Lifelines โ€” ุฎุทูˆุท ู…ู†ู‚ุทุฉ (dashed vertical lines) ู…ู…ุชุฏุฉ ู…ู† ูƒู„ box.
  • Activation boxes โ€” ุฃุนู…ุฏุฉ ุทูˆูŠู„ุฉ ุนู„ู‰ ุงู„ู€ lifeline ุจุชุจูŠู† ุงู„ูุชุฑุฉ ุงู„ู„ูŠ ุงู„ู€ object ู†ุดุท ููŠู‡ุง.
04

Notation Elements

Frame ยท Lifeline ยท Lifeline Names ยท Activation Boxes.

๐Ÿ–ผ๏ธ Frame

ุงู„ู€ Frame ู‡ูˆ ุงู„ุญุงูˆูŠุฉ ุงู„ุฎุงุฑุฌูŠุฉ. ููŠู‡ heading ุจุชุญุชูˆูŠ ุนู„ู‰ sd + ุงุณู… ุงู„ู€ interaction.

sd Frame_Name
[Lifelines and Message Flow inside]
โ†“ Time flows downward
๐Ÿ“ Lifeline

ูƒู„ participant ุนู†ุฏู‡ lifeline: ุฎุท ู…ู†ู‚ุท ุนู…ูˆุฏูŠ ุชุญุช ุงู„ู€ box ุจุชุงุนู‡. ุงู„ุฒู…ู† (Time) ุจูŠู…ุดูŠ ู…ู† ููˆู‚ ู„ุชุญุช.

๐Ÿท๏ธ Lifeline Name Conventions
ุงู„ู€ Notationุงู„ู…ุนู†ู‰
seoclecturerObject ุงุณู…ู‡ seoclecturer
seoclecturer : LecturerObject ุงุณู…ู‡ seoclecturer ู…ู† class ุงุณู…ู‡ุง Lecturer
: LecturerAnonymous object ู…ู† class ุงุณู…ู‡ุง Lecturer
lecturer[i] : Lecturerุงู„ู€ Object ุงู„ู…ูˆุฌูˆุฏ ุนู†ุฏ index ุงุณู…ู‡ i
๐Ÿ’ก ุงู„ู…ู‡ู… ุงุณู… ุงู„ู€ object ุฏุงูŠู…ุงู‹ underlined ููŠ sequence diagrams ู„ุฃู†ู‡ instance ู…ุด class. ุงู„ุงุณู… ู‚ุจู„ ุงู„ู†ู‚ุทุชูŠู†ุŒ ูˆุงู„ู€ class ุจุนุฏู‡ุง.
๐Ÿ” Mini Example โ€” Course Registration
actor
Student
:CourseSection
CourseSection
:Registration
Registration
:Student
Student
1. Student โ†’ CourseSection : requestToRegister
2. CourseSection โ†’ Registration : โ‡ข create (dashed)
3. Registration โ†’ Student : addToSchedule
4. Registration โ†’ CourseSection : addToRegistrationList
05

Message Types โ€” 4 Types

ุงู„ุฏูƒุชูˆุฑ ุจูŠุญุจ ูŠุณุฃู„ ุนู† ุงู„ูุฑู‚ ุจูŠู† Synchronous, Asynchronous, Create, Reply.

๐Ÿ”„ Synchronous Message

โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ (solid arrow, filled triangle)

ุงู„ู€ Sender ุจูŠุณุชู†ู‰ ู„ุญุฏ ู…ุง ุงู„ู€ message ุชุชุนุงู„ุฌ ู‚ุจู„ ู…ุง ูŠูƒู…ู„. ุฏูŠ Wait semanticsุŒ ูˆุฏู‡ ู‡ูˆ ุงู„ู€ method call ุงู„ุนุงุฏูŠ.

โšก Asynchronous Message

โ”€โ”€โ”€โ”€โ”€โ”€โ–ท (solid arrow, open arrowhead)

ุงู„ู€ Sender ู…ุง ูŠุณุชู†ุงุด. ุฏูŠ No-wait semantics. ู…ููŠุด explicit returnุŒ ูˆุฏู‡ ุจูŠุณู…ุญ ู„ู„ู€ objects ุชุดุชุบู„ concurrently.

โ†ฉ๏ธ Reply Message

โ‡ โ‡ โ‡ โ‡ โ‡  (dashed arrow, open arrowhead)

ุฏูŠ ุงู„ู€ return value ู…ู† message ุณุงุจู‚ุฉ. ุจุชุฑุณู… ูƒู€ dashed line. ู…ู…ูƒู† ุชุชุฌุงู‡ู„ู‡ุง ู„ูˆ ุงู„ู€ flow ูˆุงุถุญ.

๐Ÿ†• Create Message

โ‡ขโ‡ขโ‡ขโ‡ขโ‡ข (dashed arrow โ†’ object box)

ุจูŠุฎู„ู‚ object ุฌุฏูŠุฏ ุฃุซู†ุงุก ุงู„ู€ interaction. ููŠ Java = constructor call (new ClassName()). ุงู„ู€ arrowhead ุจูŠุดุงูˆุฑ ู„ู„ู€ object ุงู„ุฌุฏูŠุฏ.

๐Ÿ’ก ุงู„ูุฑู‚ ุงู„ู…ู‡ู… Synchronous = wait. Asynchronous = no wait. ู„ูˆ ุดูุช filled arrowhead ูŠุจู‚ู‰ synchronous (method call). ูˆู„ูˆ ุดูุช open arrowhead + dashed ูŠุจู‚ู‰ reply/async.
06

Combined Fragments โ€” opt, loop, alt

ุงู„ู€ Frames ุฏูŠ ุจุชุบู„ู ุฃุฌุฒุงุก ู…ู† ุงู„ู€ sequence ู„ู„ุชุญูƒู… ููŠ ุงู„ู€ control flow.

โ“ opt โ€” Optional

ุงู„ู€ messages ุฏุงุฎู„ ุงู„ู€ frame ุจุชุชู†ูุฐ ู„ูˆ ุงู„ู€ guard condition = true. ุฒูŠ if.

opt
[hasPrerequisite]
create new :Registration
:Registration โ†’ :Student : addToSchedule
:Registration โ†’ :CourseSection : addToRegistrationList

ู„ูˆ ุงู„ู€ student ู…ุง ุนู†ุฏูˆุด ุงู„ู€ prerequisiteุŒ ุงู„ู€ frame ุฏู‡ ุจูŠุชุฎุทู‰ ุจุงู„ูƒุงู…ู„.

๐Ÿ” loop

ุงู„ู€ messages ุจุชุชู†ูุฐ ุนุฏุฉ ู…ุฑุงุช. ู…ู…ูƒู† ุชุญุท range ุฒูŠ 0..n ุฃูˆ *.

loop 0..numPurchases
:Bill โ†’ :Purchase : getSubtotal
:Purchase โ†’ :Item : getUnitPrice
๐Ÿ”€ alt โ€” Alternative (if/else)

ุงุฎุชูŠุงุฑ ุจูŠู† multiple paths ุจู†ุงุกู‹ ุนู„ู‰ ุดุฑูˆุท. ุฒูŠ if/else ุฃูˆ switch.

alt
[credentials valid]
redirect to dashboard
[else]
show error message
๐Ÿ“Œ Other useful frames
par โ€” Parallel (concurrent execution).
break โ€” Like break in a loop, exits the current scope.
ref โ€” ุงู„ุฑุฌูˆุน ู„ู€ sequence diagram ุชุงู†ูŠุฉ (reusable).
07

Object Creation & Destruction

ุฅุธู‡ุงุฑ ุญูŠุงุฉ ุงู„ู€ object: ู…ู† ู„ุญุธุฉ ุฅู†ุดุงุฆู‡ ู„ุญุฏ ุชุฏู…ูŠุฑู‡.

๐ŸŒฑ Element Creation

ุงู„ู€ Object ุงู„ุฌุฏูŠุฏ ุจูŠุธู‡ุฑ ููŠ ุงู„ู†ุต ุฃูˆ ุชุญุชุŒ ู…ุด ููˆู‚ ู…ุน ุงู„ู€ objects ุงู„ู…ูˆุฌูˆุฏุฉ ู…ู† ุงู„ุจุฏุงูŠุฉ.

ุงู„ุณู‡ู… dashed arrow with open arrowhead ุจูŠุดุงูˆุฑ ู„ู„ู€ box ุงู„ุฌุฏูŠุฏ. ุงู„ู€ box ู‡ูˆ ุงู„ู„ูŠ ุงู„ุณู‡ู… ุจูŠูˆุตู„ู‡.

ููŠ ุงู„ูƒูˆุฏ: ุฏู‡ ุจูŠู…ุซู„ new ClassName().

๐Ÿ’€ Element Destruction

ุงู„ู€ Object ุจูŠู†ุชู‡ูŠ ุจุนู„ุงู…ุฉ large X symbol ุนู„ู‰ ุงู„ู€ lifeline ุนู†ุฏ ู†ู‚ุทุฉ ุงู„ู€ destruction.

ุงู„ู€ message ุงู„ู„ูŠ ุจุชุฏู…ุฑ ุงู„ู€ object ุจุชุฎู„ุต ุนู†ุฏ ุนู„ุงู…ุฉ X.

ู…ุซุงู„: cancelBooking โ†’ cancel โ†’ :Booking ูŠู†ุชู‡ูŠ ุจู€ X.

08

Library System โ€” Full Example โญ

ุงู„ุฏูƒุชูˆุฑ ุนู…ู„ sequence diagram ู„ู€ Issue a Book ู…ุน opt fragment. ุฑูƒุฒ ุนู„ูŠู‡.

๐Ÿ“š Use Case: Issue Book

Actor: Librarian ยท Goal: Issue a book to a borrower if his status permits.

Main Scenario:

ActorSystem
1- Enter user's ID2- Display info & user status
3- If allowed to borrow, enter book copy ID4- Create borrowing record
5- Update user's #books borrowed
6- Update book's availability

Exceptional Flow โ€” Suspended/MaxBorrowed:

If user is suspended or at max โ†’ deny issuing.

๐Ÿ“ˆ Sequence Diagram Flow

ุงู„ู€ Objects ุงู„ู…ุดุงุฑูƒุฉ (ู…ู† ุงู„ู€ classes ุงู„ู…ูˆุฌูˆุฏุฉ):

  • Librarian โ€” actor
  • GUI โ€” boundary
  • LibrarySystem โ€” control
  • Catalog โ€” entity
  • Book / BookCopy โ€” entity
  • User / Record โ€” entity

Step-by-step:

  1. Librarian โ†’ GUI : checkUserStatus(ID)
  2. GUI โ†’ LibrarySystem : checkUserStatus(ID)
  3. LibrarySystem โ†’ User : checkStatus() โ†’ returns status
  4. Return "Allowed" to Librarian
  5. opt [if Allowed]:
    1. Librarian โ†’ GUI : IssueBook(title, ID)
    2. GUI โ†’ LibrarySystem : SearchCatalog(title, auth)
    3. LibrarySystem โ†’ Catalog : findBook(title, auth) โ†’ returns Book
    4. LibrarySystem โ†’ Book : getCopyInfo()
    5. LibrarySystem โ†’ User : updateBorrowed() (self message)
    6. LibrarySystem โ†’ BookCopy : updateAvailability()
๐Ÿ’ก ุงู„ู…ูุงุชูŠุญ ู„ู„ู†ุฌุงุญ
  1. ูƒู„ step ููŠ ุงู„ู€ use case = message ุฃูˆ ุงุชู†ูŠู† ููŠ ุงู„ู€ sequence.
  2. ูƒู„ method ุฌุฏูŠุฏุฉ ู„ุงุฒู… ุชูƒูˆู† ููŠ ุงู„ู€ class diagram.
  3. ุฃุณู…ุงุก ุงู„ู€ objects ู„ุงุฒู… ุชูƒูˆู† underlined.
  4. ุงุณุชุฎุฏู… opt ู„ู„ู€ conditional flow.
๐Ÿšจ ุฃุฎุทุงุก ุงู„ุทู„ุจุฉ ุงู„ู…ุชูƒุฑุฑุฉ
  • โŒ ู†ุณูŠุงู† underline ู„ุฃุณู…ุงุก ุงู„ู€ objects.
  • โŒ ุงุณุชุฎุฏุงู… method names ู…ุด ู…ูˆุฌูˆุฏุฉ ููŠ ุงู„ู€ class diagram.
  • โŒ ู†ุณูŠุงู† ุงู„ู€ return messages (ุงู„ู€ dashed lines).
  • โŒ ุชุฑุชูŠุจ ุงู„ู€ time ุบู„ุท (ุงู„ุฒู…ู† ุจูŠู…ุดูŠ ู…ู† ููˆู‚ ู„ุชุญุช).
  • โŒ ุฎู„ุท ุงู„ู€ actor ุจู€ object โ€” Actor = stick figureุŒ ูˆ Object = box.
  • โŒ ู†ุณูŠุงู† ุงู„ู€ opt frame ู„ู„ู€ conditional logic.
09

Why Not Just Code It?

ุณุคุงู„ ุทุจูŠุนูŠ: ู„ูˆ ุงู„ู€ sequence diagram ู‚ุฑูŠุจ ู…ู† ุงู„ูƒูˆุฏุŒ ู„ูŠู‡ ู†ุฑุณู…ู‡ ุฃุตู„ุงู‹ุŸ ุนู†ุฏู†ุง 4 ุฃุณุจุงุจ.

1๏ธโƒฃ Above the level of real code

ุงู„ู€ sequence diagram ุจูŠุฑูƒุฒ ุนู„ู‰ ุงู„ู€ interactionsุŒ ู…ุด ุชูุงุตูŠู„ ุงู„ู€ syntax. ุงู„ู„ูŠ ุนุงูŠุฒ ูŠุดูˆู "ุฅุฒุงูŠ ุงู„ู€ objects ุจุชุชูƒู„ู…" ู‡ูŠูู‡ู…ู‡ ุจุณุฑุนุฉ.

2๏ธโƒฃ Language-independent

ู†ูุณ ุงู„ู€ sequence diagram ู…ู…ูƒู† ูŠุชู†ูุฐ ููŠ Java, Python, C#, etc.ุŒ ูˆุงู„ู€ design ุจูŠูุถู„ ู…ุญููˆุธ ุจุบุถ ุงู„ู†ุธุฑ ุนู† ุงู„ู€ implementation.

3๏ธโƒฃ Non-coders can read/do them

Business analysts, project managers, clients ูŠู‚ุฏุฑูˆุง ูŠูู‡ู…ูˆุง ุงู„ู€ flow ูˆูŠุฑุงุฌุนูˆุง ุงู„ู€ design ู…ู† ุบูŠุฑ ู…ุง ูŠูƒูˆู†ูˆุง programmers.

4๏ธโƒฃ Visual representations

ุงู„ู€ Visual representation ุฃุณุฑุน ููŠ ุงู„ูู‡ู… ู…ู† ุงู„ู†ุต. screenshot ูˆุงุญุฏ ู…ู…ูƒู† ูŠุฎุชุตุฑ ุฃู„ู ุณุทุฑ ูƒูˆุฏ.

โš ๏ธ ุงู„ู€ Risks ุงู„ู€ Dynamic modeling ุตุนุจ. ููŠ systems ูƒุจูŠุฑุฉ ููŠู‡ ูƒู… ู‡ุงุฆู„ ู…ู† ุงู„ู€ paths. ุงู„ุญู„ ูŠูƒูˆู† iteratively: ุงุจุฏุฃ ุจู€ class diagrams + use cases + interaction diagrams + state diagramsุŒ ูˆุฑุงุฌุนู‡ู… ูƒู„ู‡ู… ู…ุน ุจุนุถ.
๐ŸŽฏ

Practice Quiz โ€” Lecture 6

8 ุฃุณุฆู„ุฉ ุนู„ู‰ Sequence Diagrams. ุงู„ู€ Question 2 ููŠ ูƒู„ ุงู…ุชุญุงู† final ููŠู‡ 4 marks ุนู„ู‰ sequence diagram. ุฑูƒุฒ.

Question 1 Practice โ€” concept
What does the vertical dimension represent in a sequence diagram?
A Sequence of classes
B Time
C Number of messages
D Object visibility
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: B โ€” Time ุงู„ู€ vertical (top to bottom) = ุงู„ุฒู…ู†. ูˆุงู„ู€ horizontal = ุงู„ู€ objects ุงู„ู…ุฎุชู„ูุฉ.
A โ€” ุงู„ู€ classes ุจุชุธู‡ุฑ ุฃูู‚ูŠุงู‹ ู…ุด ุฑุฃุณูŠุงู‹. ยท C, D โ€” ู…ุด ู…ุนู†ู‰ ุงู„ู€ vertical dimension.
Question 2 Practice โ€” message types
A synchronous message means:
A The sender does not wait for any response
B The message creates a new object
C The sender waits for the message to be handled before continuing
D The message returns a value
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: C โ€” wait semantics Synchronous = wait. ุฏู‡ ุงู„ู€ method call ุงู„ุนุงุฏูŠ.
A โ€” ุฏู‡ Asynchronous. ยท B โ€” ุฏู‡ Create. ยท D โ€” ุฏู‡ Reply.
Question 3 Practice โ€” frames
A team is modeling a login flow where credentials are checked, and if valid, user is sent to dashboard, otherwise error is shown. Which frame should be used?
A alt (alternative)
B loop
C par (parallel)
D ref (reference)
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: A โ€” alt Two distinct paths (valid/invalid) = alt (if/else).
B (loop) โ€” ุชูƒุฑุงุฑ. ู‡ู†ุง ู…ุด ุชูƒุฑุงุฑ. ยท C (par) โ€” concurrent execution. ยท D (ref) โ€” reference to another diagram.
Question 4 Practice โ€” lifeline names
In a sequence diagram, you see : Lecturer. What does this mean?
A Object named "Lecturer"
B Anonymous object of class Lecturer
C Object Lecturer at index 0
D Class named Lecturer
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: B โ€” Anonymous instance of class Lecturer Empty name + :Class = anonymous instance.
A โ€” ูƒุงู† ู„ุงุฒู… ูŠูƒูˆู† Lecturer ุจุฏูˆู† ู†ู‚ุทุชูŠู†. ยท C โ€” ุงู„ู€ index ุจูŠุชูƒุชุจ lecturer[0]. ยท D โ€” ููŠ sequence diagram ู„ุงุฒู… ุชูƒูˆู† instances ู…ุด classes.
Question 5 Practice โ€” destruction
How is the destruction of an object shown on its lifeline?
A Lifeline ends with a square box
B Lifeline becomes a dashed red line
C The object name is crossed out
D A large X symbol at the end of the lifeline
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: D โ€” Large X at end of lifeline ู…ุซุงู„: ููŠ cancel bookingุŒ ุงู„ู€ :Booking object lifeline ุจูŠู†ุชู‡ูŠ ุจู€ X.
Question 6 Practice โ€” modeling concepts
Which is NOT a good reason to draw a sequence diagram rather than just writing code?
A Sequence diagrams are language-independent
B Non-coders can read them
C They are faster to execute than real code
D They provide a visual representation
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: C โ€” sequence diagrams DON'T execute Sequence diagrams ู‡ูŠ design artifactsุŒ ู…ุด executable code. ุฃู‡ุฏุงูู‡ุง: ู…ุณุชู‚ู„ุฉ ุนู† ุงู„ู„ุบุฉุŒ ูŠูู‡ู…ู‡ุง non-codersุŒ ุชู…ุซูŠู„ ุจุตุฑูŠุŒ ูˆู…ุณุชูˆู‰ ุฃุนู„ู‰ ู…ู† ุงู„ูƒูˆุฏ.
Question 7 Practice โ€” create
Which symbol represents object creation in a sequence diagram?
A Solid arrow with filled triangle
B Dashed arrow with open arrowhead pointing to the new object box
C Large X at start of lifeline
D Double-headed arrow
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: B Create = dashed arrow with open arrowhead ุจูŠุดุงูˆุฑ ุนู„ู‰ box ุงู„ู€ object ุงู„ุฌุฏูŠุฏ. ู…ู…ุงุซู„ ู„ู€ new ClassName() ููŠ Java.
A โ€” ุฏู‡ synchronous message ุนุงุฏูŠ. ยท C โ€” ุนู„ุงู…ุฉ X ุจุชุดูŠุฑ ู„ู€ destruction ู…ุด creation.
Question 8 Practice โ€” sequence + class
Which of these MUST you have before drawing a sequence diagram?
A A complete state diagram
B The full source code
C A deployment diagram
D A use case and a class diagram
โœ… ุงู„ุฅุฌุงุจุฉ ุงู„ุตุญ: D โ€” Use case + Class diagram ุงู„ู€ Sequence diagram ุจูŠู†ูู‘ุฐ use case ู…ุนูŠู†ุŒ ูˆุจูŠุณุชุฎุฏู… ุงู„ู€ methods ู…ู† ุงู„ู€ class diagram. ู„ุงุฒู… ุงู„ุงุชู†ูŠู† ูŠูƒูˆู†ูˆุง ู…ูˆุฌูˆุฏูŠู† ู‚ุจู„ู‡.
A โ€” ุงู„ู€ State diagram ุงุฎุชูŠุงุฑูŠ ูˆู…ููŠุฏ ู„ู€ objects ุนู†ุฏู‡ุง complex states. ยท B โ€” ุงู„ู€ sequence diagram ุจูŠุณุจู‚ ุงู„ูƒูˆุฏ ุบุงู„ุจุงู‹ุŒ ู…ุด ุงู„ุนูƒุณ. ยท C โ€” ุงู„ู€ Deployment diagrams ุชุฎุต ุงู„ู€ infrastructureุŒ ู…ุด requirement.
๐Ÿ“‹

Cheat Sheet

ูƒู„ ุงู„ู„ูŠ ู…ุญุชุงุฌู‡ ู„ุฑุณู… sequence diagram ููŠ Question 2.

๐Ÿงฉ Elements

Actor
Stick figure (left)
Object
Box with name:Class underlined
Lifeline
Vertical dashed line
Activation Box
Tall rectangle on lifeline = active
Frame
Outer rectangle, sd Name

๐Ÿ“จ Message Types

Synchronous
โ”โ”โ–ถ (filled triangle) ยท wait
Asynchronous
โ”โ”โ–ท (open) ยท no wait
Reply
โ‡ โ‡ โ‡  (dashed) ยท return value
Create
โ‡ขโ‡ขโ‡ข to new object box
Destroy
Large X at end of lifeline

๐Ÿ–ผ๏ธ Combined Fragments

opt
Optional (single if)
alt
Alternative (if/else)
loop
Repeated (for/while)
par
Parallel (concurrent)
break
Exit (like break in loop)
ref
Reference (reuse another diagram)

๐Ÿท๏ธ Lifeline Names

name
Just object name
name : Class
Named instance of Class
: Class
Anonymous instance
name[i] : Class
Indexed instance

โœ… Question 2 Checklist (4 marks)

1.
All necessary actors + objects with class names
2.
All object names underlined
3.
Methods used = methods ุงู„ู…ูˆุฌูˆุฏุฉ ููŠ class diagram
4.
Return messages where needed
5.
opt/alt for conditional logic
6.
ุงู„ุฒู…ู† ูŠู…ุดูŠ topโ†’bottom ุจุงุณุชู…ุฑุงุฑ

๐Ÿ“š Concepts

Modeling = ?
Abstraction of reality
App Domain
Environment (requirements)
Solution Domain
Technologies (design)
Pareto rule
20% UML โ†’ 80% problems
Pre-req for SD
Use case + Class diagram
โšก

Rapid Revision

Flashcards ยท Common Mistakes ยท What the doctor loves.

ุงู„ู€ Vertical dimension ููŠ sequence diagramุŸ
tap
Time (top โ†’ bottom)
Synchronous vs AsynchronousุŸ
tap
Sync = wait. Async = no wait.
ุฃุดู‡ุฑ 3 frame typesุŸ
tap
opt ยท alt ยท loop
Object destruction symbolุŸ
tap
Large X at end of lifeline
ุงู„ู…ุทู„ูˆุจ ู‚ุจู„ sequence diagramุŸ
tap
Use case + Class diagram
ู…ุนู†ู‰ UML 80/20ุŸ
tap
20% UML โ†’ 80% problems
Anonymous object notationุŸ
tap
: ClassName (empty before colon)
Create message arrow styleุŸ
tap
Dashed arrow โ†’ new object box
Application vs Solution DomainุŸ
tap
App = environment (analysis). Solution = tech (design).

๐Ÿšจ Common Mistakes

1. Methods ู…ุด ู…ูˆุฌูˆุฏุฉ ููŠ ุงู„ู€ class diagramูƒู„ method ููŠ ุงู„ู€ sequence diagram ู„ุงุฒู… ุชูƒูˆู† ู…ูˆุฌูˆุฏุฉ ููŠ ุงู„ู€ class diagram. ู„ูˆ ุถูุช method ุฌุฏูŠุฏุฉุŒ ุงุฑุฌุน ูˆุถูŠูู‡ุง ููŠ ุงู„ู€ class.
2. ู†ุณูŠุงู† underline ู„ุฃุณู…ุงุก ุงู„ู€ objectsุงู„ู€ Object box ููŠ sequence diagram ุงุณู…ู‡ ุฏุงูŠู…ุงู‹ underlined ู„ุฃู†ู‡ instance ู…ุด class.
3. ุฎู„ุท arrow typesSolid filled = sync ยท Solid open = async ยท Dashed = reply ยท Dashed to box = create.
4. ุชุฑุชูŠุจ ุงู„ุฒู…ู† ุบู„ุทุงู„ุฒู…ู† ุจูŠู…ุดูŠ ู…ู† ููˆู‚ ู„ุชุญุช. ู„ูˆ ุฑุณู…ุช msg ุฃุนู„ู‰ ู…ู† msg ุชุงู†ูŠุŒ ุงู„ุฃุนู„ู‰ ุจูŠุญุตู„ ุฃูˆู„ุงู‹.
5. ู†ุณูŠุงู† opt/alt ู„ู„ู€ conditional flowู„ูˆ ููŠ if ููŠ ุงู„ู€ use caseุŒ ู„ุงุฒู… ุชูƒูˆู† opt ุฃูˆ alt. ู…ุง ุชุชุฌุงู‡ู„ู‡ุงุด.

โญ What Dr. El-Ramly Loves

๐Ÿ”ฅ ุงู„ุฃุณุฆู„ุฉ ุงู„ู…ุชูƒุฑุฑุฉ ุนู„ู‰ Lec 6
  1. Question 2 (4 marks) โ€” ุจูŠุฏูŠ use case ูˆูŠุทู„ุจ sequence diagram. ุงู„ู€ flow ู…ู…ูƒู† ูŠูƒูˆู† Library / Email / Booking / Print order. ุฑูƒุฒ ุนู„ูŠู‡.
  2. ุงุณุชุฎุฏู… opt frame ู„ู…ุง ุงู„ู€ flow ูŠูƒูˆู† conditional.
  3. ุทุงุจู‚ ุงู„ู€ methods ู…ุน ุงู„ู€ class diagram โ€” ุฃูƒุชุฑ ุณุจุจ ู„ุฎุณุงุฑุฉ marks.
  4. Self message ู„ู…ุง object ูŠูƒู„ู… ู†ูุณู‡ุŒ ุฒูŠ this.updateNum().
  5. Return values โ€” ู„ูˆ ุงู„ู€ method ุจุชุฑุฌุน valueุŒ ุงุธู‡ุฑ ุงู„ู€ return.