Why Model Software?
Modeling ูุนูู ุจูุงุก abstraction ูููุงูุน: ุจูุชุฌุงูู ุงูุชูุงุตูู ุบูุฑ ุงูู ูู ุฉ ููุญุชูุธ ุจุงูู ูู ุฉ.
- Modeling = building an abstraction of reality.
- Abstractions = simplifications because:
- ุจูุชุฌุงูู irrelevant details.
- ุจูุฑูุฒ ุนูู relevant details ุจุณ.
- ู ุนูู Relevant ุจูุชุญุฏุฏ ุญุณุจ ูุฏู ุงูู model.
- ุงูู Software ุจูู ุฃูุชุฑ ุชุนููุฏุงู โ Windows 10 ุฃูุชุฑ ู ู 50 ู ูููู ุณุทุฑ ููุฏ.
- ู ุจุฑู ุฌ ูุงุญุฏ ู ุง ููุฏุฑุด ูููู ูู ุงูููุฏ ุฏู ููุญุฏู.
- ุงูููุฏ ู ุด ุณูู ุงูููู ููู ุทูุฑูู ุงููู ู ุง ูุชุจูุด.
- ูุญุชุงุฌ ุชู ุซููุงุช ุจุณูุทุฉ ูุฃูุธู ุฉ ู ุนูุฏุฉ.
๐ข Application Domain
ุงูู environment ุงููู ุงููุธุงู ุจูุดุชุบู ููู โ ู ุซูุงู Air Traffic Control: ุงูุทูุงุฑุงุชุ ุงูุฃุจุฑุงุฌุ ุงูุฑุงุฏุงุฑ.
โ ูุณุชุฎุฏู ูู Requirements Analysis.
๐ป Solution Domain
ุงูู technologies ุงูู ุชุงุญุฉ ูุจูุงุก ุงููุธุงู โ Classes, Databases, APIs, frameworks.
โ ูุณุชุฎุฏู ูู System Design & Object Design.
UML 80/20 Rule (Pareto)
ุชูุฏุฑ ุชู ุฐุฌ 80% ู ู ุงูู ุดุงูู ุจุงุณุชุฎุฏุงู 20% ู ู UML. ููุฑูุฒ ุนูู ุงูู 20% ุงูู ูู ูู.
| Diagram | View | ุงูุบุฑุถ |
|---|---|---|
| Use Case | Functional | ุงูู behavior ูู ุง ูุฑุงู ุงูู ุณุชุฎุฏู |
| Class | Static Structure | ุงูู objects ู attributes ู associations |
| Sequence โญ | Dynamic | ุชูุงุนู ุงูู objects ุนุจุฑ ุงูุฒู ู ูุชูููุฐ use case |
| State | Dynamic | ุงูู behavior ุงูุฏุงุฎูู ูู object ูุงุญุฏ |
Interaction Diagrams
Sequence + Communication diagrams. ุจูุณุชุฎุฏู ูู ููู ุฐุฌุฉ ุงูู dynamic aspects.
ุจุชูุณุชุฎุฏู ููู ุฐุฌุฉ ุงูู dynamic aspects ูููุธุงู :
- ุจุชุนุฑุถ ุฅุฒุงู ุงููุธุงู ุจูุดุชุบู.
- ุบุงูุจุงู ุจุชูุจูู ู ู use case + class diagram.
- ุงููุฏู: ููุถุญ ุฅุฒุงู ู ุฌู ูุนุฉ objects ุจุชููุฐ ุงูู interactions ุงูู ุทููุจุฉ ู ุน actor.
๐ Sequence Diagram
ุฃูุชุฑ ุดููุนุงู. ุจูุฑูุฒ ุนูู ุงูุชุฑุชูุจ ุงูุฒู ูู ููู messages. ุงูู ุญูุฑ ุงูุฑุฃุณู (vertical axis) = ุงูุฒู ู.
๐ธ๏ธ Communication Diagram
ุจูุฑูุฒ ุนูู ุงูู relationships ุจูู objects. ุงูุฒู ู ู ุด explicitุ ูุจุฏู ูุฏู ุจูุฑููู ุงูู messages.
- 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 ูุดุท ูููุง.
Notation Elements
Frame ยท Lifeline ยท Lifeline Names ยท Activation Boxes.
ุงูู Frame ูู ุงูุญุงููุฉ ุงูุฎุงุฑุฌูุฉ. ููู heading ุจุชุญุชูู ุนูู sd + ุงุณู
ุงูู interaction.
โ Time flows downward
ูู participant ุนูุฏู lifeline: ุฎุท ู ููุท ุนู ูุฏู ุชุญุช ุงูู box ุจุชุงุนู. ุงูุฒู ู (Time) ุจูู ุดู ู ู ููู ูุชุญุช.
| ุงูู Notation | ุงูู ุนูู |
|---|---|
seoclecturer | Object ุงุณู ู seoclecturer |
seoclecturer : Lecturer | Object ุงุณู ู seoclecturer ู ู class ุงุณู ูุง Lecturer |
: Lecturer | Anonymous object ู ู class ุงุณู ูุง Lecturer |
lecturer[i] : Lecturer | ุงูู Object ุงูู ูุฌูุฏ ุนูุฏ index ุงุณู ู i |
2. CourseSection โ Registration : โข create (dashed)
3. Registration โ Student : addToSchedule
4. Registration โ CourseSection : addToRegistrationList
Message Types โ 4 Types
ุงูุฏูุชูุฑ ุจูุญุจ ูุณุฃู ุนู ุงููุฑู ุจูู Synchronous, Asynchronous, Create, Reply.
๐ Synchronous Message
ุงูู Sender ุจูุณุชูู ูุญุฏ ู ุง ุงูู message ุชุชุนุงูุฌ ูุจู ู ุง ููู ู. ุฏู Wait semanticsุ ูุฏู ูู ุงูู method call ุงูุนุงุฏู.
โก Asynchronous Message
ุงูู Sender ู ุง ูุณุชูุงุด. ุฏู No-wait semantics. ู ููุด explicit returnุ ูุฏู ุจูุณู ุญ ููู objects ุชุดุชุบู concurrently.
โฉ๏ธ Reply Message
ุฏู ุงูู return value ู ู message ุณุงุจูุฉ. ุจุชุฑุณู ูู dashed line. ู ู ูู ุชุชุฌุงูููุง ูู ุงูู flow ูุงุถุญ.
๐ Create Message
ุจูุฎูู object ุฌุฏูุฏ ุฃุซูุงุก ุงูู interaction. ูู Java = constructor call (new ClassName()). ุงูู arrowhead ุจูุดุงูุฑ ููู object ุงูุฌุฏูุฏ.
Combined Fragments โ opt, loop, alt
ุงูู Frames ุฏู ุจุชุบูู ุฃุฌุฒุงุก ู ู ุงูู sequence ููุชุญูู ูู ุงูู control flow.
ุงูู messages ุฏุงุฎู ุงูู frame ุจุชุชููุฐ ูู ุงูู guard condition = true. ุฒู if.
:Registration โ :Student : addToSchedule
:Registration โ :CourseSection : addToRegistrationList
ูู ุงูู student ู ุง ุนูุฏูุด ุงูู prerequisiteุ ุงูู frame ุฏู ุจูุชุฎุทู ุจุงููุงู ู.
ุงูู messages ุจุชุชููุฐ ุนุฏุฉ ู
ุฑุงุช. ู
ู
ูู ุชุญุท range ุฒู 0..n ุฃู *.
:Purchase โ :Item : getUnitPrice
ุงุฎุชูุงุฑ ุจูู multiple paths ุจูุงุกู ุนูู ุดุฑูุท. ุฒู if/else ุฃู switch.
par โ Parallel (concurrent execution).break โ Like break in a loop, exits the current scope.ref โ ุงูุฑุฌูุน ูู sequence diagram ุชุงููุฉ (reusable).
Object Creation & Destruction
ุฅุธูุงุฑ ุญูุงุฉ ุงูู object: ู ู ูุญุธุฉ ุฅูุดุงุฆู ูุญุฏ ุชุฏู ูุฑู.
ุงูู Object ุงูุฌุฏูุฏ ุจูุธูุฑ ูู ุงููุต ุฃู ุชุญุชุ ู ุด ููู ู ุน ุงูู objects ุงูู ูุฌูุฏุฉ ู ู ุงูุจุฏุงูุฉ.
ุงูุณูู dashed arrow with open arrowhead ุจูุดุงูุฑ ููู box ุงูุฌุฏูุฏ. ุงูู box ูู ุงููู ุงูุณูู ุจููุตูู.
ูู ุงูููุฏ: ุฏู ุจูู
ุซู new ClassName().
ุงูู Object ุจููุชูู ุจุนูุงู ุฉ large X symbol ุนูู ุงูู lifeline ุนูุฏ ููุทุฉ ุงูู destruction.
ุงูู message ุงููู ุจุชุฏู ุฑ ุงูู object ุจุชุฎูุต ุนูุฏ ุนูุงู ุฉ X.
ู
ุซุงู: cancelBooking โ cancel โ :Booking ููุชูู ุจู X.
Library System โ Full Example โญ
ุงูุฏูุชูุฑ ุนู ู sequence diagram ูู Issue a Book ู ุน opt fragment. ุฑูุฒ ุนููู.
Actor: Librarian ยท Goal: Issue a book to a borrower if his status permits.
Main Scenario:
| Actor | System |
|---|---|
| 1- Enter user's ID | 2- Display info & user status |
| 3- If allowed to borrow, enter book copy ID | 4- 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.
ุงูู Objects ุงูู ุดุงุฑูุฉ (ู ู ุงูู classes ุงูู ูุฌูุฏุฉ):
- Librarian โ actor
- GUI โ boundary
- LibrarySystem โ control
- Catalog โ entity
- Book / BookCopy โ entity
- User / Record โ entity
Step-by-step:
Librarian โ GUI : checkUserStatus(ID)GUI โ LibrarySystem : checkUserStatus(ID)LibrarySystem โ User : checkStatus()โ returns status- Return "Allowed" to Librarian
- opt [if Allowed]:
Librarian โ GUI : IssueBook(title, ID)GUI โ LibrarySystem : SearchCatalog(title, auth)LibrarySystem โ Catalog : findBook(title, auth)โ returns BookLibrarySystem โ Book : getCopyInfo()LibrarySystem โ User : updateBorrowed()(self message)LibrarySystem โ BookCopy : updateAvailability()
- ูู step ูู ุงูู use case = message ุฃู ุงุชููู ูู ุงูู sequence.
- ูู method ุฌุฏูุฏุฉ ูุงุฒู ุชููู ูู ุงูู class diagram.
- ุฃุณู ุงุก ุงูู objects ูุงุฒู ุชููู underlined.
- ุงุณุชุฎุฏู 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.
Why Not Just Code It?
ุณุคุงู ุทุจูุนู: ูู ุงูู sequence diagram ูุฑูุจ ู ู ุงูููุฏุ ููู ูุฑุณู ู ุฃุตูุงูุ ุนูุฏูุง 4 ุฃุณุจุงุจ.
ุงูู sequence diagram ุจูุฑูุฒ ุนูู ุงูู interactionsุ ู ุด ุชูุงุตูู ุงูู syntax. ุงููู ุนุงูุฒ ูุดูู "ุฅุฒุงู ุงูู objects ุจุชุชููู " ููููู ู ุจุณุฑุนุฉ.
ููุณ ุงูู sequence diagram ู ู ูู ูุชููุฐ ูู Java, Python, C#, etc.ุ ูุงูู design ุจููุถู ู ุญููุธ ุจุบุถ ุงููุธุฑ ุนู ุงูู implementation.
Business analysts, project managers, clients ููุฏุฑูุง ูููู ูุง ุงูู flow ููุฑุงุฌุนูุง ุงูู design ู ู ุบูุฑ ู ุง ูููููุง programmers.
ุงูู Visual representation ุฃุณุฑุน ูู ุงูููู ู ู ุงููุต. screenshot ูุงุญุฏ ู ู ูู ูุฎุชุตุฑ ุฃูู ุณุทุฑ ููุฏ.
Practice Quiz โ Lecture 6
8 ุฃุณุฆูุฉ ุนูู Sequence Diagrams. ุงูู Question 2 ูู ูู ุงู ุชุญุงู final ููู 4 marks ุนูู sequence diagram. ุฑูุฒ.
: Lecturer. What does this mean?:Class = anonymous instance.
Lecturer ุจุฏูู ููุทุชูู. ยท
C โ ุงูู index ุจูุชูุชุจ lecturer[0]. ยท
D โ ูู sequence diagram ูุงุฒู
ุชููู instances ู
ุด classes.
:Booking object lifeline ุจููุชูู ุจู X.
new ClassName() ูู Java.
Cheat Sheet
ูู ุงููู ู ุญุชุงุฌู ูุฑุณู sequence diagram ูู Question 2.
๐งฉ Elements
๐จ Message Types
๐ผ๏ธ Combined Fragments
๐ท๏ธ Lifeline Names
โ Question 2 Checklist (4 marks)
๐ Concepts
Rapid Revision
Flashcards ยท Common Mistakes ยท What the doctor loves.
: ClassName (empty before colon)๐จ Common Mistakes
โญ What Dr. El-Ramly Loves
- Question 2 (4 marks) โ ุจูุฏู use case ููุทูุจ sequence diagram. ุงูู flow ู ู ูู ูููู Library / Email / Booking / Print order. ุฑูุฒ ุนููู.
- ุงุณุชุฎุฏู opt frame ูู ุง ุงูู flow ูููู conditional.
- ุทุงุจู ุงูู methods ู ุน ุงูู class diagram โ ุฃูุชุฑ ุณุจุจ ูุฎุณุงุฑุฉ marks.
- Self message ูู
ุง object ูููู
ููุณูุ ุฒู
this.updateNum(). - Return values โ ูู ุงูู method ุจุชุฑุฌุน valueุ ุงุธูุฑ ุงูู return.