1 / 48

ניתוח ועיצוב מערכות תוכנה אביב 2014

ניתוח ועיצוב מערכות תוכנה אביב 2014. Behavioral Modeling. Today’s Session. Sequence Diagrams State Machines. Behaviour Modeling. Behaviour models are used to describe the overall behaviour of the system.

india
Download Presentation

ניתוח ועיצוב מערכות תוכנה אביב 2014

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ניתוח ועיצוב מערכות תוכנהאביב 2014 Behavioral Modeling

  2. Today’s Session • Sequence Diagrams • State Machines

  3. Behaviour Modeling • Behaviour models are used to describe the overall behaviour of the system. • Objects interact to implement behaviour. This interaction can be described in two complementary ways, one of them is centred on individual objects and the other on a collection of cooperating objects.

  4. Structure diagram Class diagram Object diagram Component diagram Deployment diagram Package diagram Behaviour diagram Use Case diagram Activity diagram Interaction diagram Sequence diagram Communication diagram UML Diagrams

  5. Interactions 1 of 2 • An interaction is a behavior that comprises a set of messages exchanging among a set of objects with a context to accomplish a purpose. • Interactions are used to model the dynamic aspect of collaborations, representing societies of objects playing specific roles, all working together to carry out some behavior that’s bigger than the sum of the elements. 5

  6. Interactions 2 of 2 • Roles, links, messages, actions, and sequences • Modeling flows of control • Each interaction can be modeled in two ways: • by emphasizing its time ordering of messages, or • by emphasizing its sequencing of messages in the context of some structural organization of objects. 6

  7. Interaction Diagram Guide • Show interactions between instances in the model • graph of instances (possibly including links) and stimuli • existing instances • creation and deletion of instances • Kinds • Sequence diagram (temporal focus)  • Communication diagram (structural focus) 7

  8. Sequence Diagram Communication Diagram x y z 1.1: a1.2: c x y a b 1.1.1: b c z Interaction Diagrams 8

  9. Sequence Diagrams

  10. Sequence Diagrams X-Axis (objects) obj1 : Class1 obj2 : Class2 user Object Creation operate() Y-Axis (time) do (…) create (…) Message : Class3 Messages to self foo() Object Destruction Return Message Life line

  11. Sequence Diagram 11

  12. Is the specification of a communication among objects that conveys information with the expectation that activity will ensue. Sequence Diagram Message : SomeClass

  13. Syntax, Synchronous & Asynchronous • What is the difference? • (besides the Source / Source) a) b) c)

  14. Conditions (Guards) and parameters

  15. Structured controls (combined fragments) summarization of some common frame operators

  16. Structured control - alt

  17. Structured control - opt

  18. Structured control - loop

  19. Nested diagrams 4: return value

  20. Communication Diagram 20

  21. Sequence Diagram / Communication Diagram 21

  22. Sequence Diagram vs. Communication Diagram • Sequence diagrams are used when you want to look at the behavior of several objects within a single use case. Sequence diagrams are good at showing collaborations among the objects. • Communication diagrams emphasize the data links between the various participants in the interaction. • With communication diagrams we can show how the participants are linked together. 22

  23. NS Ticket service Destination Take ticket

  24. Class diagram of ‘NS ticket service’ including the classes ‘Ticket’ and ‘Destination’

  25. NS Ticket machine – use case text

  26. Sequence diagram – Buy ticket

  27. תרגיל 2013 מועד א' • קומפוננט ImageProcessing מקבל זרם של תמונות (frames) מהמצלמה. כל תמונה מועבדת ע"י ImageProcessing במקביל להגעה של תמונות חדשות ותוצאת העיבוד (objects, positions) נשלחת ל-SoundCreation. עבור כל האובייקטים ש-ImageProcessing גילה בתמונה, SoundCreation מייצר צליל מתאים ומעביר אותו יחד עם נתוני מיקום של האובייקט בתמונה ל-SoundPositioning. בתורו SoundPositioning מחשב את מיקום האובייקטים יחסית לראש של המשתמש (מתרגם מיקום בפיקסלים למיקום במטרים יחסית לראש) ומורה ל-SSR לנגן את הצלילים המתאימים במיקומים המתאימים. כל שלושת הקומפוננטות פועלות במקביל אחת לשנייה. ניתן לראות התנהגות זו גם במכונת המצבים שמופיעה בשאלה הבאה. • לצערו, שכח דני כיצד לתאר הודעות אסינכרוניות ב- Sequence Diagram כלומר הודעות שנשלחות במקביל ושליחתם לוקחת זמן. שתי תכונות אלו חשובות לתיאור נכון של התהליך. • השלם את הדיאגרמה שמופיעה מטה לפי התיאור הנ"ל.

  28. תרגיל 2013 מועד א'

  29. תרגיל 2013 מועד א'

  30. תרגיל 2013 מועד ב' • (5 נק) צייר Communication (collaboration) diagram של Sensory Substitution לפי התרשים למעלה.

  31. תרגיל 2013 מועד ב' • (5 נק) צייר Communication (collaboration) diagram של Sensory Substitution לפי התרשים למעלה.

  32. תרגיל 2013 מועד א' • דני החליט על ארכיטקטורה שבה לכל קומפוננט ראשי של המערכת יש מחלקה שמנהלת אותו ומטפלת בכל האירועים של ממשק משתמש כגון: לחיצות כפתורים, הזנות, וכו'. כמו כן, המחלקה מעדכנת את הממשק אם יש צורך. דני רוצה לשמור על הפרדה מוחלטת בין ממשק משתמש לבין הלוגיקה של המערכת ולכן אף מחלקה במערכת אשר איננה מוגדרת בפירוש כממשק משתמש לא תכיל אלמנטים של GUI.

  33. תרגיל 2013 מועד א' • מהן הבעיות בתרשים Profile selection at system startup ? צייר תרשים מתוקן מטה.

  34. תרגיל 2013 מועד א' • לפי Figure Manager classes ל-ConfigurationController אין גישה למנהלים אחרים • דני רוצה לשמור על הפרדה מוחלטת בין ממשק משתמש לבין הלוגיקה של המערכת • חסר אתחול של SoundPositioningController בניגוד לצעד 4 ב UC-3

  35. State Modeling

  36. What’s Missing in Behavior Modeling? • Using an interaction, you can model the behavior of a set of objects that work together. • Using a state machine, you can model the behavior of an individual object whether its an instance of a class, use case, or even an entire system (a set of classes). • The behavior of an object that must respond to asynchronous messages or whose current behavior depends on its past is best specified by a state machine. • We need some language for modeling the behavior of an individualobject, in order to: • Model how an object responds to events • Enumerate the possible states of an object • Model how the history of an object can affect its behavior

  37. H Elements of a State Diagram

  38. Transition event –name [guard-condition] / action State 1 State 2 Conditions that must be met for the transition to take place. The action that takes place when the transition is taken The event that triggers the transition close Open Closed close[balance=0] Open Closed close[balance=0]/moveToArchive() Open Closed

  39. States: Initial, Transitions and Final Initialize variables on the action clause of the initial pseudo-state transition. after (2 seconds) / send ping signal /target = null targetAt(p) [isThreat(p)] / addTarget(p) Sometimes tm is used instead of ‘after’, indicating ‘timer’. (i.e. tm(2 seconds).The timer is individual per state, and is restarted upon each entry.

  40. Taking Class Example: Nested, Parallel States

  41. Self Transition and Internal Action ? If occurrence event1 then calls: Activity3, Activity1, Activity2 If occurrence event1 then calls: Activity1 A state can also define a “ do/Activity” clause – an activity performed during the state; the activity is interrupted when a transition fires.

  42. ATM (History, Aggregated Transitions) • Model an ATM that can: • Wait for customers. • Be in maintenance mode (for instance: when replenishing the cash store). • Upon insertion of a credit card it will validate the card and process the client requests. • The former action can be cancelled before completion.

  43. ATM - Solution

  44. History H 1. Notice that real-life ATM machines do not have history! This is just an example. 2. In this case there is no difference between shallow and deep history.

  45. ATM (cont.) • What if we wanted to state that from every state in the “active” composite state you can transition to the “selecting” state upon a certain event? H

  46. ATM (cont.) - Reducing Transitions Reducing transitions is important for: avoiding error prone situations and increasing readability.

  47. מועד א' 2013 עזור לדני להשלים את מכונת המצבים בעמוד הבא. • דני רוצה שמשתנה time יציין כמה זמן שוהה המערכת במצב Experiment is running. • השלם את מכונת המצבים כך ש-Sensory Substitution יפעל ויפסיק יחד עם שעון העצר.

  48. מועד א' 2013

More Related