Object Oriented Development with UML 11 12 18
Object Oriented Development with UML 11 -12, 18 -19 November 2006 At Sipa Chiangmai Interaction Diagram โดย รศ. รงสต ศรรงษ อ. สายณห
State Daigram Activity Diagram Statechart Diagram UMLDiagram Implementation Diagram Package Diagram Static Structure Diagram Class Diagram Usecase Diagram Class Diagram Use case Component Diagram Scenerio Interaction Diagram Sequence Diagram De. Ployment Diagram Collaboration Diagram
Interaction Diagrams Sequence Diagram Collaboration Diagram y 1. 1: a 1. 2: c x z x a y b 1. 1. 1: b c z
Arrow Label guard-condition, sequence-expression, return-value : = message-name argument-list [ x < 0 ] C 3. 1: res : = get. Location (fig) guard Examples: sequence number move (5, 7) 3. 7. 4: move (5, 7) 3. 7 [ z > 0 ]: move (5, 7) 3. 7 *[1. . 5]: move (5, 7) condition iteration
Type Of Messages object 1 object 2 object 3 Simple Message Syncrhonous Asynchronous Recursive Return Message
A Sequence Diagram X-Axis (objects) member: Library. Member : Book Copy book: Book borrow(book) Y-Axis (time) ok = may. Borrow() Life Line Object message [ok] borrow(member) condition Activation box set. Taken(member)
การออกแบบ Account class Account} private double balance; public Account() { balance = 0{ ; public Account(double initial. Balance } ( balance = initial. Balance ; { public void deposit(double amount) { balance += amount{ ; public void withdraw(double amount } ( balance = balance - amount ; { public double get. Balance() { return balance{ ; public String to. String } () return Double. to. String(balance ; ( { {
การออกแบบ Customer class Customer} private Account account; private String name; public Customer(String a. Name} ( name = a. Name; account = new Account(0; ( { public String get. Name() { return name{ ; public Account get. Account() { return account{ public void add. To. Account(double amt} ( account. deposit(amt; ( { public String to. String} () return name + account; { { ;
การออกแบบ Customer public class Test { public static void main(String args} ([] Customer joe = new Customer("Joeseph Smith; (" joe. add. To. Account(1000; ( joe. get. Account(). withdraw(500; ( // joe. withdraw(100; ( System. out. println(joe; ( { {
Sequence Diagram
Collaboration Diagram
What is a collaboration? n n Collaboration: เปนการแสดง roles ของกลม instances ทใชในการทำงานหนง ๆ ทเกดขนภายใน use case Interaction: เปนการตดตอกนระหวาง instances ตาม roles ทกำหนดภายใน collaboration Collaboration Role role name Class Actor role name
Interactions - Links n n เปนสญลกษณทใชแสดงการเชอมตอระหวางออปเ จคโดยการสงแมสเสจระหวางกน เพอแสดงใหเหนวาคลาสมความสมพนธกนแบบ association หรอ dependency. Class Diagram Person + set. Com( s : Salary ) + assign( d : Department ) … 1. . * * employee employer Company anonymous object message Object Diagram assign( development ) p : Person named object : Company link
สญลกษณของ Collaboration ไดอาแกรม § สองออปเจคจากคลาสเดยวกนสามารถ collaborate กนได เชนในกรณของการ transfer funds จาก account A ไปยง account B: transfer() n account. A: Bank. Account deposit. Funds(out New. Total) account. A: Bank. Account สญลกษณลกศรจะนำเสนอ control flow ไมใช information flow ซงจะตองมหวลกศรสองทาง เชน Input และ Output โดย One implicit (in not necessary) และ another explicit (out)
Conditional Control n การกำหนดเงอนไขสามารถทำไดเชนเดยวกบ Diagram 1: set. Angle(landing. A, out. AF) AF=Ok 2: fix. Angel(out. FF) land() an. Air. Craft: Air. Craft n Sequence เชน [AF = OK] left. Flap: Flap
Example: Create order – class diagram Order Number Total No. Of. Products : Array. List Catalog Category Prod. Line Sales. Assistant product Events: 1. Create Order: 2. Catalog lookup 3. find product details by prod. No 4. Products are stored in Array. List
Sequence diagram Sales. Assistant : Sales. Assistant the. Order : product : Catalog initialize( ) get. Product(prod. No : Integer( find(prod. No : Integer( change( ) add. To. Array( ) close( ) calc. Total( ) display( )
Collaboration Diagram. 1. 2 add. To. Array( ) the. Order : Order. 1 initialize( ). 2 close( ). 3 calc. Total( ). 4 display( ) Sales. Assistant : Sales. Assistant . 1. 1 get. Product(prod. No : Integer(. 1. 1. 1 find(prod. No : Integer(. 1. 1. 2 change( ) : Catalog : product
Example: Create order – class diagram Order Number Total No. Of. Products : Array. List Sales. Assistant initialize() calc. Total() display() add. To. Array() close() Catalog Category Prod. Line get. Product(prod. No : Integer) : Integer product Events: 1. Create Order: 2. Catalog lookup 3. find product details by prod. No 4. Products are stored in Array. List find(prod. No : Integer) : Boolean change()
Modeling Different Levels of Abstraction Use Case Order Clerk Place Order Interaction Diagram at a High Level of Abstraction : Order Taker : Order Clerk Fulfillment submit. Order place. Order acknowledge. Order
Modeling Different Levels of Abstraction Use Case Order Clerk Place Order Interaction Diagram at a Low Level of Abstraction : Order Taker : Credit. Card Agen : Order Clerk submit. Order process. Card place. Order acknowledge. Order : Order Fulfillment : Billing Agent trigger. Bill
Sequence Diagram objects : Order Clerk : Order Taker : Credit. Card Agen : Order Fulfillment : Billing Agent submit. Order process. Card Time {process card < 1 minutes} place. Order acknowledge. Order This marks the end of the object’s life. This doesn’t show up in Rational Rose trigger. Bill Can you do this with Rose? lifeline Focus of control
Collaboration Diagram Object : Order Fulfillment 5: acknowledge. Order 4: trigger. Bill : Order Clerk 3: place. Order 1: submit. Order : Billing Agent Link 2: process. Card : Order Taker : Credit. Card Agen Message
- Slides: 48