Introduction to UML 2.0 - Object Management Group

76 downloads 1185 Views 2MB Size Report
2. Session Objectives. ▫ After completing this session, you should be able to: > Identify the different UML diagrams. >Describe the purpose of each diagram.
®

IBM Software Group

Introduction to UML 2.0 Terry Quatrani UML Evangelist

© 2005 IBM Corporation

IBM Software Group

Session Objectives ! After completing this session, you should be able to: !Identify the different UML diagrams !Describe the purpose of each diagram !State where diagrams can be used

2

IBM Software Group

Agenda ! The Importance of Modeling ! The Unified Modeling Language ! Model-Driven Architecture ! UML Diagrams ! Extending the UML

3

IBM Software Group

Agenda ! The Importance of Modeling ! The Unified Modeling Language ! Model-Driven Architecture ! UML Diagrams ! Extending the UML

4

IBM Software Group

The Importance of Modeling

5

IBM Software Group

Why do we model? ! To manage complexity ! To detect errors and omissions early in the lifecycle ! To communicate with stakeholders ! To understand requirements ! To drive implementation ! To understand the impact of change ! To ensure that resources are deployed efficiently

6

IBM Software Group

Agenda ! The Importance of Modeling ! The Unified Modeling Language ! Model-Driven Architecture ! UML Diagrams ! Extending the UML

7

IBM Software Group

The Unified Modeling Language ! The UML is the standard language for visualizing, specifying, constructing, and documenting the artifacts of a softwareintensive system

8

IBM Software Group

Blobsof with writing in their hair UML: The Language Software Development

Public Feedback

And small adornments in the air And has-relations everywhere Adopted major revision (2004) I've looked at clouds that way. UML But now I've purged them from my Sun Grady Current minor Eliminated revision 2001 every one UML So many things I would have done To drive the clouds away. Minor revision 1999 UML I've looked at clouds from both sides now Both inNov and1997 out, and still somehow OMG Acceptance, Jim It'stoclouds' delusions UML Final submission OMG, Sept 1997 I appall I really can't stand clouds at all… Balls for multiplicity UML partners UML Black and white for clarity And data flows arranged in trees Web - June 1996 Were part of OMT. UML Ivar But now I've had to let them go OOPSLA 95 We'll do it differently, you know Unified Method 'Cause Grady said, they've got to go We can't use OMT.

Other methods OOSE

2.0 1.5 1.3 1.1 1.0 0.9 0.8

Booch method OMT 9

IBM Software Group

Approach to Evolving UML 2.0 ! Evolutionary rather than revolutionary ! Improved precision of the infrastructure ! Small number of new features ! New feature selection criteria !Required for supporting large industrial-scale applications !Non-intrusive on UML 1.x users (and tool builders)

! Backward compatibility with 1.x

10

IBM Software Group

Formal RFP Requirements ! Infrastructure – UML internals !More precise conceptual base for better MDA support !MOF-UML alignment

! Superstructure – User-level features !New capabilities for large-scale software systems !Consolidation of existing features

! OCL – Constraint language !Full conceptual alignment with UML

! Diagram interchange standard !For exchanging graphic information (model diagrams)

11

IBM Software Group

Infrastructure Requirements ! Precise MOF alignment !Fully shared “common core” metamodel

! Refine the semantic foundations of UML (the UML metamodel) !Improve precision !Harmonize conceptual foundations and eliminate semantic overlaps !Provide clearer and more complete definition of instance semantics (static and dynamic)

12

IBM Software Group

OCL Requirements ! Define an OCL metamodel and align it with the UML metamodel !OCL navigates through class and object diagrams ⇒ must share a common definition of Class, Association, Multiplicity, etc.

! New modeling features available to general UML users !Beyond constraints !General-purpose query language

13

IBM Software Group

Diagram Interchange Requirements ! Ability to exchange graphical information between tools !Currently only non-graphical information is preserved during model interchange !Diagrams and contents (size and relative position of diagram elements, etc.)

14

IBM Software Group

Superstructure Requirements (1 of 2) ! More direct support for architectural modeling !Based on existing architectural description languages (UML-RT, ACME, SDL, etc.) !Reusable interaction specifications (UML-RT protocols)

