Object Oriented Analysis and Design

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Object oriented Analysis and

Design
Lecture 4

Methodology and UML


Dr.Abdualmajed Alkhulaidi
Associate professor at Sana’a University
Doctor of Philosophy in Software
Engineering
Collaboration Diagram
A collaboration diagram is a diagram that shows how objects
interact with each other.
If we develop object-oriented programs, if our program needs to
do anything, it will be through object collaboration.
Cooperation formats: Fundamentals
- The row in the collaboration diagram
symbolizes it.

- The object in the collaboration diagram is


symbolized.
Cooperation formats: Fundamentals
If we want an object to communicate with
another object.
In the following example, we want to connect
the Bet object with the account object.
We can send a message from one object to
another. Here is where the Bet object is
Sends a message to the Account object.
Collaboration Diagram
Collaboration Diagram
Sequence Diagram
The sequence diagram is a scheme of UML
schemes that is similar to a collaboration
diagram that describes how objects interact
with each other over time.
Rational Rose can represent UML charts
Such as the sequence diagram of the
cooperation diagram.
Sequence Diagram :
• Sequence diagrams are used to represent or model the flow of
messages, events and actions between the objects or components
of a system.
‫ مجموعة مهام) النجاز مهمه‬، ‫– يستخدم لعرض تسلسل االحداث (تبادل رسائل‬
‫محدده في جزء من النظام‬
• Time is represented in the vertical direction showing the
sequence of interactions of the header elements, which are
displayed horizontally at the top of the diagram.
‫) الالساسية المشاركة في انجاز‬life line ‫• يتم عرض مكونات النظام (تعرف باسم‬
‫احد المهام على المستوى العمودي و تظهر الرسائل التي يتم تبادلها على المستوي‬
‫االفقي للرسم‬
Sequence Diagram(cont …)
• Sequence Diagrams are used primarily to:
-: ‫• يستخدم ل‬
◦ Design, document and validate the architecture, interfaces
‫◦ تصميم و توثيق و التحقق من معمارية النظام و الواجهات‬
◦ Logic of the system by describing the sequence of actions that
need to be performed to complete a task or scenario.
‫◦ وصف طريقة عمل النظام و المهام التي يجب انجازها الداء الوظائف االساسية‬
‫للنظام ونوع البيانات التي يتم تبادلها‬
• Sequence Diagrams are useful design tools because they provide a
dynamic view of the system behavior which can be difficult to
extract from static diagrams or specifications.
‫• هذا النوع من التصميم (المخطط) مفيد النه يوفر وصف الداء النظام (طريقة تعامل‬
‫النظام مع اوامر المستخدم) التي من الصعب معرفتها بواسطة طرق التصميم االخرى‬
) static diagrams or specifications ‫(كل من‬
Sequence Diagram Drawing Elements:

• Actor:
Represents an external person or entity that
interacts with the system.
‫يمثل او يعرض المستخدمين (من يتفاعل مع النظام) للنظام من‬
‫اشخاص او نظم اخرى‬
‫‪Sequence Diagram Drawing‬‬
‫‪Elements(cont…):‬‬
‫‪• object :‬‬
‫‪Represents an object in the system or one of its components.‬‬
‫يعرض احد اجزاء النظام او مكوناته (مثل المستخدمين للنظام او احد اجزائه‬
‫كقاعدة البيانات مثال تعتبر جزء من النظام)‬
Messages in Sequence Diagram:
 Simple massage:
:‫ يستخدم هذا النوع عندما‬
◦ One object sends a message to object
‫◦ يرسل احد اجزاء النظام رساله لجزء اخر‬
◦ The sender does not care what happens to the message
‫◦ في هذه الحالة ال يهتم المرسل بما يحدث لهذه الرسالة‬
◦ Useful when the recipient can not be controlled
‫◦ مفيده في حالة ان المستقبل ال يمكن التحكم بطريقة ادائه للمهمة‬
◦ Simple messages can be used to represent interactions between
components that are not direct method calls (could be http or web
services)
‫◦ و يمكن استخدامه ايضا في حالة عرض التفاعل بين جزء من النظام مع مكون خارجي قد‬
‫تكون خدمة انترنت مثال‬
Messages In Sequence Diagram(cont .)
• Synchronous Message:
: ‫• الرسائل المتزامنه وهي كاالتي‬
– The sender sends the message
‫– يقوم الطرف االول باالرسال‬
– The recipient accepts the message, and notifies the sender with a
message result.
‫– يستقبل الطرف االخر الرسالة و يعلم المرسل ان رسالته قد وصلت بالرد عليها بناتج‬
‫العملية‬
– The sender accepts the message result.
‫– يقوم المرسل باستقبال ناتج العمليه‬
Messages In Sequence Diagram(cont .)
• If the sender does not accept the message result, then the
whole operation will not continue.
‫• ستوقف النظام عن اداء اي مهمه لحين استقبال الرد من الطرف االخر‬
• Synchronous messages are useful to represent procedure calls
or modal dialogs.
‫• الرسائل المتزامنه مفيده في حالة نداء دوال محددة و انتظار القيمة الناتجة منها او‬
‫انتظار المستخدم الدخال بيانات محددة علي شاشة الحوار‬
Messages In Sequence Diagram(cont .)
• Asynchronous Message:
: ‫• الرسائل غيرالمتزامنه‬
– The sender sends the message.
‫– يقوم الطرف االول باالرسال‬
– The sender does not wait for the return of the message, it
immediately continues execution.
‫– ال يتوقف المرسل لحين رجوع الرد على رسالته و انما يواصل مباشرة تنفيد الخطوة‬
‫التاليه من مهامه‬
– The recipient may or may not send a reply.
‫– المستقبل قد يستقبل الرساله او ال يستقبلها‬
Messages In Sequence Diagram(cont .)
• Asynchronous messages are useful to model:
: ‫• الرسائل غير المتزامنه مفيدة في االنظمة التالية‬
– Multithreading)‫(االنظمة المتعددة‬
– Exception Handling )‫(معالجة اخطاء التنفيذ‬
– Modeless dialogs )(
Messages In Sequence
Diagram(cont .)
• Timeouts Message:
:‫الؤسائل ذات الزمن المحدد‬
– The sender sends the message
‫– يقوم الطرف االول باالرسال‬
– The sender awaits for the return of the message for some time.
‫– ينتظر المرسل الرد لفترة زمنية محددة‬
– Execution continues when the recipient replies, or after the
timeout period if the recipient does not reply
‫– يقوم المرسل باكمال اداء مهامه بمجرد استقبال الرد او بعد نهاية الفترة الزمنيه‬
‫المحددة اذا لم يستقبل شئ‬
– The recipient may or may not send a reply.
‫– المستقبل قد يجب علي الرسالة او قد ال يجيب‬
Messages In Sequence Diagram(cont .)
• Timeout messages are useful to model:
‫• الرسائل محددة الزمن مفيدة في تمثيل‬
– System Calls
Messages In Sequence Diagram(cont .)
• Return Message:
– Return messages indicate a response to a call
message, although they can also be used with
simple messages to represent request/response
pairs.
‫– توضح او تمثل االجابة علي رسائل سابقة و يمكن استخدامها مع ال‬
‫ لعرض الرد علي نداء سابق‬simple message
Messages In Sequence Diagram(cont .)
• Create Message:)‫(رسائل االنشاء‬
– The message creates the recipient.
‫– هذه الرسالة تقوم بإنشاء المستقبل‬
– Create messages are used to represent the dynamic creation of an object
instance. They can also be used to represent the creation of a thread or
task.
‫ محدد عند‬class ‫ من‬object ‫– يتم في هذه الحالة انشاء المستقبل في لحظة االرسال (مثل عمل‬
thread ‫الحاجة) و تستخدم ايضا عند انشاء‬
• Destroy Message (‫)رسائل الحذف‬
– The message destroys the recipient.
‫– هذه الرسالة تقوم بإنهاء و حذف المستقبل‬
– Destroy messages are used to represent the dynamic destruction of an
object instance. They can also be used to represent the destruction of a
thread or task.
‫ محدد عند‬object ‫– يتم في هذه الحالة حذف المستقبل عند ارسال هذه الرسالة (مثل حذف‬
thread ‫الحاجة) و تستخدم ايضا لحذف‬
Example:

: Customer

1. Create : Order

2. Destroy
Messages In Sequence Diagram(cont .)
• Self Message:
: ‫• الرسائل الذاتية‬
• A self message can represent a recursive call of an operation,
or one method calling another method belonging to the same
object. It is shown as creating a nested focus of control in the
lifeline’s execution occurrence.
‫• يتم استخدامها في حالة النداء الذاتي (نداء العملية لنفسها) او ان احد الدوال تقوم‬
‫ و تظهر كسهم لنفس الجزء‬object ‫بنداء دالة اخرى تابعه لنفس ال‬
Messages format
• Messages have sequence numbers
– The numbers represent the order of interaction
‫– الرسائل لها ترقيم يوضح ترتيب تنفيذها‬
• Messages have sequence numbers
– Sequence number can be hierarchical
‫ و‬1.1 ‫– هذه االرقام يمكن تجزئتها و عرضها بشكل هرمي مثل‬
‫هكذا‬
[Condition] Sequence Number. Return value := MessageName(Arguments)

[Condition] Sequence Number. *[iteration] Return value := MessageName(Arguments)


Example :
: Customer : store

1. Create : Item
1.1. CheckStock

1.1.1. Yes
Sequence Diagram

You might also like