270 likes | 297 Views
Statechart diagrams in UML show dynamic system aspects, displaying a state machine's flow of control and system changes over time. They illustrate class or object statuses at different time points, showcasing behavior changes. The diagrams depict states, events, transitions, and concurrency in system execution, like a gas station example. Stateful sessions, systems, windows, transactions, and devices are examples of entities that benefit from Statechart Diagrams.
E N D
UML Statechart Diagram • The Statechart diagrams are one of the five diagram in the UML for modeling the dynamic aspects of systems. • هو احد طرق التمثيل الخمسه التي تعرض التغير علي النظام • A statechart diagram shows • a state machine. • flow of control from state to state. • يوضح هذا النوع : حالات جهازمحدد و شكل او شرط التغير من حالة لاخرى
UML Statechart Diagram(con.) • shows the different status of a class or object at different points in time • يعرض الحالات المختلفة للبرنامج (class) في نقاط زمنيه مختلفة • Use to illustrate aspects of a system that show interesting changes in behavior as time passes. • يستخدم لتوضيح او عرض التغيرات الهامة علي النظام مع تغير الزمن
Events and States • State – Is the condition of a object at a specific time. • هي حالة البرنامج في لحظة زمنية محددة • A telephone is on “idle” state until it is taken from the hook. • مثال: الهاتف يكون في الوضع المثالي الى ان يتم رفع السماعة • Event – Is an occurrence that triggered the state. • هو الشرط او حدث الذي يغير من حالة النظام • A telephone receiver is taken off the hook. • مثال: استقبال مكالمة (يتم رفع سماعة الهاتف)
Illustrating External and Internal Events • There are three types of events: • هنالك ثلاثة انواع للاحداث: • External Event – Events caused by an outside actor, outside of the system’s boundary. • احداث خارجية: تتم بواسطة مستخدم او نظام اخر خارج حدود النظام • Internal Event – Events caused by an internal action, inside the system’s boundary. • احداث داخلية: تتم بواسطة مستخدم او نظام اخر داخل حدود النظام • Temporal Event – Events caused by a determined date or time clock. • احداث مؤقتة: تتم في تاريخ او زمن محدد
Transitions Transition – Involves going from one state to the other when an event occurs. الانتقال: هو تغير حالة النظام الى اخرى بناء على حدث معين Transitions are label in form: Event [Guard] / Action يتم تمثيلها بالشكل الحدث [الشرط]/ التصرف • When the event “off hook” occurs, transition the telephone from the “idle” state to the “active” state. • عندما يتحقق الشرط «استقبال مكالمة» تتغير حالة النظام من الوضع «مثالي» الى الوضع «يعمل او نشط »
Statechart Diagrams A Statechart diagram shows the lifecycle of an object state initial State event transition
Statechart Diagrams (Cont.) • The state diagram on the previous slide illustrates a simple telephone state chart diagram, with states, events and transitions. • المثال السابق يعرض طريقة عمل الهاتف باوضاعه المختلفه و الاحداث و الانتقال من حالة لاخرى • The states are shown in round rectangles. The transitions are shown with arrows, and the events are the labels in each transition. • حيث تظهر الحالة علي شكل مربع او مستطيل و يمثل الانتقال بسهم و لاحداث المختلفه تظهر على شكل نص على السهم
Concurrent State Diagrams • Sometimes, it is relevant to split the path of execution to two or more state diagrams • في بعض الاحيان يتم فصل شكل التنفيذ على اكتر من رسم واحد • These state diagrams represent paths of execution that execute concurrently • هذا النوع من الرسم يوضح انماط التنفيذ المتكررة • At some point, the paths of execution will join into the original execution path • في بعض الاحيان هذه الانماط المختلفة تلتقي في نقاط تنفيذ اساسية
A Gas Station Example In Service pumpGas tankFull Filling Gas Tank depart arrive beginWash endWash Washing Windshield
A Gas Station Example pumpGas tankFull Filling Gas Tank depart arrive beginWash endWash Washing Windshield Divergence Convergence
When to use Statechart Diagrams • The next slide contains a list of common state-dependant objects that might be worth illustrating in a Statechart diagram: • بعض انواع الانظمة التي تحتاج ان تمثل بواسطة هذا النوع :
Classes that benefit from Statechart Diagram • Stateful sessions – Server-side software objects • Systems – classes representing the system • Windows – window’s action “Edit-Copy” • Transactions – The way transaction respond to events • Devices – Microwave oven, Radio
Additional Statechart Diagram Notation • Additional features UML notation for statechart diagram: • بعض طرق التمثيل للاضافية • Transition actions • Transition guard condition • Nested states
Additional Statechart Diagram Notation (Cont.) • Transitions are what makes an action to fire, such as a method invocation. • A transition also can have a Boolean test, such as a guard, that only happens if the test succeeds. • الانتقال يمكن ان يكون اختبار لشرط محدد يتم فقط عندما يتحقق هذا الشرط • Nested states represents substates. The substate inherits the transitions of its superstate. • في حالة التداخل هذه يتم التفرع لاكثر من حالة جزئية ، كل منها يرث نفس الشروط الانتقال للحالة الاساسية
Additional Statechart Diagram Notation (Cont.) • Example of Transition action and guard notation
Statechart diagram from Sequence diagram: • The dynamic model provides two diagrams that model changes over time - Sequence Diagram - Statechart Diagram • The key to understanding the relationship between these diagrams is in understanding states and events • المفتاح لفهم العلاقة بينهما هي بفهم الحلات و الاحداث المختلفة للنظام
Statechart diagram from Sequence diagram: A basic Sequence diagram with events and transitions: Event1 Event2 A B C
Statechart diagram from Sequence diagram: • Each vertical column represents a portion of the total lifeline for one object. • كل خط رأسي يمثل جزء من عملية محددة على النظام • Each event directed at a lifeline represents an event that might trigger a change in that object. • كل سهم او حدث يتم رسمه قد يمثل تغير علي احد مكونات النظام • The space between events on the object lifeline represents a period of time when the object remains in the same state . المسافة بين الاسهم تمثل الفترة الزمنية التي يبقى بها النظام على نفس الحالة • The events pointing outward from the object lifeline represent either return values sent to other objects or send events .
How we determine the states: • The state of the object is defined by the values of one or more of its attributes. • Use these values to find adjectives that describe the object's condition . • For example, if one of the attributes indicates whether the object has been sold or not, then you might use sold and unsold as part or all of the state name.
How we determine the states: Event1 Event2 Event1/C.event2 Return2 Retuen2/return1 Return1 A B C Draft SD for object B State name1 State name2 State name3
Example showseat : select select purchasecancel Use case : Purchase show seat Customer showseat Customer showseat
Example showseat (con t): select select purchase purchase Customer showseat Price ,not held, not sold Price , held, not sold Price ,not held, sold
Example showseat (con t): select select cancel cancel Customer showseat Price ,not held, not sold Price , held, not sold Price ,not held, not sold
Example showseat (con t): Select cancel purchase Price Held Not sold Price Not held Not sold Price Not held Sold