! Behavior harmonization !Generalized notion of behavior and causality !Support choice of formalisms for specifying behavior

! Hierarchical interactions modeling ! Better support for component-based development ! More sophisticated activity graph modeling !To better support business process modeling

15

IBM Software Group

Superstructure Requirements (2 of 2) ! New statechart capabilities !Better modularity

! Clarification of semantics for key relationship types !Association, generalization, realization, etc.

! Remove unused and ill-defined modeling concepts ! Clearer mapping of notation to metamodel ! Backward compatibility !Support 1.x style of usage !New features only if required

16

IBM Software Group

Language Architecture !

A core language + a set of optional “language units” ! Some language units have multiple “levels” State Machines

Structured Classes and Components

Activities

Multiple Multiple levels levels of of compliance compliance

Level Level 33

Interactions

Detailed Actions

Flows

Level Level 22 MOF

Profiles OCL Level Level 11

Basic UML

(Classes, Basic behavior, Internal structure, Use cases…) UML Infrastructure

17

IBM Software Group

The UML 2.0 Specification ! Can be downloaded from http://www.omg.org/cgi-bin/doc?ptc/2004-10-02

18

IBM Software Group

Agenda ! The Importance of Modeling ! The Unified Modeling Language ! Model-Driven Architecture ! UML Diagrams ! Extending the UML

19

IBM Software Group

Model-Driven Architecture (MDA) ! An OMG initiative to support model-driven development through a series of open standards (1) ABSTRACTION

(2) AUTOMATION

MDA (3) (3) OPEN OPEN STANDARDS STANDARDS •• Modeling Modeling languages languages •• Interchange Interchange facilities facilities •• Model Model transformations transformations •• Software Software processes processes •• etc. etc. 20

IBM Software Group

! Set of modeling languages for specific purposes

The Languages of MDA UML “bootstrap”

MetaObject MetaObject Facility Facility (MOF) (MOF) MOF MOF “core” “core” A modeling language for defining modeling languages

General General Standard Standard UML UML General-purpose modeling language Common Common Warehouse Warehouse Metamodel Metamodel (CWM) (CWM)

For exchanging information about business and data

Real -Time Real-Time profile profile EAI EAI profile profile Software Software process process profile profile

etc. etc. etc. etc. 21

IBM Software Group

MOF (Metamodel) Example !

Uses (mostly) class diagram concepts to define ! Language concepts ement ! Relationships betweenElconcepts 0..1 /owner *

Relationship

/ownedE lement

Element

Comment *

1..*

DirectedRelationship

/source 1..* /target 1..* 22

IBM Software Group

Agenda ! The Importance of Modeling ! The Unified Modeling Language ! Model-Driven Architecture ! UML Diagrams ! Extending the UML

23

IBM Software Group

Meta-models and Notations

24

IBM Software Group

Metamodel Description of Objects Object Object

NamedElement

Element (from Ownerships)

(from Namespaces)

InstanceSpecification

owningInstance {subsets owner} 1

slot

*

Slot

{subsets ownedElement}

owningSlot {subsets owner} 0..1

Va lueS pe ci fic at ion

val ue

(from Expres sions)

{ordered, * subsets ownedElement} StructuralFeature definingFeature

(from StructuralFeatures)

1

classifier Classifier 1..* inst ance

(from Classifiers)

1 ValueSpecification (from Expressions)

Object Object Identifier Identifier InstanceValue

25

IBM Software Group

Metamodel Structure

Different Different Behavior Behavior Formalisms Formalisms

Structure -Behavior Structure-Behavior Dependency Dependency Shared Shared Behavior Behavior Semantics Semantics

26

IBM Software Group

Diagram Elements ! Each diagram has a frame, a content area and a heading ! The frame is a rectangle and is used to denote a border



!Frame is optional

! The heading is a string contained in a name tag which is a rectangle with cut off corners in the upper left hand corner of the frame !Format [] [] [] ! can be activity, class, component, interaction, package, state machine, use case

27

IBM Software Group

