Object Oriented Development with UML 7 10 November
Object Oriented Development with UML 7 – 10 November 2006 At Sipa Chiangmai Introduction to UML 2. 0 โดย รศ. รงสต ศ ร รงษ อ. สายณห
3 basic building blocks of UML - Diagrams UML 1. x: 9 diagram types. UML 2. 0: 12 diagram types Structural Diagrams Represent the static aspects of a system. u u u Class; Object Component Deployment Behavioral Diagrams Represent the dynamic aspects. u Use case u Sequence; Collaboration u u Statechart Activity u Class; Object Component Deployment Composite Structure u Package u u u Behavioral Diagrams u Use case Interaction Diagrams u Sequence; Communication u u Statechart Activity u u Interaction Overview Timing
UML 2. 0 Highlight of Changes list is not comprehensive n n n n n แนะนำแนวคดใหมเรอง Ports แนะนำไดอาแกรม Composite Structure Classes & Diagrams Class Diagrams – มการเปลยนแปลงเลกนอย Collaboration Diagram – เปลยนชอเปน Communication Diagram Sequence Diagram – มลกษณะเปน nesting options เพมไดอาแกรมใหมเขามาเรยกวา – Timing Diagram Activity Diagrams มการเปลยนแปลงมากทสดในทก ๆ ไดอาแกรม UML Use Case Diagrams – เพม multiplicity และเปลยนแปลงสวนทเปน extension points. Package Diagram ถอเปน official UML diagram
Component-Based Development n Interface-based design uตองการและจดเตร ยม interfaces เพอยอมใหแตล ะคลาสมการกำหนด ใหอยในรปของ entity เดยว n Encapsulation uคลาสจะถกมองในรปของ ”black box” uจำเปนตองทราบถง how ท interfaces นำไปใช Class «interface» Display Vending. Machine Display() No. Change() Out. Of. Order() Insert. Coin Provided interface Display Required interface
Specifying Communicating Classes n มเพยงคลาสท matching กบ interfaces เทานนทยอมใหม การตดตอสอสารกบส วนอน ๆ uสนบสนนการทำงา composite port นแบบ contracts n port ทำหนาทไดหลาย roles: uทำหนาทเปน unique interaction point ของคลาส uใหมมมองแกคลาส Controller Coin. Control Display p. Ctrl Maintenance Detector Insert. Coin Counter Coin. Control, Counter ๆ
Assembling Classes n class สามารถใชเปนสวนหน งของโครงสรางภายในของคลา สอน uhierarchical decomposition Connectors ถกใชในรปของ contextual associations uนำเสนอเสนทางการต ดตอสอสาร Class Part n Vending. Machine p. Ctrl Insert. Coin Counter : Detector Coin. Control Display Connector : Controller
Example: Interaction Context n ทก ๆ การปฏสมพนธทเกดขนภายในโครงสรางของ collaborating parts u เปนโครงสราง context สำหรบการตดตอสอสารระหวางกน Interaction Context: Structured Class or Collaboration Go. Home. Service. Context sd Go. Home sd Service. User Authorization Interactions : Service. User : Service. Terminal Service. Base Internal Structure : Service. Base Part Service. Terminal
UML 2. 0 Changes Sequence diagrams can be “nested” using operators: sd – named sequence diagram ref – reference to “interaction fragment” loop – repeat interaction fragment alt – selection par – concurrent (parallel) regions seq – partial ordering (default) (aka “weak”) strict – strict ordering assert – required (i. e. causal) opt – optional “exemplar” neg – “can’t happen” or a negative specification n The message entry and exit points are called “gates” and allow tools to ensure that the diagrams are compatible and consistent with each other. * Quoted from I-Logix white paper http: //www. ilogix. com/whitepaper_PDFs n
Interactions (Sequences) n วตถประสงค : uกำหนดความตองการของระบบ uตรวจสอบตดตามการตดตอสอ สาร uสราง test cases และ test suites sd Trace : User : Vending. Machine Display(1) Insert(. 10) Display(. 90) Insert(. 50) Display(. 40) Insert(. 50)
Variations in Sequence Diagrams แสดงการทำงานไดหลายลกษ ณะ uparallelism และ alternatives uiterations และทางเลอกตาง ๆ uexceptions n ใชสำหรบการลดจำนวนของ sequence diagrams ทตองการในการแสดงฟงก ชนการทำงานของระบบ n sd Validate. Coin : User : Vending. Machine Insert(coin) alt else Display(price) Reject. Coin()
Decomposition n ปกปดขอมลโดยการแบง ในระดบรายละเอยดตอไป lifeline ออกเปน sequences sd Decomposition : Detector create sd Overview : Controller Insert(coin) : User : Vending. Machine ref Decomposition Insert(coin) Reject. Coin() Validate. Coin() Reject. Coin()
Referencing Sequences n เพอปองกนการซำซอนโดยไมจำเปน จงมความเปนไปไดทจะอางถง ทไดสรางไวแลว sequence diagrams sd Buy. Scenario : User ref : Vending. Machine Choose. Product Display(price) ref Validate. Coin
Organizing Sequences n เปนไปไดทจะจดการ sequence diagrams ใหอยในรปของ flows เพอระบการทำงานรวมกน u. Interaction Overview diagram = interaction diagram + activity diagram uรวม interactions ใหมลกษณะแตกตางออกไปเพอสราง scenarios ใหม sd Overview ref Initiate ref Validate. Coin [price=0] ref [else] Dispense. Product
Interaction Frame Interaction Occurrences Lifeline is one object or a part Interaction Occurrence Asynchronous message (signal) Combined (inline) Fragment
Combined Fragments and Data loop Choice Operand Separator Guarding Data Constraint
Activities: New Semantic Foundation n สนบสนนสญลกษณการทำงานของ statecharts) Un-structured graphs (graphs with “go-to’s”) Input pinu มโมเดลแบบ concurrency มากขน u Petri Net foundation (vs. Pre- and postconditions
Extended Concurrency Model n สนบสนน concurrent streams (“tokens”) Concurrency fork Concurrency join B C A Z X “Tokens” represent individual execution threads (executions of activities) Y Trace: A, {(B, C) || (X, Y)} , Z
UML 2. 0 New Terms n Use Case Diagrams * u มการกำหนดจำนวน Use Case Multiplicities ทเสนแสดงความสมพนธระหวาง actors และ use cases u คำจำกดความของ multiplicities ทใชภายใน use case diagram จะเหมอนกบทใชใน class diagram u Extension Points - เปนเงอนไขจาก UML 2. 0 เพอแสดงลอจกการทำงานทจำเปนจาก use case หนงไปยง case อน ๆ ซงโดยปกตจะเปน extension point ทใชระหวางสอง use cases * What’s New in UML 2? The Use Case Diagram–by Randy Miller June 30, 2003 http: //community. borland. com/article/0, 1410, 30166, 00. html use
Use Cases n เครองหมาย เทาใดนก use cases จะไมแตกตางไปจาก UML 1. 4 Vending. Machine Buy. Item «include» User Validate. Coin Refill Service. Man
State Machine Improvements n n เพมโครงสรางใหม : u Modularized submachines u State machine specialization/redefinition u State machine termination u “Protocol” state machines Ftransitions pre/post conditions Fprotocol conformance Notational enhancements u action blocks u state lists
Modular Submachines: Definition Submachine definition Read. Amount. SM abort EXIT point select. Amount other. Amount amount Enter. Amount aborted ok again ENTRY point
Modular Submachines: Usage invoked submachine ATM Verify. Card accept. Card out. Of. Service Out. Of. Service Read. Amount : Read. Amount. SM aborted again reject. Transaction usage of entry point Verify. Transaction usage of exit point release. Card Release. Card
Specialization n ใชงานเปนสวนหนงของการแสดงรายละเอยดการทำงา นของคลาส ATM Behaviour Statemachine accept. Card() out. Of. Service() amount() <<Redefine>> Flexible. ATM Behaviour Statemachine other. Amount() reject. Transaction()
Internal Structure and Behavior n พฤตกรรมการทำงานสามารถใชรวมกบโครงสรางภายใน uเชน state machine Behavioral ports Behavior (of Sensor) Sensor Maintenance Sensor. Initiation p. M p. S Input : Monitor[*] Regulator
Symbols for drawing UML 2. 0 Client ref User Authorize. Car d «sut» ATM «test. Component» Client Card. Inserted Note pass fail sig 1 sd Valid. PIN +role Class Attribute Operation «stereotype» Class Attribute Operation * alt
Tools supporting UML 2. 0 n n n n n Altova UModel 2005 ARTi. SAN's Real-time Studio Borland Together 2006 for Eclipse Computas' Metis with UML 2. 0 Template Embarcadero Describe IBM Rational Software Architect and Modeler I-Logix Rhapsody Meta. Matrix Meta. Base Modeler Mia Software (Sodifrance) Model-in-Action No Magic's Magic. Draw UML
Tools supporting UML 2. 0 continued……. . OMONDO Eclipse. UML Studio n Pathfinder Solutions' Path. MATE 5. 2 n Open Source Star. UML sponsored by Plastic Software n Sparx Systems Enterprise Architect n Sun Microsystems' Java Studio Enterprise n Pattern Weaver Ver. 2. 0 Technologic Arts Inc. (Japanese) n Telelogic's TAU Developer and TAU Architect n Gentleware's Poseidon for UML n Visual Paradigm's Smart Development Environment tool series List of tool obtained from: http: //www. uml. org/#Links-UML 2 Tools By OMG n
- Slides: 31