Скачать презентацию Details of UML and Unified Process Koichiro OCHIMIZU Скачать презентацию Details of UML and Unified Process Koichiro OCHIMIZU

ec9b2e3fbcb9dad6ea428f5686f0ccd2.ppt

  • Количество слайдов: 168

Details of UML and Unified Process Koichiro OCHIMIZU School of Information Science JAIST 2018/3/16 Details of UML and Unified Process Koichiro OCHIMIZU School of Information Science JAIST 2018/3/16

Use-Case View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Use-Case View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Use Case Model : A use case model represents the functional requirements and consists Use Case Model : A use case model represents the functional requirements and consists of actors and use cases. A use case model helps the customer, users, and developers agree on how to use the system. Actor: An actor is someone or something that interacts with system. System: Black box provided with use cases Use Case: A use case specifies a sequence of actions  that the system can perform and that yields an observable result of value to a particular actor. I. Jacobson, G. Booch, J. Rumbaugh, ”The Unified Software Development Process”, 2018/3/16 Addison Wesley, 1999.

Development of Use Case Model • • Defining the System Finding Actors and Uses Development of Use Case Model • • Defining the System Finding Actors and Uses Cases Use Case Descriptions Defining Relationships between Use Cases • Verify and Validate the Model H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

What is an Actor ? • An actor is someone or something that Interacts What is an Actor ? • An actor is someone or something that Interacts with the system. • The actor is a type ( a class), not an instance. • The actor represents a role, not an individual user of the system. • Actors can be ranked. A primary actor is one that uses the primary functions of the system. A secondary actor is one that uses secondary functions of the system, those functions that maintain the system, such as managing data bases, communication, backups, and other administration tasks. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Finding Actors • Who will use the main functionality of the system ? • Finding Actors • Who will use the main functionality of the system ? • Who will need support from the system to do their daily tasks ? • Who will need to maintain, administrate, and keep the system working (secondary actor) ? • Which hardware devices does the system need to handle ? • With which system does the system need to interact ? • Who or what has an interest in the result (the value) that the system produce ? H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

What is a Use Case ? • A use case represents a complete functionality What is a Use Case ? • A use case represents a complete functionality as perceived by an actor. • A use case is always initiated by an actor. • A use case provides values to an actor. • A use case is complete. • Use cases are connected to actors through associations (communication association). • A use case is a class, not an instance. A instantiation of a use case is called a scenario. – Signing Insurance (Use Case) – John Doe contacts the system by telephone and signs for car insurance for the Toyota Corolla he just bought. (scenario) 2018/3/16 H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Finding Use Cases • Which functions does the actor require from the system ? Finding Use Cases • Which functions does the actor require from the system ? What does the actor need to do ? • Does the actor need to read, create, destroy, modify, or store some kind of information in the system ? • Does the actor have to be notified about events in the system, or does the actor need to notify the system about something ? What do those events represent In terms of functionality ? • Could the actor’s daily work be simplified or made more efficient through new functions in the system ? H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Logical View Component View Use-Case View Deployment View Concurrency View H. E. Eriksson and Logical View Component View Use-Case View Deployment View Concurrency View H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

A Simple model of an insurance business Insurance company 1 0. . * Insurance A Simple model of an insurance business Insurance company 1 0. . * Insurance contract 0. . * 1. . * Customer H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Finding Classes • Do we have information that should be stored or analyzed?   Finding Classes • Do we have information that should be stored or analyzed?   If there is any information that has to be stored, transformed, analyzed, or handled in some other way, then it is a possible candidate for a class.   The information might be concepts that must be always be registered in the system or events or transactions that occur at a specific moment. • Do we have external system ? If so, they are normally of interest when we model. • Do we have any patterns, class library, components ? If we have them from earlier projects, colleagues, or manufacturers, they normally contain class candidates. • Are there devices that system must handle ? • Do we have organizational parts ? • Which roles do actors in the business play ? There roles can be seen as classes; for example, user, system operator, customer, and so on. 2018/3/16 H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Visibility Invoice + amount : Real + date : Date + customer : String Visibility Invoice + amount : Real + date : Date + customer : String + specification : String - administration : String • + public referenced from classes other than the one in which they are defined – It violates Information hiding principle • - private cannot access it from other classes • # protected can access it from sub classes H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Default values Invoice + amount : Real + date : Date = Current date Default values Invoice + amount : Real + date : Date = Current date + customer : String + specification : String - administration : String = “Unspecified” • Assigned at the same time an object of the class is created H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