Frame Example

Package P

Class 1

Class 2

28

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 29

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Class Class Diagrams Diagrams

Activity Activity Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams

Deployment Deployment Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 30

IBM Software Group

Activities ! Significantly enriched in UML 2.0 (relative to UML 1.x activities) !More flexible semantics for greater modeling power (e.g., rich concurrency model based on Petri Nets) !Many new features

! Major influences for UML 2.0 activity semantics !Business Process Execution Language for Web Services (BPEL4WS) – a de facto standard supported by key industry players (Microsoft, IBM, etc.) !Functional modeling from the systems engineering community (INCOSE)

31

IBM Software Group

Activity Diagram ! Activity diagrams show flow of control and data flow ! Typically used to model !Business process workflow !Flow within a use case !Business rules logic !Functional processes !UI screen flows

[condition 1] [condition 3] 32

IBM Software Group

Activity Diagram «post condition» Flight selected

Flight Selection

Cancel Request

Enter Departure Airport

Departure Airport

List of Alternatives

Lookup City

Cancel Selection

Select Flight

[found > 1 flight] [found 1 flight]

[found 0 flights]

33

IBM Software Group

Partitioning capabilities OrderDepartment Accounting

Company

Seattle

Receive order

Reno

Ship order

Fill order

Close order

Accept payment

Send invoice

Customer

Invoice

Make payment

34

IBM Software Group

Partitioning capabilities Reno

OrderDepartment Accounting

Company

Seattle

Receive order

Ship order

Fill order

Close order

Accept payment

Send invoice

Customer

Invoice

Make payment

35

IBM Software Group

Activities: Basic Notational Elements Control/Data Flow

Control Fork

Activity or Action Control Join Object Node (may include state)

Initial Node

Pin (Object) Activity Final Choice Flow Final (Simple) Join 36

IBM Software Group

Extended Concurrency Model !

Fully independent concurrent streams (“tokens”) Concurrency Concurrency join join

Concurrency Concurrency fork fork B

C

A

Z X

“Tokens” “Tokens” represent represent individual individual execution execution threads threads (executions (executions of of activities) activities) NB: NB: Not Not part part of of the the notation notation

Y

Valid output streams: ABCXYZ AXYBCZ ABXCYZ AXBYCZ ABXYCZ AXBCYZ 37

IBM Software Group

Activities: Token Queuing Capabilities ! Tokens can !queue up in “in/out” pins !backup in network !prevent upstream behaviors from taking new inputs

Activity 2

Activity 3

! …or, they can flow through continuously !taken as input while behavior is executing !given as output while behavior is executing !identified by a {stream} adornment on a pin or object node

38

IBM Software Group

Actions in UML ! Action = fundamental unit of behavior !for modeling fine-grained behavior !Level of traditional programming languages

! UML defines: !A set of action types !A semantics for those actions ! i.e. what happens when the actions are executed ! Pre- and post-condition specifications (using OCL) !No concrete syntax for individual kinds of actions (notation) ! Flexibility: can be realized using different concrete languages

! In UML 2, the metamodel of actions was consolidated !Shared semantics between actions and activities (Basic Actions) 39

IBM Software Group

Object Behavior Basics ! Support for multiple computational paradigms

OutputPin (typed)

Control Control Flow Flow

ActivityNode ActivityNode (context) (context) . . .

.

. . .

Action1 Action1

Action2 Action2

. . .

Action3 Action3

. . .

. . .

. . . .

.

Input Pin (typed)

. . .

VariableA VariableA

Data Flow 40

IBM Software Group

Categories of Actions ! Communication actions (send, call, receive,…) ! Primitive function action ! Object actions (create, destroy, reclassify,start,…) ! Structural feature actions (read, write, clear,…) ! Link actions (create, destroy, read, write,…) ! Variable actions (read, write, clear,…) ! Exception action (raise)

41

IBM Software Group

UML 2.0 Diagrams Use UseCase Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 42

IBM Software Group

Use Case Diagram ! Use case diagrams are created to visualize the relationships between actors and use cases ! Use cases are a visualization the functional requirements of a system

43

IBM Software Group

