Download presentation
Presentation is loading. Please wait.
1
Amirkabir University of Technology Department of Computer engineering & IT Software Engineering II Unified modeling Language (UML) April 2006 In the Name of GOD
2
2 Unified Modeling Language Table of Contents References OO Paradigm Modeling Overview of UML
3
3 Unified Modeling Language References 1- “The Unified Modeling Language User Guide”, Grady Booch, James Rumbaugh, Ivar Jacobson 2- “The Unified Modeling Language Reference Guide”, Grady Booch, James Rumbaugh, Ivar Jacobson 3- “Mastering UML with Rational Rose 2002”, Wendey Rogss, 2002, Cybex
4
4 Unified Modeling Language OO Paradigm در شي گرايي واحد برنامه ما کلاس است که طي آن اطلاعات و رفتار يک موجوديت پياده سازي مي شود. اصول : Encapsulation: کپسوله کردن بخشي از اطلاعات و رفتارهايي که بر اساس آن اطلاعات صورت مي گيرد درون يک شيء. مزايا : محدود کردن تاثيرات تغييرات سيستم مخفي کردن اطلاعات
5
5 Unified Modeling Language OO Paradigm Inheritance: در شي گرايي ارث بري مکانيزمي است که بر اساس آن مي توان يک شي بر اساس شي ديگر ايجاد کرد که در آن شي فرزند کيفيت شي پدر را به ارث خواهد برد. تغييرات در پدر بر فرزندان موثر است و نه بالعکس. Polymorphism: چند ريختي به معني داشتن چند شکل مختلف براي پياده سازي يک عملکرد است.
6
6 Unified Modeling Language Modeling Model: تعريف : تکنيک ثابت شده و صوری برای نمايش و بازنمايي اطلاعات هدف : نمايش ساده واقعيت Why Modeling: Big Problem n Smaller Problem اهداف : 1- نمايش وضعيت فعلي / آتي 2- تعيين ساختار و عملکرد سيستم 3- مبنايي براي توليد ( نرم افزار ) 4- مستند سازي
7
7 Unified Modeling Language Modeling اصول مدلسازي : 1- انتخاب مدل در نتيجه نهايي تاثير دارد. 2- هر مدل محدوديت برای ميزان نمايش دارد. 3- بهترين مدل : شبيه ترين به واقعيت 4- ديدگاه هاي مختلف درباره سيستم وجود دارد
8
8 Unified Modeling Language Modeling ديدگاه هاي مختلف سيستم در UML: 1- Use Case View: - Requirements and Features - Analyst 2- Design View: - Problem and Solution - Designer and Programmer 3- Process View: - Multithreading - Programmer 4- Implementation View: - Technologies - Programmer 5- Deployment View: - Hardware and Topology - Designer and Technologist نکته : بر حسب نوع برنامه، ممکن است بعضي view ها مهمتر باشند.
9
9 Unified Modeling Language Modeling
10
10 Unified Modeling Language Modeling ديدگاه هاي مختلف سيستم در Rational Rose: 1- Use Case View: Use Case View in UML Standard 2- Logic View: Design View and Process View in UML Standard 3- Component View: Implementation View in UML Standard 4- Deployment View: Deployment View in UML Standard
11
11 Unified Modeling Language Overview of UML سه مورد زير مباحث اصلي UML هستند : 1- Basic Building Blocks: The Vocabulary of the UML 2- Rules: Specify the Well-formed Model: Semantically Self-consistent and in harmony with all its related models. 3- Common Mechanisms: An UML model is made simpler by presence of common mechanisms
12
12 Unified Modeling Language Basic Building Blocks 1- Things Structural Things: - Class - Interface - Collaboration - Use Case - Active Class - Component - Node Behavioral Things: - Message - State Grouping Things: - Package Annotational Things: - Note
13
13 Unified Modeling Language Basic Building Blocks 2- Relationships Dependency رابطه استفاده چيزی از ديگري Association رابطه ساختاري Generalization (is-a) رابطه تعميم Realization رابطه تحقق بخشيدن
14
14 Unified Modeling Language Basic Building Blocks 3- Diagrams 1- Class Diagram 2- Object Diagram 3- Use case Diagram 4- Sequence Diagram 5- Collaboration Diagram 6- Statechart Diagram 7- Activity Diagram 8- Component Diagram 9- Deployment Diagram
15
15 Unified Modeling Language Basic Building Blocks - structural things 1- Class تعريف : اشياء که دارای خصوصيات مشابه، عملکرد مشابه، رابطه مشابه يا مفهوم مشابه هستند. نکته : اگر تعداد عملکردها زياد و نامرتبط با هم باشند، بهتر است کلاس به کلاسهاي ديگر شکسته شود.
16
16 Unified Modeling Language Basic Building Blocks - structural things 2- Interface تعريف : External Behavior Visible فقط تعيين مشخصات (Specification) بدون پياده سازي نکته : در کلاسهاي عادي که فقط يک قسمت Public دارند و از بيرون قابل دسترسي هستند. Interface مشخص نمي کنيم.
17
17 Unified Modeling Language Basic Building Blocks - structural things 3- Use Case تعريف : مجموعه عملياتهايي که نتيجه اي را در اختيار Actor قرار ميدهد نکته : - مفهموم Class و Use Case با هم متفاوتند. يک متد از يک کلاس اصلي مي تواند يک Use Case باشد. - Actor: کلاسي از سيستم که Active است و کار خاص مفيدي انجام ميدهد. ( فرد، سخت افزار، سيستم يا زير سيستم )
18
18 Unified Modeling Language Basic Building Blocks - structural things 4- Collaboration تعريف : مجموعه از کلاسهايي که با هم همکاري مي کنند تا نتيجه اي بدست آيد. نکته : - معمولا رابطه Use Case و Collaboration يک به يک است. - اگر Use Case کلي تر باشد ميتواند به چند Collaboration تجزيه شود ( رابطه کلي = 1 به n ) - 1 Use Case --- 0 … n Collaboration - 1 Collaboration --- 1 … n Class -1 Class --- 1 … n Collaboration - در Rational Rose از نام Use Case Realization استفاده ميشود.
19
19 Unified Modeling Language Basic Building Blocks - structural things 5- Active Class تعريف : کلاسي که از ديدگاه کاربر نهايي خودکار اجرا ميشود و کنترل فعاليتهايش را خودش بر عهده دارد نه مثل کلاس عادي که با درخواست کلاس ديگر سرويسي ارائه کند. نکته : - معمولا برنامه هاي سيستمي مانند سيستم عامل و سيستم مديريت پايگاه داده، سرويسهايي از نوع Active Class دارند.
20
20 Unified Modeling Language Basic Building Blocks - structural things 6- Component تعريف : يک عنصر فيزيکي و با قابليت جايگزيني که مجموعه اي از Interface را پشتيباني مي کند.
21
21 Unified Modeling Language Basic Building Blocks - structural things 7- Node تعريف : عنصر سخت افزاری که امکان پردازش دارد.
22
22 Unified Modeling Language Basic Building Blocks – Behavioral thing 1- Message تعريف : فراخواني Operation از شيء يک کلاس
23
23 Unified Modeling Language Basic Building Blocks – Behavioral thing 2- State Machine تعريف : وضعيت های مختلف يک شيء را نشان ميدهد. متشکل از چهار جزء است : 1- State 2- Event 3- Response 4- شيء
24
24 Unified Modeling Language Basic Building Blocks – Grouping Thing 1- Package تعريف : نوعي گروه بندي منطقي است که هر جزيي را شامل مي شود. Package ها داراي ساختار سلسله مراتبي هستند و ميتوانند تودرتو باشند.
25
25 Unified Modeling Language Basic Building Blocks – Annotational Thing 1- Note تعريف : توضيحات درباره دياگرام ها و اجزاء آنها در Rational Rose می توان از گزينه هاي Document Window و Attach File نيز استفاده کرد.
26
26 Unified Modeling Language Relationships 1- Association تعريف : رابطه ساختاري بين کلاس ها a relationship between classes indicates some meaningful and interesting c onnection a structural relationship that describes a set of links, a link being a conn ection between objects.
27
27 Unified Modeling Language Relationships 1- Association Association Notation:
28
28 Unified Modeling Language Relationships 1- Association Multiplicity: Multiplicity A defines how many instances of type A can be assoc iated with one instance of type B at some point Mother Child 1 1..* Actor Film * * performs-in Game Player 1 2..6 حالت ها مختلف برای Multiplicity : Exactly one - 1 Zero or one - 0..1 Many - 0..* or * One or more - 1..* Exact Number - e.g. 3..4 or 6 Or a complex relationship – e.g. 0..1, 3.. 4, 6..* would mean any number of objec ts other than 2 or 5
29
29 Unified Modeling Language Relationships 1- Association Multiplicity:
30
30 Unified Modeling Language Relationships 1- Association Aggregation: A Special Kind of Association تعريف : - Aggregation: whole/part relationships, Instances on one side are aggregates (or wholes) and the instances on the other side are their parts. - An association that models HAS-A relationships - The objects can exist independently or each other - No one object is more important than the other - An Aggregation relationship may be called isPartOf or consistsOF. SchoolStudent 0..* 1
31
31 Unified Modeling Language Relationships 1- Association Composition: A Special Kind of Association تعريف : - Composition: Strangle relationship, If the parts in the part-whole relationship are non-s hareable. - One can not exist without the other - Composition is a anti-symmetric and transitive relation. - In aggregation relationship, the part may be included in several aggregates and its ow ner may also change over time. SchoolDepartment 11..*
32
32 Unified Modeling Language Relationships 1- Association Examples for aggregation and composition relationships:
33
33 Unified Modeling Language Relationships 2- Dependency تعريف : رابطه استفاده کلاسي از کلاس ديگر. تغيير در کلاس B ممکن است بر روي کلاس A تاثير بگذارد. - occurs when one object depends on another - if you change one object's interface, you need to change the dependent object Directed is optional and label is optional.
34
34 Unified Modeling Language Relationships 3- Generalization تعريف : رابطه تعميم يا رابطه is-a. در کلاس ها معني توارث مي دهد، اما براي بقيه اجزاء نيز مي تواند استفاده شود. - Objects of the Specialized element (the child) are substitutable for objects of the generalized element (the parent). - The child shares the structure and the behavior of the parent. Child class is a sp ecial case of the parent class
35
35 Unified Modeling Language Relationships 4- Realization تعريف : رابطه تحقق يا عينيت بخشيدن. يکي از طرفين وظيفه پياده سازي طرف ديگرا را به عهده دارد. يک سمت، يک چيز واقعي و سمت ديگر چيز فرضي است. a semantic relationship between two elements, wherein one element guarantees to carry out what is expected by the other element. Where? Between interfaces and classes that realize them … Between use cases and the collaborations that realize them...
36
36 Unified Modeling Language Diagrams : Use Case تعريف : دياگرام مورد کاربرد بصورت گرافيکي رفتار سيستم را از منظر بيروني سيستم نشان مي دهد و بخشي يا تمام موارد کاربرد سيستم را نشان مي دهد. هدف : آناليز نيازمنديهاي سيستم براي اينکه نشان دهد سيستم چه کار ميکند البته توالي کار را نمايش نمي دهد. يک دياگرام مورد کاربرد عناصر زير را نشان مي دهد. 1- Actor: فرد، سيستم، خردسيستم، يا سخت افزاري که در سيستم نقش دارند. عملي را انجام داده يا نتيجه اي را دريافت ميکنند. 2- Use Case: مجموعه عملياتي که توسط Actor انجام ميشود تا نتيجه اي معيني را توليد کرده يا در اختيار Actor قرار دهد. - تعيين ” چه “ و عدم توجه به ” چگونگي “ What not How - فهرست امکانات سيستم، فهرست Use Case ها را نمايش ميدهد. - دياگرام مورد کاربرد در Use Case View کشيده ميشود. - دياگرام مورد کاربرد جزو دياگرام هايي است که جنبه ديناميکي سيستم را نشان ميدهد.
37
37 Unified Modeling Language Diagrams : Use Case مراحل رسم نمودار مورد کاربرد : بصورت کلي در براي رسم نمودارهاي مورد کاربرد سيستم بايد سه مورد را انجام داد : - شناسايي Actor ها و ارتباط آنها - شناسايي Use Case ها و ارتباط آنها - تعيين ارتباط Actor ها و Use Case ها وظايف : 1- شناسايي Actor ها : مثال : سيستم فروش : مشتري، فروشنده، مدير فروش، سيستم حسابداري، Admin سيستم و... 2- سازماندهي Actor ها : - گروه بندي (Packaging) - استفاده از رابطه Generalization در صورت لزوم - استفاده از Stereotype
38
38 Unified Modeling Language Diagrams : Use Case وظايف : 3- شناسايي عمليات هر يک از Actor ها : --- > فهرست Use Case ها
39
39 Unified Modeling Language Diagrams : Use Case وظايف : 4- سازماندهي Use Case ها : الف - استفاده از Package ب - استفاده از Stereotype ج - استفاده از Generalization
40
40 Unified Modeling Language Diagrams : Use Case وظايف : 5- شناسايي ارتباط بين Actor ها و Use case ها : فقط رابطه Association رابطه Association در نمودار مورد کاربرد مي تواند دو طرفه باشد : - Actor کاري انجام ميدهد. - نتيجه کار انجام شده در اختيار Actor قرار مي گيرد.
41
41 Unified Modeling Language Diagrams : Use Case وظايف : 6- شناسايي ارتباط Use case ها با کمک رابطه Dependency وقتي يک مورد کاربرد از ديگري استفاده مي کند، رابطه Dependency بين آنها برقرار است. جهت رابطه مهم است. در اين حالت دو Stereotype معروف استفاده ميشود : 1- >: عمليات B حين انجام عمليات A انجام ميشود. 2- >: عمليات B بصورت احتمالي ( انتخاب کاربر، شرايط موجود و...) پس از اجراي عمليات A انجام ميشود.
42
42 Unified Modeling Language Diagrams : Use Case يک مثال براي کليه روابط ممکن در نمودار مورد کاربرد :
43
43 Unified Modeling Language Diagrams : Activity Diagram تعريف : An Activity diagram shows the flow from activity to activity. An Activity is an ongoing nonatomic execution with in state machine. Activity result in some actions با استفاده از نمودار فعاليت ميتوان جريانهاي کاري را درسطوح مختلفي از سيستم مدل کرد. - جريان کاري در فرايند کل سيستم. - جريان کاري در فرآيند زير سيستم ها - جريان کاري در سطح موارد کاربرد (سناريوها) - جريان کاري در سطح کلاس ( يک متد از کلاس) - جنبه ديناميکي سيستم را مدل مي کند و اساسا مانند فلوچارت ميباشد. - براي مدل کردن جريانهاي کاري در سطح سيستم يا زيرسيستم ها بهتر است از نام موارد کاربرد براي نام فعاليتها استفاده کرد. - نمودارهاي Activity Diagram و ُStatechart با هم معادل هستند و هر دو حالت خاص از State Machine ها هستند. - Activity Diagram: Activity Centric Statechart: State Centric - Statechart براي مدل کردن رفتار Object در طول حيات آن استفاده ميشود.
44
44 Unified Modeling Language Diagrams : Activity Diagram Elements: 1- Activity State: يک فعاليت طولاني و قابل اينتراپت که ممکن خردفعاليتهاي ديگري داشته باشد. 2- Action State: يک فعاليت کوتاه که حالت اتميک دارد. مانند يک Method Call يا Pure Computation در Rational Rose ميتوان درون State ها، Action هاي مربوطه را مشخص کرد. ضمنا در RR بجاي Activity State از نام Activity استفاده ميشود. َ Activity: represents the performance of task or duty in a workflow. State: represents a condition or situation during the life of an object during which it satisfies some condition or waits for some event.
45
45 Unified Modeling Language Diagrams : Activity Diagram Elements: در RR درون هريک از Activity ها يا State ها ميتوان Action تعريف کرد که در حالات زير اتفاق مي افتند. · on entry: the task must be performed when the object enters the state or activity · on exit: the task must be performed when the object exits the state or activity · do: the task must be performed while in the state or activity until existing · on event: the task triggers an action only if a specific event is received. 3- Start/End State: - حالت شروع فقط يکي - حالت پايان 0 تا n عدد
46
46 Unified Modeling Language Diagrams : Activity Diagram Elements: 4- Transition: انتقال از فعاليت يا حالتي به فعاليت يا حالت ديگر. دو نوع دارد : - Trigger less: با اتمام عمل ( فعاليت ) قبلی، عمل بعدي شروع ميشود. بيشتر براي انتقال از Activity به Activity - Guarded: با کنترل شرط عمل بعدي آغاز ميشود. بيشتر براي انتقال از يک State 4- Branch Decision: زماني استفاده ميشود که مسير Transition بنابر حالات مختلف (Guard Conditions) فرق کند. پس شرط بر روي Transition گذاشته مي شود نه بر روي Decision.
47
47 Unified Modeling Language Diagrams : Activity Diagram Elements: 4- Fork & Join (Synchronization): تعريف Fork: تقسيم کنترل يک جريان کاري به دو يا چند جريان کاري همزمان. ( شروع عمليات همزمان ) تعريف Join: يکي کردن دو يا چند جريان کاري به يک جريان کاري. ( خاتمه همه عمليات هاي همزمان ) در RR اين دو را با استفاده از Synchronization انجام مي دهيم. که داراي دو نوع افقي و عمودي است. - بايد در Swimlane هاي مختلف صورت بگيرد. - تعداد Fork ها و Join ها بايد متوازن باشند. - Activity هاي موازي الزاما مستقل نيستند و احتمال عمليات همزمان وجود دارد که اصطلاحا آنها را Co-Routine مي گويند. ميتوان با Object Flow آنها را نشان داد.
48
48 Unified Modeling Language Diagrams : Activity Diagram Elements: 5- Swimlane: تعريف : براي جداسازي و تفکيک وظايف استفاده ميشود. - معمولا در مدلسازي Business براي تفکيک وظايف و مسئوليتها در جريان هاي کاري استفاده ميشود. - هر Swimlane ميتواند نام يک Actor ، يک کلاس، يک Object ، نقش يک کلاس، زيرسيستم ها، واحدهاي ومختلف سازمان و... باشد که نشان ميدهد آن فعاليت را چه کسي انجام ميدهد. - در Statechart ظاهر نميشود. - بخش هاي مختلف سازمان کانديداهاي خوبي برای Swimlane ها هستند. ( وظايف هر بخش و ارتباط بخش ها را نشان ميدهد )
49
49 Unified Modeling Language Diagrams : Activity Diagram Activity Diagram Use Case Sample :
50
50 Unified Modeling Language Diagrams : Class Diagram Definition: A class diagram is a diagram that shows a set of classes, and collaborations and their relationships - Class diagrams contain classes and object diagrams contain objects - Class diagrams are more prevalent than object diagrams. Normally you will build class diagrams plus occasional object diagrams illustrating complicated data structures - عمدتا در قسمت Logical view تهيه ميشود. جزو Structural Modeling ميباشد و جنبه Static سيستم را مدل ميکند. - در RR توصيه ميشود که دياگرام کلاس در سطح کل سيستم و نيز در سطح Package هاي منطقي تهيه شود. Use Class Diagrams To: Analysis: Show common roles and responsibilities of the entities that provide the system's behavior. Design: Capture the structure of the classes that form the system's architecture.
51
51 Unified Modeling Language Diagrams : Class Diagram - معمولا براي طراحي شيءگرا از چند لايه نرم افزاري برای ساخت سيستم استفاده ميشود که ميتواند مبنايي براي Package بندي کلاسها باشد. بطور مثال دياگرام کلاس زير روابط بين اين لايه ها را نشان ميدهد: - Class Diagram معمولا عناصر زير را در بر دارد: 1- Class 2- Interface 3- Collaboration 4- Dependency, Generalization and Association - جنبه رفتاري کلاسها (اشياء) با استفاده از دياگرامهاي زير صورت ميگيرد: 1- Interaction Diagram (Sequence or Collaboration Diagram) 2- Statechart Diagram 3- Activity Diagram
52
52 Unified Modeling Language Diagrams : Class Diagram - نام گذاري: اسم يا جمله اسميه - انواع کلاس: فرد، مکان، رويداد، شيء فيزيکي، مفاهيم، User Data Type، Enumeration،... اين موارد را ميتوان با Stereotype ها مشخص کرد.
53
53 Unified Modeling Language Diagrams : Class Diagram Visibility: Specify whether attribute or Operation cab be used by another classes. 1- Public: members of a class are accessible to all clients. This is the default access. 2- Protected: members of a class are accessible only to subclasses, friends, or to the class itself. 3- Private: members of a class are accessible only to the class itself or to its friends. 4- Friend (Implemented in RR): the class is accessible only by the implementation of the package containing the class.
54
54 Unified Modeling Language Diagrams : Class Diagram Multiplicity: نشان دهنده آن است که در يک لحظه حداکثر چند نمونه از آن کلاس ميتوانند وجود داشته باشند. - Syntax: min.. max - Cases: 0.. 1 بيشتر کلاسهاي ورود اطلاعات از اين دسته هستند 1.. 1 example: main form با حالت Abstract (No Instance) فرق دارد. 0.. 0 مانند کلاسي که تمام Operation هايش Class Scope باشد (توابع محاسباتي و رشته اي) که به آنها Utility Class گويند. Dim m as math s = m.sin(90) حالت هاي 0.. N ، 1.. N و N نيز استفاده ميشود. Attributes: - Syntax: [visibility] name [multiplicity] [:type] [= initial value] [{property}] - خاصيت Visibility مانند کلاس است. - خاصيت Multiplicity به معني آرايه بودن است که در RR نداريم. - خاصيت Property ميتواند يکي از مقادير Changable، Frozen و Addonly را داشته باشد.
55
55 Unified Modeling Language Diagrams : Class Diagram Property Cases: - هر ويژگي ميتواند يکي از حالات زير را داشته باشد. - Changeable (default): Read / Write - Frozen: Write Once فقط يکبار ميتوان به آن مقدار داد و بعد از آن قابل تغيير نيست. مانند: Const ، Auto number - AddOnly: براي Multiplicity > 1 معنا دارد. فقط اضافه ميشوند و مقادير قبلي حفظ ميشوند. مانند: حکم کارمندي Operations: - Syntax: [visibility] name [(in|out|inout) parameter name: type = default value,...)] [: return type] [{property}] Example: ConvertToGerog (PerDate: String = CurDate): Date - خاصيت Visibility مانند کلاس است.
56
56 Unified Modeling Language Diagrams : Class Diagram Generalization Relationship: A generalization is a relationship between a general thing (called the superclass or parent) and a more specific kind of that thing (called the subclass or child) Stereotypes: 1- implementation: child inherits the implementation of the parent but does not make public nor support its interfaces Constraints: 1- Complete: all children in the generalization have been specified in the model 2- incomplete: all children in the generalization haven’t been specified in the model
57
57 Unified Modeling Language Diagrams : Class Diagram Association Relationship: A association is a structural relationship, specifying that objects of one thing are connected to objects of another. - Navigation: Possibility to navigate from objects of one kind to objects of other kind. - Visibility: indicated in role name. 1- Public: objects at the end are accessible to any objects outside the association 2- Private: objects at the end are not accessible to any objects outside the association 3- Protected: objects at the end are not accessible to any objects outside the association, except for children of the other end
58
58 Unified Modeling Language Diagrams : Class Diagram Association Relationship: - Qualification: By given an object of workDesk an given a particular value of JobID, can navigate to zero or one object of ReturnedItem. - Composition and Aggregation: SchoolStudent 0..* 1 SchoolDepartment 11..*
59
59 Unified Modeling Language Diagrams : Class Diagram Realization Relationship: A realization is a semantic relationship between classifiers in which one classifier specifies a contract that another classifier guarantees to carry out.
60
60 Unified Modeling Language Diagrams : Class Diagram Example:
61
61 Unified Modeling Language Diagrams : Object Diagram تعريف : An Instance is a concrete manifestation of an abstraction to which a set of operation can be applied and which has a state stores the effects of operations. An Object is a instance of a class: concrete manifestation of a class - An object is something that takes up space in the real or conceptual world براي عناصر زير نيز ميتوان مفهوم Instance را در نظر گرفت. - Usecase - Node - Association - Component - When you model instances, you ’ ll place them in 1- Object Diagram (visualize their structural details) 2- Interaction and activity diagrams (visualize their participation in dynamic situations) 3- Class diagram (show the relationship of an object to its abstraction) - The classifier of an instance is usually static
62
62 Unified Modeling Language Diagrams : Object Diagram Object Name: every instance must have a name that distinguish it from other instances within its context. Object Operation: is declared in object ’ s abstraction Syntax: className.OperationName() ex.: trans.Commit()
63
63 Unified Modeling Language Diagrams : Object Diagram Object State: is all the properties of the object (usually static) + the current values of each these properties (usually dynamic)
64
64 Unified Modeling Language Diagrams : Object Diagram تعريف : An object diagram is a diagram that shows a set of objects and their relationships at a point in time (for model object structures) - An object diagram shows the existence of objects and their relationships in the logical design of a system - An object diagram is essentially an instance of a class diagram or static part of an interaction diagram To model an object structure: 1- Identify the mechanism: A mechanism represents some function or behavior of the part of the system that results from the interaction of a society of classes, interfaces … 2- For each mechanism, identify the classes, interfaces, … and their relationships. 3- Use scenario to walk through these things. Freeze that scenario at a moment in time and render each object that participates in the mechanism. 4- Expose the state and attribute value of each object. 5- Expose the links among these objects (instances of associations)
65
65 Unified Modeling Language Diagrams : Object Diagram Object Diagram Example1: در RR ، Object Diagram نداريم. ميتوان از Collaboration Diagram بدون Message و Note ها براي اين منظور استفاده کرد.
66
66 Unified Modeling Language Diagrams : Object Diagram Object Diagram Example2:
67
67 Unified Modeling Language Diagrams : Interaction Diagram تعريف : An Interaction is a behavior that comprise a set of messages exchanged among a set of objects within a context to accomplish a purpose. A Message is a specification of a communication between objects that conveys information with the expectation that activity will ensue. -Interaction Diagrams: 1- Sequence diagram تاکيد بر روي توالي 2- Collaboration diagram تاکيد بر نحوه ارتباط (ساختار ارتباط) - Context: 1- Collaboration 2- Operation 3- Class - Objects and Roles: 1- Concrete object 2- Prototypical object نکته: در صورت استفاده از object يک کلاس Abstract منظور تمام Object هاي کلاسهاي مشتق شده است.
68
68 Unified Modeling Language Diagrams : Interaction Diagram -Link: A Link is a semantic connection among object. an instance of an association or one object send a message to the another. Visibility Stereotypes: 1- Association: object is visible by association 2- Self: object is visible because it is the dispatcher of the operation. 3- Global: object is visible because it is in an enclosing scope. 4- Local: object is visible because it is a local scope. 5- Parameter: object is visible because it is a parameter. -Message: A Message is a specification of a communication between objects that conveys information with the expectation that activity will ensue. Message -> Action -> Change State Kinds of Actions: 1- Call: invokes an operation on an object 2- Return: returns a value to the caller 3- Send: send a signal to an object (Asynchronous call) 4- Create: creates an object 5- Destroy: destroys an object
69
69 Unified Modeling Language Diagrams : Interaction Diagram -Message Sequencing: Can explicitly model the order of the messages by prefixing each messages with a sequence number set apart by a colon separator. -Flow of Control: 1- Nested or Procedural شماره بصورت سلسله مراتبي پيش ميرود 2- Flat شماره بصورت سريال پيش ميرود
70
70 Unified Modeling Language Diagrams : Interaction Diagram - Object Lifetime: To specify if an object or link enters and/or leaves during an interaction Constraints: 1- New: instance is created during execution of enclosing interaction 2- Destroyed: instance is destroyed prior to completion of execution of enclosing interaction 3- Transient: is created during execution of enclosing interaction but is destroyed before completion of execution Modeling Flow of Control: The most common purpose of interaction diagrams is modeling the flow of control that characterizes the behavior of system, class or an individual operation. To model a flow of control: 1- set the context for the interaction 2- identifying which objects play a role. determine their initial attributes values, states and roles. 3- identifying the links and messages that connect them. Identifying stereotyps, constraints, parameters and return values 4-convey the necessary detail of the interaction.
71
71 Unified Modeling Language Diagrams : Interaction Diagram Kinds of Modeling Flow of Control: 1- by time: emphasize the time order of messages sequence diagram 2- by organization: emphasize the structural organization of the objects collaboration diagram
72
72 Unified Modeling Language Diagrams : Interaction Diagram تعريف : An Interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them. -Interaction Diagrams: 1- Sequence diagram تاکيد بر روي توالي 2- Collaboration diagram تاکيد بر نحوه ارتباط (ساختار ارتباط) - Contents: 1- Objects 2- Links امکان تبادل اطلاعات 3- Messages
73
73 Unified Modeling Language Diagrams : Interaction Diagram تعريف : A Sequence diagram is an interaction diagram that emphasize the time ordering of messages Appropriate features: 1- object lifetime: represents the existence of object over a period of time 2- focus of control: shows the period of time during which an object is performing an action X: Objects Y: Time
74
74 Unified Modeling Language Diagrams : Interaction Diagram تعريف : An Collaboration diagram is an interaction diagram that emphasize the structural organization of the objects. Appropriate features: 1- sequence number: to indicate the time order of a message 2- path and path streotype More complex flows: 1- iteration: by prefixing the sequencenumber with expression such as [i:=1..n] 2- branch: by prefixing the sequence number with condition clause such as [x>0]
75
75 Unified Modeling Language Diagrams : Interaction Diagram Modeling Techniques: 1- Modeling Flow of Control by Time Ordering
76
76 Unified Modeling Language Diagrams : Interaction Diagram Modeling Techniques: 1- Modeling Flow of Control Organization
77
77 Unified Modeling Language Diagrams : Statechart Diagram State machine: تعريف : A state machine is a behavior that specifies the sequence of states an object goes through during its lifetime in response to events, together with its responses to those events. A state is a condition or situation during the life of an object during which it satisfies some condition, performs some activity or waits for some event. An event is the specification of a significant occurrence that has a location in time and space. (trigger a state transition) A transition is a relationship between two sates indicating that an object in the will perform certain actions and enter the second state when a specified event occurs and specified condition are satisfied. An activity is ongoing nonatomic execution within a state machine. An action is an executable atomic computation that results in a change in state of the model or the return of a value. - state machine جنبه ديناميکي سيستم (رفتاري) را مدل ميکند و برخلاف interaction ، يک Object خاص را مدل ميکند.
78
78 Unified Modeling Language Diagrams : Statechart Diagram - state machine معمولا زمان حيات يک Object را مدل ميکند که ميتواند instance از يک کلاس، مورد کاربرد يا کل سيستم باشد. State machine can be visualized in two ways: 1- Activity diagram: focus on the activities that take place within the object. 2- Statechart diagram: focus on the event-ordered behavior of an object.
79
79 Unified Modeling Language Diagrams : Statechart Diagram A state is a condition or situation during the life of an object during which it satisfies some condition, performs some activity or waits for some event. A state is a several parts: 1-name 2-entry/exit action 3-internal transition: are handled without causing a change in state 4-substates: nested structure of a state involving 1-disjoint (sequentially active) or 2-concurrent substates 5-deffered events: a list of events that are not handled in that state but, rather, are postponed and queued for handling by the object in another state.
80
80 Unified Modeling Language Diagrams : Statechart Diagram A transition is a relationship between two sates indicating that an object in the will perform certain actions and enter the second state when a specified event occurs and specified condition are satisfied. - transition ميتواند چندين مبدا و چندين مقصد داشته باشد. در state هاي موازي معنا دارد. (join & fork) A transition has five parts: 1-source state 2-event trigger 3-guard condition 4-action 5-target state - اتفاق افتادن event بصورت مرتب و پيوسته چک ميشود ولي guard condition يکبار و آنهم بعد از روي دادن event ارزيابي ميشود.
81
81 Unified Modeling Language Diagrams : Statechart Diagram substates: A state that has substates that is, nested states is called composite state. A composite state may contain either concurrent or sequential substates. 1-sequential substates: After dispatching entry action (if any), control passes to the nested state and dispatching its entry action (if any) and reverse on exit.
82
82 Unified Modeling Language Diagrams : Statechart Diagram The most common purpose for use state machine: Modeling the lifetime of an object
83
83 Unified Modeling Language Diagrams : Statechart Diagram Statechart Diagram: تعريف : A Statechart diagram shows a state machine, emphasizing the flow of control from state to state. - Statechart is one of five diagrams to modeling dynamic aspects of system. - Activity diagram is a special case of a statechart diagram in which all or most of the states are activity states and all or most of the transitions are triggered by completion of activities in the source state. -Both activity and statechart are useful in modeling the lifetime of an object. activity diagram: shows flow of control from activity to activity statechart diagram: shows flow of control from state to state. - Statechart diagrams commonly contain: 1- simple and composite states 2- transactions, including events and actions
84
84 Unified Modeling Language Diagrams : Statechart Diagram Statechart diagram example:
85
85 Unified Modeling Language Diagrams : Component Diagram تعريف : A component is a physical and replaceable part of a system that conforms to and provides the realization of a set of interfaces - name: 1-simple name 2-path name
86
86 Unified Modeling Language Diagrams : Component Diagram components and classes: Similarities: 1-both may realize a set of interfaces 2-both may participate in dependency, generalization and association relationship 3-both may be nested 4-both may have instances 5-both may be participants in interactions Difference: classes represent logical abstraction; component represent physical thing. components may live on nodes, classes may not.
87
87 Unified Modeling Language Diagrams : Component Diagram Binary replaceability: - A component is substitutable. Support previous interfaces and provide new services through other services. Goal: create a system out of components and then evolve that system by adding new component and replacing old ones, without rebuilding the system. Kind of components: 1- deployment components: necessary and sufficient to form an executable system, such as DLLs and EXEs. 2- work product components: are essentially the residue of the development process, consisting of things such as source code files and data files. 3- execution components: are created as a consequence of an executing system. Such as a COM+ object, which is instantiated from a DLL. Components stereotypes: 1- executable: a component that may be executed on a node 2- library: a static or dynamic object library 3- table: a component that represents a database table 4- file: a component that represents a document containing source code or data 5- document: a component that represents a document
88
88 Unified Modeling Language Diagrams : Component Diagram تعريف : A component diagram shows a set of components and their relationships. - Modeling the physical aspect of OO systems - Shows the organization and dependencies among a set of components. Contents: 1-components 2-interfaces 3-realationships
89
89 Unified Modeling Language Diagrams : Deployment Diagram تعريف : A node is a physical element that exists and represents a computational resource, generally having at least some memory and often, processing capability. - name: 1-simple name 2-path name
90
90 Unified Modeling Language Diagrams : Deployment Diagram nodes and components: Similarities: 2-both may participate in dependency, generalization and association relationship 3-both may be nested 4-both may have instances 5-both may be participants in interactions Difference: - Components are things that participate In execution of a system; nodes are Things that execute components - Components represent the physical packaging of otherwise logical elements; nodes represent the physical deployment of components
91
91 Unified Modeling Language Diagrams :Deployment Diagram Connections: The most common kind of relationship between nodes is an association.
92
92 Unified Modeling Language Diagrams : Deployment Diagram تعريف : A deployment diagram is a diagram that shows the configuration of run time processing nodes and the components that live on them. Contents: 1-nodes 2-relationships - dependency - association
93
93 Unified Modeling Language UML Extension Mechanism Lightweight Extension Mechanism Heavyweight Extension Mechanism
94
94 Unified Modeling Language Lightweight Extension Mechanism Constraints Tagged Values Stereotypes
95
95 Unified Modeling Language Constraints (OMG Description)
96
96 Unified Modeling Language Constraints
97
97 Unified Modeling Language Tagged Values (OMG Description)
98
98 Unified Modeling Language Tagged Values
99
99 Unified Modeling Language Stereotypes (OMG Description)
100
100 Unified Modeling Language Stereotypes Decorative Descriptive Restrictive Redefined Evolutionary
101
101 Unified Modeling Language Stereotypes
102
102 Unified Modeling Language in Conclusion موضوعات پيشنهادي براي ادامه مباحث UML : 1- مدلسازي منطقي و فيزيکي با استفاده از UML 2- طراحي سيستمهاي بلادرنگ با استفاده از UML 3- طراحي سيستمهاي Multithread 4- Design patterns 5- بکارگيري UML در توليد نرم افزار با متدولوزي RUP End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.