A class-scope attribute or a class variable Invoice + amount : Real + date A class-scope attribute or a class variable Invoice + amount : Real + date : Date = Current date + customer : String + specification : String - administration : String = “Unspecified” - number of invoices : Integer • A class variable (underlined) is shared by all objects of the class H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Property string Invoice + amount : Real + date : Date = Current date Property string Invoice + amount : Real + date : Date = Current date + customer : String + specification : String - administration : String = “Unspecified” - number of invoices : Integer + status : Status = { unpaid, paid} • Property string show the possible values explicitly H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Java implementation public class Invoice { public double amount; public Date date = new Java implementation public class Invoice { public double amount; public Date date = new Date(); public String customer; static private int number_of_invoices = 0; }; // Constructor, called every time an object is created public Invoice() { // Other initialization number_of_invoices++; Increment the class attribute } // Other methods go here H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Signature Car + registration number : String - data : Car. Data + speed Signature Car + registration number : String - data : Car. Data + speed : Integer + direction : Direction - administration : String + drive(speed: Integer, direction: Direction) + get. Data(): Car. Data • Signature: a return-type, a name, zero or more parameters H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Class-scope operation Figure size : Size pos : Position figcounter : Integer draw() get. Class-scope operation Figure size : Size pos : Position figcounter : Integer draw() get. Counter(): Integer • Access class-scope attributes • Creation of objects H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Visibility of Operation  Figure size : Size pos : Position + draw() + scale. Visibility of Operation  Figure size : Size pos : Position + draw() + scale. Figure(percent: Integer = 25) + return. Pos(): Position H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Default values of parameter Figure size : Size pos : Position + draw() + Default values of parameter Figure size : Size pos : Position + draw() + resize(percent. X: Integer = 25, percent. Y: Integer = 25) + return. Pos(): Position • figure. resize(10, 10) • figure. resize(37) • figure. resize() H. E. Eriksson 2018/3/16 percent. X=10, percent. Y=10 percent. X=37, percent. Y=25 percent. X=25, percent. Y=25 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Java implementation Figure - x: Integer = 0 - y: Integer = 0 public Java implementation Figure - x: Integer = 0 - y: Integer = 0 public class Figure { private int x = 0; private int y = 0; + draw() }; public void draw() { // Java code for drawing the figure } Figure fig 1 = new Figure(); Figure fig 2 = new Figure(); fig 1. draw(); fig 2. draw(); H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

UML notations Representation of Relationships between Classes Association Navigable Association Dependency Generalization Aggregation: whole-part UML notations Representation of Relationships between Classes Association Navigable Association Dependency Generalization Aggregation: whole-part association Composition: the same life span G. Booch, J. Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999. 2018/3/16

Multiplicity Person 1. . * owns 0. . * Car owned by owns Person Multiplicity Person 1. . * owns 0. . * Car owned by owns Person H. E. Eriksson 2018/3/16 0. . * Car and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

A class diagram describing an Insurance business Insurance Policy 0. . 1 1 Insurance A class diagram describing an Insurance business Insurance Policy 0. . 1 1 Insurance Company 1 0. . * Insurance contract 0. . * 1. . * Customer H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Object Diagram Author 0. . * name: String age: Integer Use 1. . * Object Diagram Author 0. . * name: String age: Integer Use 1. . * Computer name: String memory: Integer Bob: Author Bob’s PC: Computer name = “Bob J” age = 32 name = “ Dell 466” memory = 64 H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Recursive Association * wife Node * Connects H. E. Eriksson 2018/3/16 Person husband married Recursive Association * wife Node * Connects H. E. Eriksson 2018/3/16 Person husband married to and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Composite Clients use the Component class interface to interact with objects in the composite Composite Clients use the Component class interface to interact with objects in the composite structure. If the recipient is a Leaf, then the request Is handled directly. If the recipient is a Composite, then it usually forwards requests to its child components, possibly performing additional operations before and/or after forwarding. Component Client Operation() Add(Component) Remove(Component) Get. Child(int) Leaf Operation() * children Composite Operation() Add(Component) Remove(Component) Get. Child(int) forall g in children g. Operation() E. Gamma, R. Helm, R. Johnson, J. Vlissides, ”Design Patterns”, ADDISON-WESLEY, 1995. 2018/3/16

Object Diagram a. Composite a. Leaf E. Gamma, R. Helm, R. Johnson, J. Vlissides, Object Diagram a. Composite a. Leaf E. Gamma, R. Helm, R. Johnson, J. Vlissides, ”Design Patterns”, ADDISON-WESLEY, 1995. 2018/3/16

Java Implementation Insurance Company 1 contracts 0. . * Insurance Contract refers to // Java Implementation Insurance Company 1 contracts 0. . * Insurance Contract refers to // Insurance_company. java file public class Insurance_company { /* Methods */ // Insurance_company. Vector is a specialization of the // Vector class ensuring hard typing. Vector is a standard // Java class for dynamic arrays. private Insurance_contract. Vector contracts; }; // Insurance_contract. java file public class Insurance_contract { /* Methods */ private Insurance_company refer_to }; H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Qualifier * Canvas figure ID Figure “one to many” to “one to one H. Qualifier * Canvas figure ID Figure “one to many” to “one to one H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

OR-association Insurance company 1 0. . * Insurance contract 0. . * 0. . OR-association Insurance company 1 0. . * Insurance contract 0. . * 0. . An insurance contract cannot have associations to both company and person at the same time Insurance company 1 0. . * Company Person Insurance contract 0. . 1. . * Person H. E. Eriksson 2018/3/16 1. . * 0. . * {or} 1. . * Company and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Ordered Association Insurance contract 0. . * { ordered } 1. . * Customer Ordered Association Insurance contract 0. . * { ordered } 1. . * Customer H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Association Class A class can be attached to an association Queue Elevator Control * Association Class A class can be attached to an association Queue Elevator Control * Button 3 Elevator The association class is not connected at any of the ends of the association H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Ternary Association Insurance company 1 0. . * Insurance contract 0. . * 0. Ternary Association Insurance company 1 0. . * Insurance contract 0. . * 0. . 1 policyholder Insurance policy 1. . * Person H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

What is an Aggregation ? • Aggregation is a special case of association • What is an Aggregation ? • Aggregation is a special case of association • “whole-part”, “is-part-of” • Special kinds of aggregation – Shared Aggregation – Composition Aggregation Composition: The part has the same life span with the whole H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Aggregation * Navy Warship Contains This example is not so good. H. E. Eriksson Aggregation * Navy Warship Contains This example is not so good. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Shared Aggregation Team * * Person Members A team is composed of team members. Shared Aggregation Team * * Person Members A team is composed of team members. One person could be a member of many teams. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Composition Aggregation * * Window * * Text Listbox Button Menu H. E. Eriksson Composition Aggregation * * Window * * Text Listbox Button Menu H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Another Expression of Aggregation Window * Text * Listbox * Button * * Window Another Expression of Aggregation Window * Text * Listbox * Button * * Window Text Menu * H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16 * *

Generalization Vehicle Problem Fitness Property (reusability) Car Boat • Associations and Aggregation describe structure Generalization Vehicle Problem Fitness Property (reusability) Car Boat • Associations and Aggregation describe structure of the problem domain which we are interested in. • Generalizations describe concepts which are common to several problem domains. 2018/3/16

Generalization and Association Last year May problem domain 1 This year April problem domain Generalization and Association Last year May problem domain 1 This year April problem domain 2 purse drawer money stock container purse Next year 2018/3/16 drawer Problem domain 3 class purse{ } class money{ } class drawer{ } class stock{ } content money A A B stock B class A extend{ } class B extend{ }

Inheritance • Class inheritance • Interface Inheritance 2018/3/16 Inheritance • Class inheritance • Interface Inheritance 2018/3/16

Combination of Inheritance and Aggregation Canvas consists of Group draw() Polygon draw() * Figure Combination of Inheritance and Aggregation Canvas consists of Group draw() Polygon draw() * Figure {abstract} position: Pos draw(){abstract} * Line consists of * Circle draw() H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Java Implementation Figure {abstract} position: Pos draw(){abstract} * Group draw() abstract public class Figure Java Implementation Figure {abstract} position: Pos draw(){abstract} * Group draw() abstract public class Figure { abstract public void draw(); protected Pos position; }; public class Polygon extends Figure { public void draw(); Polygon { /* draw polygon code */ } draw() }; H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Constrained Generalization Overlapping Disjoint Class A Complete Incomplete {constraint 1, constraint 2, … , Constrained Generalization Overlapping Disjoint Class A Complete Incomplete {constraint 1, constraint 2, … , } Class B Class C H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Overlapping and Disjoint Vehicle {overlapping} Car Boat Amphibian H. E. Eriksson 2018/3/16 and M. Overlapping and Disjoint Vehicle {overlapping} Car Boat Amphibian H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Complete and Incomplete Person {Complete} Man Woman H. E. Eriksson and M. Penker, “UML Complete and Incomplete Person {Complete} Man Woman H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Refinement relationship Analysis Class Design Class • A refinement is a relationship between two Refinement relationship Analysis Class Design Class • A refinement is a relationship between two descriptions of the same thing, but at different levels of abstraction. • It can be also used to model different implementations of the same thing. • Support Configuration Management. • Support traceability In the model. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Derivation Car hire company 1 0. . * Hire contract 0. . * * Derivation Car hire company 1 0. . * Hire contract 0. . * * 1 Customer / VIP customer • can be computed from other associations and attributes. • The VIP customers are a derived association when company makes contracts with many customers. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Derived Attribute Article cost price sales price /profit { profit = sales price – Derived Attribute Article cost price sales price /profit { profit = sales price – cost price } H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Subset Constraint Member of 1. . * Politician 1 (subset} 1 Party leader of Subset Constraint Member of 1. . * Politician 1 (subset} 1 Party leader of H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Navigation Expression • • • set. Attribute set. role set. _~role set{ boolean expression Navigation Expression • • • set. Attribute set. role set. _~role set{ boolean expression } set. [ qualifier value } H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Template Parameterized class T, n: integer Array<Car, 100> Array <<bind>><Color, 50> Color Array H. Template Parameterized class T, n: integer Array Array <> Color Array H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Dynamic Model • State Diagram – Describe which states an object can have during Dynamic Model • State Diagram – Describe which states an object can have during its life cycle • Sequence Diagram – Describe how objects interact and communicate with each other – The primary focus in sequence diagrams is time • Collaboration Diagram – Describe how objects interact – But the focus in a collaboration diagram is space • Activity Diagram – Describe how objects interact – But the focus in an activity diagram is work H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Object Interaction ( Message ) • Synchronous – procedure call or other nested flow Object Interaction ( Message ) • Synchronous – procedure call or other nested flow of control • Return – return from a procedure call • Simple – Flat flow of control • Asynchronous – Asynchronous flow of control. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Defining behavior of the system by a state diagram Process Control System Ochimizu, Higashida, Defining behavior of the system by a state diagram Process Control System Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan 2018/3/16

What is a State ? on     init    help ! timeout Ochimizu, Higashida, What is a State ? on     init    help ! timeout Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan time Frozen Period 1 Frozen Period 2 on/Action init/Action    help/Action Not in Operation 2018/3/16 Power on Frozen Period 3 Monitoring Frozen Period 4 Period 5 timeout/Action Controlling Success of control/action Alarm on

State Model • Represent the behavior of an object by a state transition diagram. State Model • Represent the behavior of an object by a state transition diagram. 2018/3/16

Defining the behavior of philosopher and fork right-next use philosopher 0. . 1 0. Defining the behavior of philosopher and fork right-next use philosopher 0. . 1 0. . 2 fork left-next Each philosopher must use right next fork and left next one not used Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan 2018/3/16

Behavior of a Philosopher thinking eating end/ thinking end/ put down forks takes forks Behavior of a Philosopher thinking eating end/ thinking end/ put down forks takes forks eating 2018/3/16 Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan

State transition depends on the state of forks both side Event [guard] / action State transition depends on the state of forks both side Event [guard] / action State 1 State 2 Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan 2018/3/16

Detailed behavior of a philosopher [left-next fork is not used]/take a fork at left Detailed behavior of a philosopher [left-next fork is not used]/take a fork at left hand having a fork at left hand [right-next fork is not used]/take a fork at right hand 2018/3/16 Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan thinking waiting [forks at both side are not used]/take forks at both hands having two forks eating [right-next fork is not used]/take a fork at right hand /put having a fork at right hand [left-next fork is not used]/take a fork at left hand down forks

Passive Object and Active Object • Passive Object – It is activated when it Passive Object and Active Object • Passive Object – It is activated when it receives a message from other object ( work when being hit) • Active Object – It can change its state by itself and send a message to other object if necessary • In the case of philosopher – Philosopher’s state of hunger changes autonomously during thinking and eating. Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan 2018/3/16

Simplified behavior [left-next fork is not used]/take a fork at left hand thinking [forks Simplified behavior [left-next fork is not used]/take a fork at left hand thinking [forks at both side are not having a fork used]/take at left hand forks at both hands [right-next fork is not used]/take a fork at right hand 2018/3/16 eating /put down forks [right-next fork is not used]/take a fork at right hand having a fork at right hand [left-next fork is not used]/take a fork at left hand Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan

Defining the behavior of a fork not used take/taken put down/put down used Ochimizu, Defining the behavior of a fork not used take/taken put down/put down used Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan 2018/3/16

Class Diagram right-next philosopher name right hand left hand take at right hand take Class Diagram right-next philosopher name right hand left hand take at right hand take at left hand take at both hand put down both use 0. . 1 0. . 2 fork name state of use put taken left-next Ochimizu, Higashida, ”Object Modeling”, Addison-Wesley Publishers Japan 2018/3/16

Ochimizu, Higashida, ”Object Modeling”, Execution p 1 right-next left-next p 2 Addison-Wesley Publishers Japan Ochimizu, Higashida, ”Object Modeling”, Execution p 1 right-next left-next p 2 Addison-Wesley Publishers Japan f 1 left-next right-next left-next use p 3 p 4 f 2 f 3 right-next use left-next right-next f 4 left-next p 5 2018/3/16 right-next f 5

Initial State and Final State Invoice created Unpaid Invoice destroyed paying Paid H. E. Initial State and Final State Invoice created Unpaid Invoice destroyed paying Paid H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

A state diagram for an elevator On first floor go up Moving up arrived A state diagram for an elevator On first floor go up Moving up arrived Moving to first floor Moving down time-out arrived go up idle go down H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

State Transition State 1 do:activity 1 event-signature [guard]/action ^send-clause State 2 event-signature: event-name (parameter State Transition State 1 do:activity 1 event-signature [guard]/action ^send-clause State 2 event-signature: event-name (parameter list) draw (f: Figure, C: color) draw() send-clause: destination-expression. Destination-event-name (argument list) message sent during transition [timer=time-out] ^ self. go down ( first floor ) destination-expression: object or a series of objects H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Guard North/south may go strait Time-out [cars in N/S right lanes] North/south may turn Guard North/south may go strait Time-out [cars in N/S right lanes] North/south may turn right Time-out [no cars in N/S right lanes] time-out Time-out [no cars in E/W right lanes] East/west may turn right Time-out [cars in E/W right lanes] J. Rumbaugh, ”Object-Oriented 2018/3/16 East/west may go strait Modeling and Design”, Prentice. Hall, 199.

State Generalization Automatic transmission push R Neutral push N Forward First downshift push N State Generalization Automatic transmission push R Neutral push N Forward First downshift push N push F upshift stop Reverse upshift Third Second downshift J. Rumbaugh, ”Object-Oriented Modeling and Design”, Prentice. Hall, 199. 2018/3/16

Automatic Transition coins in (amount)/set balance Collecting money coins in (amount)/add to balance idle Automatic Transition coins in (amount)/set balance Collecting money coins in (amount)/add to balance idle cancel/refund coins [item empty] select (item) [change<0] do: test item and compute change [change=0] do: dispense item J. Rumbaugh, ”Object-Oriented 2018/3/16 [change>0] do: make change Modeling and Design”, Prentice. Hall, 199.

Sub diagram dispense item arm ready Do: move arm to correct row do: move Sub diagram dispense item arm ready Do: move arm to correct row do: move arm to correct column do: push item off shelf J. Rumbaugh, ”Object-Oriented Modeling and Design”, Prentice. Hall, 199. 2018/3/16

A state diagram for an elevator go up (floor) On first floor Moving up A state diagram for an elevator go up (floor) On first floor Moving up do: moving to floor arrived Moving to first floor Moving down do: moving to floor arrived go up idle timer = 0 do: increase timer go down (floor) [timer=time-out] H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Events in the state diagram correspond with operations within the class Digital~watch mode-button() inc/hours: Events in the state diagram correspond with operations within the class Digital~watch mode-button() inc/hours: =hours+1 modulo 24 Display do/ display current time mode~button Set hours do/ display hours inc/minutes: =minutes+1 modulo 60 mode~button Set minutes do/ display minutes mode~button H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Four types of events • Guard (Condition) becomes true. • Receipt of an explicit Four types of events • Guard (Condition) becomes true. • Receipt of an explicit signal from another object – The signal itself an object – This type of event is called a message • Receipt a call on an operation by another object (or by the object itself). – This type of event is also called a message • Passage of a designated period of time. – This is shown as a time-expression on state transitions. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

An event is an object too <<signal>> Input {abstract} device: Device time: Time <<signal>> An event is an object too <> Input {abstract} device: Device time: Time <> Mouse {abstract} up: Boolean down: Boolean x. Pos: int y. Pos: int <> Right Mouse Button <> Keyboard character: Char up: Boolean down: Boolean Idle input Send do / send(input) to corresponding class <> Voice Recognition commando : String <> Left Mouse Button H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

A state diagram for digital watch inc/hours: =hours+1 modulo 24 Display do/ display current A state diagram for digital watch inc/hours: =hours+1 modulo 24 Display do/ display current time mode~button Set hours do/ display hours inc/minutes: =minutes+1 modulo 60 mode~button Set minutes do/ display minutes mode~button H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Java program for digital watch (1/2) public class State { public final int Display Java program for digital watch (1/2) public class State { public final int Display = 1; public final int Set_hours = 2; public final int Set_minutes = 3; public int value; }; public class Watch { private State state = new State(); private Digital. Display LCD = new Digital. Display(); public Watch() { state. value = State. Display; LCD. display_time(); } H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Java program for digital watch (2/2) public void mode_button() { switch ( state. value) Java program for digital watch (2/2) public void mode_button() { switch ( state. value) { case State. Display: LCD. display_time(): state. value = State. Set_hours; break; case State. Set_hours: LCD. display_hours(): state. value = State. Set_minutes; break; case State. Set_minutes: LCD. display_minutes(): state. value = State. Display; break; } } public void inc() { switch ( state. value) { case State. Display: : break; case State. Set_hours: LCD. inc_hours(): break; case State. Set_minutes: LCD. inc_minutes() : break; } } } H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Message passing between two state diagram Remote Control On () Off On Off () Message passing between two state diagram Remote Control On () Off On Off () Play () On () Off () Stop () Play () Stop () CD Player On () Off Play () On/Play On/Stop Off () Stop () Off() / Stop () H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Or-substate and And-substate Running Or-substate Backward Forward And-substate Running Forward Backward Low speed High Or-substate and And-substate Running Or-substate Backward Forward And-substate Running Forward Backward Low speed High speed H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

History Indicator • is used to memorize internal state • Support roll-back • If History Indicator • is used to memorize internal state • Support roll-back • If a transition to the indicator fires, the object resumes the state it had last within that region • Shown as a circle with an H H H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Sequence Diagram • Sequence diagrams illustrate how objects interact with each other. • They Sequence Diagram • Sequence diagrams illustrate how objects interact with each other. • They focus on message sequences, that is, how messages are sent and received between a number of objects. • Sequence diagrams have two axes: the vertical axis shows time and the horizontal axis shows a set of objects. • The Instance form describes a specific scenario in detail • The Generic form describes all possible alternatives in a scenario, therefore branches, conditions, and loops may be included. : H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

The Concepts used In a sequence diagram Print( ps-file) :Computer Simple message :Printer Server The Concepts used In a sequence diagram Print( ps-file) :Computer Simple message :Printer Server Print( ps-file) :Printer [no queue] Print( ps-file) Object Activation Synchronous message Guard Lifeline H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Sequence diagram with Branch Print( ps-file) :Computer :Printer Server Print( ps-file) :Printer :Queue [no Sequence diagram with Branch Print( ps-file) :Computer :Printer Server Print( ps-file) :Printer :Queue [no queue] Print( ps-file) [printer busy] Store( file) H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Timing Constraint Print( ps-file) :Computer { b - a < 5 sec} a { Timing Constraint Print( ps-file) :Computer { b - a < 5 sec} a { b’- b < 1 sec } b :Printer Server :Printer Print( ps-file) b’ H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Iteration op 1 () C 1:C send message op 2 until. . . D Iteration op 1 () C 1:C send message op 2 until. . . D 2: D D 1: D op 2 () op 3 () H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Creating Object New. Customer(Data) :Customer. Window Customer (Data) D 1: D H. E. Eriksson Creating Object New. Customer(Data) :Customer. Window Customer (Data) D 1: D H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Destroying Object Remove. Customer() :Customer. Window D 1: D Delete. Customer () H. E. Destroying Object Remove. Customer() :Customer. Window D 1: D Delete. Customer () H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Recursion oper() object name : class oper() H. E. Eriksson and M. Penker, “UML Recursion oper() object name : class oper() H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Collaboration Diagram • Collaboration diagrams focus on the interaction and the links between a Collaboration Diagram • Collaboration diagrams focus on the interaction and the links between a set of collaborating objects. The sequence diagram focuses on time but the collaboration diagram focuses on space. 2018/3/16

An example of a collaboration diagram Print(ps-file) : Computer 1:Print(ps-file) : Printer. Server : An example of a collaboration diagram Print(ps-file) : Computer 1:Print(ps-file) : Printer. Server : Printer [printer free] 1. 1: Print(ps-file) H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Message Label predecessor guard-condition sequence-expression return-value : = signature sequence-number , … / The Message Label predecessor guard-condition sequence-expression return-value : = signature sequence-number , … / The predecessor is an expression for synchronization of threads or paths, meaning that the messages connected to specified sequence-number must be performed and handled before the current message is sent. [ integer | name | recurrence] ・ integer a sequence-number specifying the message order 1. 2. 1 ・ name concurrent thread of control 1. 2 a 1. 2 b ・ recurrence * [ iteration-clause] [ condition-clause] a conditional or iterative exrcution [mode = display] 3. 1 [x<0] 3. 2 [ x => 0 ] 1. 1 a, 1. 1 b/ 1: display() 1. 2. 3. 7: redraw() 2 * [n: =1. . z]: prime: =next. Prim(prim) : foo() : bar() 1. 2: continue() H. E. 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. Eriksson

Iteration in a collaboration diagram Calc. Prim (n) : Calculator 1 * [ z Iteration in a collaboration diagram Calc. Prim (n) : Calculator 1 * [ z = 1. . n ]: prim: =next. Prim(prim) : Prim module H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Elevator Control 2: nextjob=Get. Job() :Queue :Elevator 1. 1 *[all queues]: len=Length(){broadcast} 1. 3: Elevator Control 2: nextjob=Get. Job() :Queue :Elevator 1. 1 *[all queues]: len=Length(){broadcast} 1. 3: invoke(job) {parameter}job :Elevator control :Order{new} job 1: Get. Elevator(floorid) {local}nextjob 1. 2: Create() Push() :Button H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Constraints for link role • Global: specify that the corresponding instance is visible because Constraints for link role • Global: specify that the corresponding instance is visible because it ‘s in a global scope • Local: specify that the corresponding instance is visible because it’s a local variable in an operation. • Parameter: specify that the corresponding instance is visible because it’s a parameter in an operation. • Self: specify that an object can send messages to itself J. Rumbaugh, I. Jacobson, G. Booch, The Unified Modeling Language Reference Manual, Addison-Wesley 2018/3/16

A state diagram for an elevator go up (floor) On first floor Moving up A state diagram for an elevator go up (floor) On first floor Moving up do: moving to floor arrived Moving to first floor Moving down do: moving to floor arrived go up (floor) idle timer = 0 do: increase timer go down (floor) [timer=time-out] H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Customer Window creation [free memory] 1: Create() Newcustomer() :Mainwindow :Customer{new} {parameter} 2: Create() 3: Customer Window creation [free memory] 1: Create() Newcustomer() :Mainwindow :Customer{new} {parameter} 2: Create() 3: Show(customer) :Customer. Window {transient} 3. 1: Update(data) H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Summarizing sales results 1. 1: Create() 1: Show() :Sales Statistics Window 1. 2 *[while Summarizing sales results 1. 1: Create() 1: Show() :Sales Statistics Window 1. 2 *[while any lines left]: Get. Result. Line() :Statistics Summary {new} 1. 1. 1 *[for all salespersons]: ordersum = Get. Total. Order. Sum() 1. 1. 2 *[for all salespersons]: budget = Getbudget() 3: Show(customer) :Sales. Person :Order 1. 1 *[for all orders]: Get. Order. Amount() :Budget Sales 1. 1. 2. 1 : Get. Budget. Amount() H. E. Eriksson 2018/3/16 and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Exercise :C 4 1. 1: f 2 ( ) 1. 2: f 3 ( Exercise :C 4 1. 1: f 2 ( ) 1. 2: f 3 ( ) 1: f1 ( ) :C 1 1. 1. 1: f 4 ( ) 1. 1. 2: f 5 ( ) :C 2 1. 1. 2. 1 : f 6 ( ) :C 3 1. 1: f 7 ( ) :C 5 2018/3/16

Answer f1( ) :C 1 :C 2 UML Ver. 1. 3 :C 4 :C Answer f1( ) :C 1 :C 2 UML Ver. 1. 3 :C 4 :C 5 f 2 ( ) f 4 ( ) f 5 ( ) f 7 ( ) call return f 6 ( ) 1 f 3 ( ) 2018/3/16 1. 1. 2 1. 1. 2. 1 1. 2

Activity  Diagram • An activity diagram is essentially a flowchart, showing flow of control Activity  Diagram • An activity diagram is essentially a flowchart, showing flow of control from activity to activity 2018/3/16

Actions and Transitions Customer. Window. Print. All. Customer() Show message. Box “Printing” on screen Actions and Transitions Customer. Window. Print. All. Customer() Show message. Box “Printing” on screen Remove Message. Box Create postscript file Send postscript file to printer H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Transition with send-clause Customer. Window. Print. All. Customer() Show message. Box “Printing” on screen Transition with send-clause Customer. Window. Print. All. Customer() Show message. Box “Printing” on screen Remove Message. Box Create postscript file ^Printer. Print(file) H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Transitions are protected by guarded-conditions [disk full] Customer. Window. Print. All. Customer() Show message. Transitions are protected by guarded-conditions [disk full] Customer. Window. Print. All. Customer() Show message. Box “Disk full” on screen Show message. Box “Printingl” on screen Remove Message. Box H. E. Eriksson 2018/3/16 ^Printer. Print(file) Create postscript file and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Parallel Actions. Sampler. Run(channel, frequency) Initiate Updating display H. E. Eriksson 2018/3/16 Measuring and Parallel Actions. Sampler. Run(channel, frequency) Initiate Updating display H. E. Eriksson 2018/3/16 Measuring and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Swim lanes Displayer Sampler. Run(channel, frequency) Initiate Updating display H. E. Eriksson 2018/3/16 Measuring Swim lanes Displayer Sampler. Run(channel, frequency) Initiate Updating display H. E. Eriksson 2018/3/16 Measuring and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Object Flow Displayer Sampler. Run(channel, frequency) Initiate Updating display H. E. Eriksson 2018/3/16 Measured Object Flow Displayer Sampler. Run(channel, frequency) Initiate Updating display H. E. Eriksson 2018/3/16 Measured value Measuring and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Sending/receiving signals. Sampler. Run(channel, frequency) a. Printer: Printer Print(file) Show Message. Box “Printing” on Sending/receiving signals. Sampler. Run(channel, frequency) a. Printer: Printer Print(file) Show Message. Box “Printing” on screen Create postscript file Print file Remove Message. Box H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Concurrency View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Concurrency View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Specific Features of Real-time Systems • Timeliness is important. The system performs its function Specific Features of Real-time Systems • Timeliness is important. The system performs its function within specified time limits. • Reactive. The system is continuously responding to events from the external environment that “drives” the execution of the system. • Concurrently executing threads of control, where different parts of the software run in parallel. • Very high requirements on most of the nonfunctional requirements such as reliability, fault tolerance, and performance. • Not deterministic H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Basic Concepts for real-time system modeling • • time requirement asynchronous event handling communication Basic Concepts for real-time system modeling • • time requirement asynchronous event handling communication concurrency – process, thread • synchronization H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Concurrency in Object-Orientation • Explicit concurrency model – Explicit concurrency model describes concurrency separately Concurrency in Object-Orientation • Explicit concurrency model – Explicit concurrency model describes concurrency separately from the objects by defining processes at an early stage of analysis, and then treating processes and objects as separate modeling entities. The system is decomposed into a number of processes, and each process is internally modeled as an object-oriented system to design the internal structure. • Implicit concurrency model – Implicit concurrency model delay the design of concurrency. The system is modeled as objects, where in an early analysis, all objects are considered to have their own execution threads; that is, be active objects. Gradually, through architecture and detailed design, the ideal analysis models are mapped onto an implementation with the support of services from the underlying real-time operating system. • UML can support both – It has better support for the implicit concurrency model. Active classes, asynchronous communication, and synchronization can be modeled in early phases and gradually be translated into the services and capabilities of the implementation environment. 2018/3/16 H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Active Class and Object Active Class <<Active Class> Communication Supervisor Active Object aninstance : Active Class and Object Active Class < Communication Supervisor Active Object aninstance : Communication Supervisor An active class is a one that owns an execution thread and can initiate control activity H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

An active object with its internal structure : Communication Supervisor Input: Message Buffert Output: An active object with its internal structure : Communication Supervisor Input: Message Buffert Output: Message Buffer : Comm Manager Port 1: Communication Port H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Thread of Control • Thread: Thread of control – A sequence of control transfer Thread of Control • Thread: Thread of control – A sequence of control transfer in a program • Multi Threads – Multiple threads exist together in a program and they can run concurrently 2018/3/16 S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.

Thread using Thread class • public class Our. Class { • public void run() Thread using Thread class • public class Our. Class { • public void run() { • for(int i = 0; i < 100; i++) { • System. out. println(“Hello”); • } • } Import java. applet. Applet; public class Our. Applet extends Applet{ public void init() { our. Class oc = new Our. Class(); oc. run(); } } Applet executes run() Applet executes init() Execution of Applet thread 2018/3/16 The run() method that writes a string 100 times to standard output is defined in Our. Class Applet thread works by executing run() method in Applet  t This example simply shows a method invocation as shown in the left figure. S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.

Execute run() method of Our. Class concurrently with init() or the other Applet methods Execute run() method of Our. Class concurrently with init() or the other Applet methods • public class Our. Class extends Thread{ • public void run() { • for(int i = 0; i < 100; i++) { • System. out. println(“Hello”); • } }} Import java. applet. Applet; public class Our. Applet extends Applet{ public void init() { our. Class oc = new Our. Class(); oc. start(); } } 2018/3/16 Implementation of start() method is in a Thread class or its super class start() method invokes run() method directly or indirectly. start() method creates the new thread of control S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.

Methods of the Thread class • Thread() : creates a thread object using default Methods of the Thread class • Thread() : creates a thread object using default values for all option • void run() : the method that is executed by the newly created thread. It can be considered as a main() of the newly created thread. This method should be over-ridded by the code that is executed by the new thread. • void start() : creates a new thread and executes run() method that is defined in this thread class public void run() { if (target != null) { target. run(); }} Default run() method of a Thread object 2018/3/16 run new creation of an instance start enqueue it to the thread queue sleep S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.

States of an active object Running time > 50 msec Create Schedule Ready Terminate States of an active object Running time > 50 msec Create Schedule Ready Terminate Making Call Running Waiting Result of call H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Run-time environment view of threads main memory Waiting or Ready Running thread 1 restore Run-time environment view of threads main memory Waiting or Ready Running thread 1 restore channel save pc register Waiting or Ready Running Ready thread 2 channel restore CPU run() { } 2018/3/16 create

Execute run() method of Our. Class concurrently with init() or the other Applet methods Execute run() method of Our. Class concurrently with init() or the other Applet methods Applet executes its run() method Applet executes internal task thread stop Applet executes the start() method Applet executes init() method Applet thread executes the other task 2018/3/16 S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997. t

Thread using Runnable Interface Runnable interface only have • public interface Runnable{ a run() Thread using Runnable Interface Runnable interface only have • public interface Runnable{ a run() method • public abstract void run(); • } • public class Our. Class implements Runnable{ • public void run() { • for(int i = 0; i < 100; i++) { • System. out. println(“Hellow”); • } }} Import java. applet. Applet; public class Our. Applet extends Applet{ public void init() { Runnable ot = new Our. Class(); Thread th = new Thread(ot); th. start(); }} 2018/3/16 S. Oaks, H. Wong, “Java Threads”, O’REILLY, 1997.

Communication among active objects • Operation call – An ordinary call of an operation. Communication among active objects • Operation call – An ordinary call of an operation. A caller waits for the operation to finish and return • Mailboxes/Message queues – This technique allows for asynchronous message • Shared memory – Two or more active objects can write and read information from/to a block of memory reserved for communication. The block has to be guarded by some kind of synchronization mechanisms. • • Rendezvous – Specific points in the execution of two threads are defined. The first thread to reach Its rendezvous point stops and waits for the other thread to reach its corresponding rendezvous point. When both threads are at the rendezvous point, they exchange information and then start to execute concurrently again. Remote procedure calls (RPCs) – RPCs handle distribution of the concurrent threads to separate computers in a network. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Events • In a real-time system, events are drivers of system activity • An Events • In a real-time system, events are drivers of system activity • An event is something that occurs in the system or in the environment. • All events that can occur must be defined; furthermore, the behavior of the system when the event happens must be defined. • In UML, there are four different categories for events: – – A condition (guard) become true The receipt of an explicit signal object The receipt of an operation call A passage of time H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Signals • Signals are defined in UML as “a named event that can be Signals • Signals are defined in UML as “a named event that can be raised <> Signal {abstract} <> Physical {abstract} <> Mouse Move H. E. Eriksson 2018/3/16 <> Key Pressed <> Logical {abstract} <> Object Drop <> Synchronization {abstract} <> Perform Command M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Synchronization • Concurrent processes interact with each other – to exchange data – to Synchronization • Concurrent processes interact with each other – to exchange data – to share resources, referring variables that show the status of the resource • It cause the occurrence of time-dependent errors • Synchronization mechanisms are required to avoid errors. – Mutual exclusion: operation A and operation B should be executed exclusively – Message buffer: A producer of data can not send data more than the finite capacity of a buffer. A consumer of data can not receive data before it is produced. – Exchange of timing signals: semaphore invariance – 0 <= r(v) <= s(v) + c(v) <= r(v)+ max(integer) – s(v): number of signals sent, r(v): number of signals received, c(v): initial value of signals, max: maximum countable number of a counter 2018/3/16

Problems without  synchronization • The problems that can occur if synchronization is not properly Problems without  synchronization • The problems that can occur if synchronization is not properly handled – incorrect shared access: use mutual exclusion between the thread – inefficient resource usage: avoid busy-wait – dead locks: detection, protection, resolution – starvation: thread scheduling H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Message Buffer full C ( a consumer) P (a producer) The position to be Message Buffer full C ( a consumer) P (a producer) The position to be read next The position to be written next synchronization rule empty (1) A consumer can not receive the message before the message is sent (2) 0 <= r < s (2) A producer can not put the new message into the position before the message In the position is read (3) 0 <= s - r < max 2018/3/16 The pointer P can not pass the pointer C and the pointer C can not pass the pointer

Synchronization Supports in UML • sequential – The class/operation is intended only for use Synchronization Supports in UML • sequential – The class/operation is intended only for use in a single thread of control • guarded – The class/operation will work in the presence of multiple threads of control. The threads normally have to lock the object/operation before using it, and unlock it afterward. • synchronized – The class/operation will work in the presence of multiple threads of control; the class itself handles this. Operation can be declared as synchronized. H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Scheduling • Scheduling is the process of deciding which thread should run next in Scheduling • Scheduling is the process of deciding which thread should run next in a situation where several threads are conceivable • Scheduling is done by the operating system, which allocates the processor to a thread using some predefined algorithm (e. g. round-robin) • In a complex situation where detailed control is needed of the scheduling, a supervisor thread can be designed. • In UML, the priority of an active object is most suitably noted as a tagged value of the active class H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Implementation of Concurrency and Synchronization in Java class Demo. Thread extends Thread{ public void Implementation of Concurrency and Synchronization in Java class Demo. Thread extends Thread{ public void run() { try{ for ( ; ; ) {// Do forever // Synchronous message to System. out object system. out. println(“Hello”); // Asynchronous message placed in Global_mailbox // Needs definition of class Signal and Mailbox // elsewhere. Signal s = new Signal(“Asynch Hello”); Global_mailbox. Put(s); Sleep(10); // Waits for 10 milli. Seconds. } } catch ( Interrupted. Exception e) { } } public static void main(String[ ] arg) { // Create an instance of the active class (thread) Demo. Thread t 1 = new Demo. Thread(); t 1. start(); // Start execution // Create another instance of the active class Demo. Thread t 2 = new Demo. Thread(); t 2. start(); // Start execution H. E. Eriksson and M. Penker, } “UML Toolkit” John Wiley & Sons, 2018/3/16 } Inc.

Basic Mechanisms for Modeling Real-time Systems in UML - house alarm system • Time: Basic Mechanisms for Modeling Real-time Systems in UML - house alarm system • Time: time specifications and constraints are best defined in sequence diagrams • Concurrency: is described as active classes • Asynchronous event: asynchronous message • Synchronization: can described either as properties of be classes or operations( concurrency properties) or as classes/stereotypes that define mechanism such as a semaphore, monitor, or critical region. • Distribution: Thread deployed in a distributed system are described in a deployment diagram. H. E. 2018/3/16 Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Sensors <<ActiveClass>> Sensor {abstract} +id : Address Self. Test() Activate() De. Activate() Photo Cell Sensors <<ActiveClass>> Sensor {abstract} +id : Address Self. Test() Activate() De. Activate() Photo Cell Sensor Devic. Specific Configuration parameters Self. Test() Activate() Deactivate() Heat Sensor Devic. Specific Configuration parameters Self. Test() Activate() Deactivate() Messages sent from a sensor device is ACK or NAK or an alarm signal Sound Sensor Devic. Specific Configuration parameters Self. Test() Activate() Deactivate() H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Alarms <<ActiveClass>> Alarm +id : Address Self. Test() Trigger() Turn. Off() Phone Alarm Devic. Alarms <<ActiveClass>> Alarm +id : Address Self. Test() Trigger() Turn. Off() Phone Alarm Devic. Specific Configuration parameters Self. Test() Trigger() Turn. Off() Light Alarm Devic. Specific Configuration parameters Self. Test() Trigger() Turn. Off() Messages sent from an alarm device is ACK or NAK Sound Alarm Devic. Specific Configuration parameters Self. Test() Trigger() Turn. Off() H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

A hierarchy of signal classes <<signal>> Signal {abstract} time. Sent: Time sender: Object. ID A hierarchy of signal classes <> Signal {abstract} time. Sent: Time sender: Object. ID <> General Signals {abstract} <> Error Trigger <> Activate <> Deactivate <> Sensor Signals {abstract} <> ACK NAK <> Heartbeat <> Alarm Signals {abstract} <> Alarm <> Turnoff <> Self. Test H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Class diagram 1. . * System Handler 1 1. . * Sensor Cell Handler Class diagram 1. . * System Handler 1 1. . * Sensor Cell Handler Log LCD Display Wrapper Sound Alarm 2018/3/16 1. . * Supervisor Keyboard Handler Wrapper 1 1. . * 1 1 Alarm 1 1 <> Cell Configuration Information <> System Configuration Information H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Collaboration diagram : System Handler : Sound Alarm : Phone Alarm 2 b. Trigger Collaboration diagram : System Handler : Sound Alarm : Phone Alarm 2 b. Trigger : Sound Alarm 2 a. Trigger 2 c. 2 Trigger : Cell Handler : Supervisor : Log 2 c. 1 Store (Date, Time, Cell, Sensor) 2 c. Alarm 1. Alarm : Photo Cell Sensor H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Sequence diagram : System Handler : Cell Handler : Sensor Activate A Read Configuration Sequence diagram : System Handler : Cell Handler : Sensor Activate A Read Configuration Self. Test Repeat for each installed alarm and sensor B B - A < 5 sec 2018/3/16 : Alarm : Cell Configuration Information Config info returned ACK Activate Self. Test ACK ACK H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

State diagram Activation Phase Alarms Self. Test Sensors Self. Test Performing Sensor Self. Test State diagram Activation Phase Alarms Self. Test Sensors Self. Test Performing Sensor Self. Test Cell Handler create Creating device list Performing Alarm Self. Test / send ACK NAK Activate Command /Send Activating ACK NAK List built System Activated sensor device / send ACK NAK success Initiating Thread loop Activation Failure H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Control flows are divided into concurrent threads that run in parallel and later become Control flows are divided into concurrent threads that run in parallel and later become synchronized again “Activate System” command System Inactive Activating Sensors / Green light on Activating Alarms System Activated Initiating Cell Handler Activation Failure H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

The run operation defined for the active Cell Handler class Waiting for Signal Alarm The run operation defined for the active Cell Handler class Waiting for Signal Alarm Trigger Alarm A Activate Message Handling Trigger Alarm B H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. Deactivate Message Handling Time-out Message Handling Trigger Alarm X Report to System Alarm(to system handler) Heartbeat( to system handler) Order time-out signal from real-time OS 2018/3/16 Time-out Documented in separate activity diagrams

The deployment diagram for the house alarm system User Panel 1 1 <<Thread>> Alarm The deployment diagram for the house alarm system User Panel 1 1 <> Alarm System Handler <> Cell Handler <> Sensor 1 1 1. . * Sensor Alarm <> Alarm H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

The UML definition of architecture • Architecture is the organizational structure of a system The UML definition of architecture • Architecture is the organizational structure of a system • An architecture can be recursively decomposed into – parts that interact through interfaces – relationships that connect parts – constraints for assembling parts H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Logical Architecture and Physical Architecture • Logical Architecture – The logical architecture deals with Logical Architecture and Physical Architecture • Logical Architecture – The logical architecture deals with the functionality of the system, allocating functionality to different parts of the system and specifying in detail how the solution work. – In UML, the diagram used to describe the logical architecture are usecase, class, state, activity, collaboration, and sequence. • Physical Architecture – The physical architecture deals with a detailed description of the system, in terms of the hardware and software that the system contains. It reveals the structure of the hardware, including different nodes and how these nodes are connected to each other. It also illustrates the physical structure and dependencies of the code modules that implement the concepts defined in the logical architecture; and distribution of the runtime software in terms of processes, programs, and other components. – In UML, the diagram used to describe the physical architecture are component and deployment H. E. 2018/3/16 Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Allocating Components to Nodes • Class and collaborations as defined in the logical design Allocating Components to Nodes • Class and collaborations as defined in the logical design are allocated to components in which they are implemented. The allocation is driven by the programming language used. Java implements a class in just one file. • The processes are allocated to the components in which they execute. • Components are allocated to nodes. • A component instance executes on at least one node instance. • There a number of aspects to consider when allocating components to nodes. – Resource Usage of the hardware – Geographical location – Access to devices – Security – Performance – Extensibility and portability H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Deployment View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Deployment View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

UML notations Package: Subsystem, Framework Interface realization (simple form) realization (expanded form) G. Booch, UML notations Package: Subsystem, Framework Interface realization (simple form) realization (expanded form) G. Booch, J. Rumbaugh, I. Jacobson , ”The Unified Modeling Language User 2018/3/16 Guide”, Addison Wesley, 1999.

Interface Storable Class A Class B Runnable <<interface>> Runnable {abstract} run(){ abstract} H. E. Interface Storable Class A Class B Runnable <> Runnable {abstract} run(){ abstract} H. E. Eriksson 2018/3/16 <> Storeble {abstract} load(){ abstract} save(){ abstract} and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Java Implementation interface Storable { public void save(); public void load(); }; public class Java Implementation interface Storable { public void save(); public void load(); }; public class Person implements Storable { public void save(); { /* Implementation of save operation for Person */ } public void save(); { /* Implementation of load operation for Person */ } }; H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Package A pakage is a grouping mechnism, whereby all kinds of model elements can Package A pakage is a grouping mechnism, whereby all kinds of model elements can be linked Subsystem A Subsystem B Subsystem C Subsystem D Subsystem E H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

UML notation Node ATM Data Server A physical element that exists at run time UML notation Node ATM Data Server A physical element that exists at run time and that represents a computational resource, generally having at least some memory and, often times, processing capability G. Booch, J. Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999. 2018/3/16

Node Dell Pentium 466 MMX node type <<Printer>> HP Laser. Jet 5 MP Bill’s Node Dell Pentium 466 MMX node type <> HP Laser. Jet 5 MP Bill’s Machine: Dell Pentium 466 MMX an instance <> Cisco Router X 2000 <> SAAB 9 -5 Navigator Device nodes and possible stereotype H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Communication Association between nodes Client. A: Compaq Pro PC “TCP/IP” Application Server: Silicon Graphics Communication Association between nodes Client. A: Compaq Pro PC “TCP/IP” Application Server: Silicon Graphics O 2 Client. B: Compaq Pro PC <> Database Server: VAX “TCP/IP” H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Component Allocation A node type supporting a run-time component type, and a run-time component Component Allocation A node type supporting a run-time component type, and a run-time component instance executing in a node instance UNIX Transaction Server Program Executable component instances may be contained within node instance symbols, showing that they reside and execute on the node instance Bill’s Machine: Dell Pentium MMX PC <> Transaction Client Library <> Silicon Graphics O 2 Client Program Use the services of another component H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Allocation of Object A passive object ( of Thermometer. Controller ) within an active Allocation of Object A passive object ( of Thermometer. Controller ) within an active process object ( of active class Super. Visor ) that lives within a component instance ( of type guard. exe ), which is allocated to the node Microwave Oven System ( of type Microwave Oven Controller ). Microwave Oven System: Microwave Oven Controller guard. exe <> Super. Visor Thermometer Controller H. E. 2018/3/16 Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Object Allocation Objects are allocated to nodes. The transobj object that originally exists in Object Allocation Objects are allocated to nodes. The transobj object that originally exists in the Main Server node can be distributed to the Dell PC node shown with the stereotype <> Main Server: Quad Pentium PC Bill’s Machine: Transaction Server Program Dell Pentium MMX PC Client Program t 1: updatethread transobj <> H. E. 2018/3/16 transobj dlbobj callobj Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.

Complex Modeling Client PC Net. Drv 1. . * 1. . 2 Server connected Complex Modeling Client PC Net. Drv 1. . * 1. . 2 Server connected To Appl. Client Window 95 Admin PC Admin. Pgm 1 backup. Medium 1 Backup Station H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Component View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Component View Logical View Component View Use-Case View Deployment View Concurrency View H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

UML notation Component <<executable>> client. exe A component is a physical and replaceable part UML notation Component <> client. exe A component is a physical and replaceable part of a system that conforms to and provides the realization of a set of Interfaces. Graphically, a component is rendered as a rectangle with tabs. G. Booch, J. Rumbaugh, I. Jacobson , ”The Unified Modeling Language User Guide”, Addison Wesley, 1999. 2018/3/16

An example of a component diagram Window Handler (whnd. cpp) Comm Handler (comhnd. cpp) An example of a component diagram Window Handler (whnd. cpp) Comm Handler (comhnd. cpp) Main Class (main. cpp) Window Handler (whnd. obj) Comm Handler (comhnd. obj) Main Class (main. obj) Graphic lib (graphic. dll) Client Program (client. exe) H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Three kinds of components • Source component • Binary component • Executable component H. Three kinds of components • Source component • Binary component • Executable component H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Interfaces and Dependencies updatethread. java Runnable display. java H. E. Eriksson and M. Penker, Interfaces and Dependencies updatethread. java Runnable display. java H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Compile-time Component <<page>> home. html <<file>> a file containing source code <<page>> a Web Compile-time Component <> home. html <> a file containing source code <> a Web page <> a document <> animlogo. java <> animator. java <> animlogo. doc <> animator. doc H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Run-time Components <<library>> commhandler. d. II <<library>> graphics. d. II <<library>> dbhandler. d. II Run-time Components <> commhandler. d. II <> graphics. d. II <> dbhandler. d. II <> umlviewer. exe H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc. 2018/3/16

Use of UML • • • Information system – Handle large amounts of data Use of UML • • • Information system – Handle large amounts of data with complex relationships, which are stored in relational or object databases Technical system – Handle control technical equipment such as telecommunications, military systems, or industrial processes. They must handle the special interfaces of the equipment and have less standard software than Information system. The are often real-time system. Embedded real-time systems – Execute on simple hardware embedded in some other equipment such as a mobile phone, car, household appliance, etc. Distributed systems – Distributed on a number of machines where data Is transferred easily from one machine to another. They require synchronized communication mechanisms to ensure data integrity and are often built upon object mechanisms such as CORBA, COM/DCOM, or Java Beans/RMI System software – Define the technical infrastructure that other software uses. Operating system. Databases. Business system – Describe the goals, the resources (human, computers), the rules (laws, business strategies, policies), and the actual work in the business 2018/3/16 H. E. Eriksson and M. Penker, “UML Toolkit” John Wiley & Sons, Inc.