Actors ! An actor is someone or some thing that must interact with the system under development

Passenger

Bank

44

IBM Software Group

Use Cases ! A use case is a pattern of behavior the system exhibits !Each use case is a sequence of related transactions performed by an actor and the system in a dialogue

! Actors are examined to determine their needs !Passenger – Search for Flights, Make Reservation, Pay for Flight !Bank -- receive payment information from Pay for Flight

Search for Flights

Make Reservation

Pay for Flight

45

IBM Software Group

Documenting Use Cases ! A use case specification document is created for each use cases !Written from an actor point of view

! Details what the system must provide to the actor when the use cases is executed ! Typical contents !How the use case starts and ends !Normal flow of events !Alternate flow of events !Exceptional flow of events

46

IBM Software Group

Use Case Diagram Flight Reservation System Search for flights

Condition: {seat Selection available on flight} Extension point: Seat Selection

«include» Make reservation Extension points Seat Selection

«extend»

Select seat

Passenger Pay for Flight

Bank

47

IBM Software Group

UML 2.0 Changes ! No notational changes for use case diagrams in UML 2.0

48

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 49

IBM Software Group

Interaction Diagrams ! Interaction diagrams show the communication behavior between parts of the system ! Four types of diagrams !Sequence diagram ! Emphasis on the sequence of communications between parts !Communication diagram ! Emphasis on structure and the communication paths between parts !Timing diagram ! Emphasis on change in state over time !Interaction overview diagram ! Emphasis on flow of control between interactions 50

IBM Software Group

Sequence Diagram : Customer

reservation system

reservation manager

destination

Make reservation Enter PIN verify PIN(number) valid Ask for destination Destination Destination Show flights (destination)

51

IBM Software Group

Framed Sequence Diagram SD Make Reservation

: Customer

reservation system

reservation manager

destination

Make reservation Enter PIN verify PIN(number) valid Ask for destination Destination Destination Show flights (destination)

52

IBM Software Group

Composite Diagrams SD Make Reservation SD Check PIN : Customer

reservation system

reservation manager

destination

Make reservation Enter PIN

ref

CheckPin verify PIN(number)

valid Ask for destination Destination

: Customer

reservation system

reservation manager

Enter PIN verify PIN(number) valid

Destination Show flights (destination)

53

IBM Software Group

Combined Fragment Types ! Alternatives (alt) !choice of behaviors – at most one will execute !depends on the value of the guard (“else” guard supported)

! Option (opt) !Special case of alternative

! Loop (loop) !Optional guard: [, , ] !No guard means no specified limit

! Break (break) !Represents an alternative that is executed instead of the remainder of the fragment (like a break in a loop)

54

IBM Software Group

Combined Fragment Types ! Parallel (par) !Concurrent (interleaved) sub-scenarios

! Negative (neg) !Identifies sequences that must not occur

! Assertion (assert) !This must happen

! Critical Region (region) !Traces cannot be interleaved with events on any of the participating lifelines

55

IBM Software Group

Combined Fragments Diagram SD Make Reservation

client:

atm:

dbase:

insertCard ref

CheckPin [chk= OK]

alt ref

DoTransaction

error(badPIN)

[else]

56

IBM Software Group

Communication Diagram Example

sd Reserve Flights ights l f e rov 1app ights l f m onfir 1.3 c

:Web Client

:Web Server

y 2 pa eipt c e r 2.1

1.2 confirm flights

1.1 approve flights

:Flight DB

57

IBM Software Group

Timing Diagram Example {d..d+0.5}

sd Reader

Reading r : Reader Idle

Read

ReadDone

Read {t1..t1+0.1}

Uninitialized Initialize

t1

58

IBM Software Group

Interaction Overview Example ! Like flow charts ! Use activity graph notation for control constructs

! Better overview of complex interactions

sd OverviewDiagram lifelines Client, :Server

ref

Authorization

sd :Server

:Client request

! Alternatives, options etc.

! Multiple diagram types could be included/referenced ~[more] [more] ref

DoMore

59

IBM Software Group

UML 2.0 Changes ! Interaction occurrences and combined fragments added ! Communication diagrams created to replace collaboration diagrams used to show interactions ! New diagrams: Timing Diagram and Interaction Overview Diagram

60

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 61

IBM Software Group

Class Diagram ! Class diagrams show static structure !This is the diagram that is used to generate code

62

IBM Software Group

Classes ! A class defines a set of objects with common structure, common behavior, common relationships and common semantics ! Classes can be “discovered” by examining the objects in sequence and collaboration diagram ! A class is drawn as a rectangle with three compartments ! Classes should be named using the vocabulary of the domain !Naming standards should be created !e.g., all classes are singular nouns starting with a capital letter

63

IBM Software Group

Classes ReservationManager «interface» IPerson Mailer

PassengerInterface

Reservation

Passenger

Seat

Flight

CorporatePassenger

64

IBM Software Group

Operations ! The behavior of a class is represented by its operations ! Operations may be found by examining interaction diagrams :ReservationManager

:Reservation

Reservation Assign seat row and position

assignSeat(row, position)

65

IBM Software Group

Attributes ! The structure of a class is represented by its attributes ! Attributes may be found by examining class definitions, the problem requirements, business rules and by applying domain knowledge

The name, address and phone number for each person is needed before a reservation can be made

Person name address phoneNumber

66

IBM Software Group

Classes with Operations and Attributes ReservationManager «interface» IPerson Mailer

getName ( ) getAddress ( )

PassengerInterface getName ( ) getAddress ( ) Reservation addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address Seat CorporatePassenger discount

row position

Flight airline flightNumber update( )

67

IBM Software Group

Relationships ! Relationships provide a pathway for communication between objects ! Sequence and/or communication diagrams are examined to determine what links between objects need to exist to accomplish the behavior -- if two objects need to “talk” there must be a link between them ! Relationship types !Association !Aggregation !Composition !Dependency

68

IBM Software Group

Relationships ! An association is a bi-directional connection between classes ! An aggregation is a stronger form of association where the relationship is between a whole and its parts ! A composition is a stronger form of aggregation where the part is contained in at most one whole and the whole is responsible for the creation of its parts ! A dependency is a weaker form of relationship showing a relationship between a client and a supplier where the client does not have semantic knowledge of the supplier 69

IBM Software Group

Finding Relationships ! Relationships are discovered by examining interaction diagrams !If two objects must “talk” there must be a pathway for communication :ReservationManager

:Reservation ReservationManager

Assign seat row and position Reservation

70

IBM Software Group

Relationships ReservationManager «interface» IPerson Mailer

getName ( ) getAddress ( )

PassengerInterface getName ( ) getAddress ( ) Reservation addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address Seat CorporatePassenger discount

row position

Flight airline flightNumber update( )

71

IBM Software Group

Multiplicity and Navigation ! Multiplicity defines how many objects participate in a relationships !Multiplicity is the number of instances of one class related to ONE instance of the other class !For each association and aggregation, there are two multiplicity decisions to make: one for each end of the relationship

! Although associations and aggregations are bi-directional by default, it is often desirable to restrict navigation to one direction !If navigation is restricted, an arrowhead is added to indicate the direction of the navigation

72

IBM Software Group

Multiplicity ReservationManager «interface» IPerson Mailer

getName ( ) getAddress ( )

1 PassengerInterface getName ( ) getAddress ( )

0..*

Reservation 0..* addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address

1 1 Seat

CorporatePassenger discount

row position

1 Flight airline flightNumber update( )

73

IBM Software Group

Navigation ReservationManager «interface» IPerson Mailer

getName ( ) getAddress ( )

1 PassengerInterface getName ( ) getAddress ( )

0..*

Reservation 0..* addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address

1 1 Seat

CorporatePassenger discount

row position

1 Flight airline flightNumber update( )

74

IBM Software Group

Inheritance ! Inheritance is a relationships between a superclass and its subclasses ! There are two ways to find inheritance: !Generalization !Specialization

! Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchy

75

IBM Software Group

Inheritance ReservationManager «interface» IPerson Mailer

getName ( ) getAddress ( )

1 PassengerInterface getName ( ) getAddress ( )

0..*

Reservation 0..* addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address

1 1 Seat

CorporatePassenger discount

row position

1 Flight airline flightNumber update( )

76

IBM Software Group

Realization ! Realization is a relationship between a specification and its implementation

77

IBM Software Group

Realization ReservationManager «interface» IPerson Mailer

getName ( ) getAddress ( )

1 PassengerInterface getName ( ) getAddress ( )

0..*

Reservation 0..* addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address

1 1 Seat

CorporatePassenger discount

row position

1 Flight airline flightNumber update( )

78

IBM Software Group

UML 2 Interface Notation PassengerInterface getName ( ) getAddress ( )

Mailer IPerson

IPerson

PassengerInterface is the implementation IPerson interface

Mailer uses the IPerson interface

PassengerInterface Mailer

IPerson

getName ( ) getAddress ( )

79

IBM Software Group

Realization ReservationManager 1 PassengerInterface

Mailer

IPerson

getName ( ) getAddress ( )

0..*

Reservation 0..* addItem ( ) assignSeat ( ) deleteSeat ( )

Passenger name address

1 1 Seat

CorporatePassenger discount

row position

1 Flight airline flightNumber update( ) 80

IBM Software Group

UML 2.0 Changes ! Notation for a required interfaces (

) added

81

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams

Deployment Deployment Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 82

IBM Software Group

Composite Structure Diagrams ! Composite Structure diagrams show the internal structure of a classifier and its interaction points to other parts of the system !Instance view of the world

! They show how the contained parts work together to supply the behavior of the container

83

IBM Software Group

Aren’t Class Diagrams Sufficient? ! No! !Because they abstract out certain specifics, class diagrams are not suitable for performance analysis

! Need to model structure at the instance/role level N2:Node N2:Node

N1:Node N1:Node

N3:Node N3:Node N4:Node N4:Node

N1:Node N1:Node

N2:Node N2:Node

0..1 right

Node Node

left 0..1

N3:Node N3:Node

Same class diagram describes both systems!

84

IBM Software Group

Collaborations ! In UML 2.0 a collaboration is a purely structural concept

collaboration collaboration

!More general than an instance model

RedundantSystem associated interaction

role role

2

1query

client client

arbiter arbiter :Arb :Arb connector connector (link (link role) role)

primary primary

et g a

2b get 2c

ge t

backup1 backup1

backup2 backup2

85

IBM Software Group

Roles and Instances ! Specific object instances playing specific the roles in a collaboration d1/primary d1/primary :Dbase :Dbase

c1/client c1/client :Client :Client

a/a/arbiter arbiter :Arb :Arb

d2/backup1 d2/backup1 :Dbase :Dbase

d2/backup2 d2/backup2 :Dbase :Dbase

86

IBM Software Group

Structured Class ! A complex class comprised of internal “parts” ! Desired structure is asserted rather than constructed !Class constructor automatically creates desired structures !Class destructor automatically cleans up Class Name

broker

client

service

87

IBM Software Group

Ports ! Interaction points ! Each port is dedicated to a specific purpose and presents the interface appropriate to that purpose

Ports 88

IBM Software Group

Port Semantics ! A port can support multiple interface specifications ! Provided interfaces (what the object can do) - incoming ! Required interfaces (what the object needs to do its job) outgoing

«uses»

BuyTicket

«provides»

Request() Confirm()

TicketServer «provides»

SellTicket

WebClient «uses»

Proposal() Confirm()

89

IBM Software Group

Ports: Alternative Notation ! Shorthand “lollipop” notation with 1.x backward compatibility

Provided Interface

buyTicket WebClient sellTicket Required Interface

90

IBM Software Group

Assembling Communicating Objects ! Ports can be joined by connectors to model communication channels !At runtime, the WebClient is linked to the TicketServer

Customer: WebClient

Agency: TicketServer

A connector is constrained by a protocol Static typing rules apply (compatible protocols) 91

IBM Software Group

Protocols: Reusable Interaction Sequences ! Communication sequences that !Conform to a pre-defined dynamic order !Are defined generically in terms of role players !E.g., ticket purchase protocol

WebClient

loop

TicketServer

request propose

confirm confirm

92

IBM Software Group

Modeling Protocols with UML 2.0 ! A collaboration structure with interactions Ticket Purchase Protocol WebClient

«interface» «interface» buyTicket buyTicket request( request( )) Confirm() Confirm()

loop

TicketServer

request propose confirm

«interface» «interface» sellTicket sellTicket Propose() Propose() Confirm() Confirm()

confirm

customer customer

agency agency 93

IBM Software Group

Structured Classes: Putting Them Together

OnlineAgency sd ReserveFlights

Customer: WebClient

sd SelectFlights

Agency: TicketServer

94

IBM Software Group

Structured Classes: Putting Them Together OnlineAgency sd ReserveFlights

Customer: WebClient

sd SelectFlights

Agency: TicketServer

AirlineTicketReservation sd

sd

95

IBM Software Group

UML 2.0 Changes ! Composite structure diagrams, structured classes, ports and connectors are new

96

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 97

IBM Software Group

State Machine Diagram ! A state machine diagram shows !The life history of a given class !The events that cause a transition from one state to another !The actions that result from a state change

! State machine diagrams are created for objects with significant dynamic behavior

98

IBM Software Group

State Diagram state machine Make Payment cancel

Enter credit card data

OK

Do transaction: Payment Transaction

aborted

done

Display Confirmation Page

Display Cancellation Page

99

IBM Software Group

Submachine Payment Transaction OK

User confirmation For amount

OK

Transaction confirmed

Authorize transaction

Transaction not authorized

PIN required aborted

Enter PIN

OK Authorize PIN

PIN rejected

PIN confirmed

100

IBM Software Group

Specialization ! Redefinition as part of standard class specialization Behaviour

ATM

Statemachine acceptCard() outOfService() amount()

FlexibleATM

Behaviour Statemachine

otherAmount() rejectTransaction()

101

IBM Software Group

Example: State Machine Redefinition ATM ! State machine of ATM to be redefined VerifyCard {final} acceptCard

ReadAmount OutOfService {final}

outOfService

selectAmount amount

releaseCard

VerifyTransaction {final}

{final}

ReleaseCard

102

IBM Software Group

State Machine Redefinition ATM {extended} FlexibleATM

VerifyCard {final} acceptCard

ReadAmount {extended} OutOfService {final}

outOfService

selectAmount

otherAmount

enterAmount

amount reject

ok

releaseCard

VerifyTransaction {final}

{final}

ReleaseCard

103

IBM Software Group

UML 2.0 Changes ! Protocol state machines added

104

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 105

IBM Software Group

Component Diagram ! A component is a modular unit with well defined interfaces that is replaceable within its environment ! Components can be logical or physical ! Logical components !Business components, process components etc.

! Physical components !EJB components, .NET components, COM components etc.

106

IBM Software Group

Component Diagram



:Ticket



:Reservation

IPerson

:Passenger

107

IBM Software Group

UML 2.0 Changes ! Notation for a component changed ! Component may have ports

108

IBM Software Group

UML 2.0 Diagrams Use Use Case Case Diagrams Diagrams

Interaction Interaction Diagrams Diagrams

Activity Activity Diagrams Diagrams

Class Class Diagrams Diagrams

Deployment Deployment Diagrams Diagrams

Composite Composite Structure Structure Diagrams Diagrams Component Component Diagrams Diagrams

State State Machine Machine Diagrams Diagrams 109

IBM Software Group

Deployment Diagram ! Deployment diagrams show the execution architecture of systems ! Nodes are connected by communication paths to create network systems

110

IBM Software Group

Artifacts ! An artifact represents a physical entity ! Examples !Model files, source files, scripts, binary executable files

Ticket.jar



:Ticket 111

IBM Software Group

Deployment Diagram

AppServer

DB Server



Ticket.jar

112

IBM Software Group

UML 2.0 Changes ! Artifacts and deployment specifications are new ! New Node types introduced !Execution environment (virtual machine, app server, and other “middleware”)

113

IBM Software Group

Agenda ! The Importance of Modeling ! The Unified Modeling Language ! UML Diagrams ! Extending the UML

114

IBM Software Group

Extending the UML ! In order to model something effectively, the language that you use to model it must be rich and expressive enough to do so ! “Out of the box” UML is sufficient for modeling object-oriented software systems ! BUT… there are many more models that are useful in the software development process ! UML can easily be extended to add more semantics to cover other modeling situations !Database models !Business process !Web pages !On and on…. 115

IBM Software Group

Extension Mechanisms ! Stereotypes ! Tag definitions and tagged values ! Constraints

116

IBM Software Group

Stereotypes ! A more refined semantic interpretation for a model element



Class



Table

117

IBM Software Group

Stereotype Examples

118

IBM Software Group

Deployment Diagram

119

IBM Software Group

Tag Definitions and Tagged Values ! A tag definition the ability to associate extra information with a modeling element !Defines the name and the type of information

! Example !A database table could be modeled as a stereotyped class !Columns could be modeled as stereotyped attributes !Tag definition for a column could be “NullsAllowed”

! A tagged value is the actual instance of a tag definition with a value that is associated to the modeling element ! Example !Create a table Person !Add a column, you MUST supply a value for “NullsAllowed” (true or false) 120

IBM Software Group

Constraints ! A constraint is a rule that is applied to a modeling element !Represented by curly braces in UML

! Used to evaluate if a modeling element is “well-formed” ! Example !The name of a column cannot exceed the maximum length for column names for the associated database

! The language of constraints is Object Constraint Language (OCL)

121

IBM Software Group

OCL ! OCL is another OMG specification ! Defines an object-oriented language that is similar to Smalltalk, Java and C++ ! Formal way to express model ” well formedness” rules {let x = self.model().OwnedProfile->any(Name='Data Modeler'). TaggedValueSet->any(Name='Preferences').TagDefinition>any(Name='maximumidentifierlength').DefaultValue.oclAsType(UML::Int egerTaggedValue).Value in self.Name.size() = 0}

127

IBM Software Group

Profiles: Notation ! E.g., specializing the standard Component concept «profile» TimingDevices

«stereotype»

«metaclass»

Clock

Class

Extension

«stereotype»

Timer

«stereotype»

ToDclock

128

IBM Software Group

Templates ! More precise model than UML 1.x ! Limited to Classifiers, Packages, and Operations Template parameter

T > Number, k : IntegerExpression

NumericArray arrayElement : T [k]

Class(ifier) template

Template signature

«bind» Integer, k -> 10>

Template binding

“Bound” class

IntegerArray arrayElement : Integer [10] 129

IBM Software Group

Collaboration Templates ! Useful for capturing design patterns ObserverPattern

subject : sType

Collaboration template

oType, sType observer : oType

«bind»

DeviceObserver ObserverPattern DevicePoller, sType>Device>

130

IBM Software Group

Package Templates ! Based on simple string substitution CustomerAccountTemplate CustomerAccountTemplate

$$ $$

owner

customer : StringExpression, kind : StringExpression $Acct$

1..*

0..*

$ $ Account$ Account$

Name Expression

«bind» Person, kind -> Personal

SavingsBank SavingsBank Person Person

owner 1..*

PersonalAcct 0..*

Personal Personal Account Account 131

IBM Software Group

Summary: UML 2.0 Highlights ! Greatly increased level of precision to better support MDD ! More precise definition of concepts and their relationships ! Extended and refined definition of semantics

! Improved language organization ! Modularized structure ! Simplified compliance model for easier interworking

! Improved support for modeling large-scale software systems ! Modeling of complex software structures (architectural description language) ! Modeling of complex end-to-end behavior ! Modeling of distributed, concurrent process flows (e.g., business processes, complex signal processing flows)

! Improved support for defining domain-specific languages (DSLs) ! Consolidation and rationalization of existing concepts 132

IBM Software Group

Session Summary ! Now that you have completed this session, you should be able to: !Identify the different UML diagrams !Describe the purpose of each diagram !Use the different diagram and model elements

133

IBM Software Group

134

IBM Software Group

135