Introduction To UML 2 - OMG

Transcription

IBM Software GroupIntroduction to UML 2.0Terry QuatraniUML Evangelist 2005 IBM Corporation

IBM Software GroupSession 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 used2

IBM Software GroupAgenda! The Importance of Modeling! The Unified Modeling Language! Model-Driven Architecture! UML Diagrams! Extending the UML3

IBM Software GroupAgenda! The Importance of Modeling! The Unified Modeling Language! Model-Driven Architecture! UML Diagrams! Extending the UML4

IBM Software GroupThe Importance of Modeling5

IBM Software GroupWhy 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 deployedefficiently6

IBM Software GroupAgenda! The Importance of Modeling! The Unified Modeling Language! Model-Driven Architecture! UML Diagrams! Extending the UML7

IBM Software GroupThe Unified Modeling Language! The UML is the standardlanguage for visualizing,specifying, constructing,and documenting theartifacts of a softwareintensive system8

IBM Software GroupBlobsofwithwriting in theirhairUML: The LanguageSoftwareDevelopmentPublicFeedbackAnd small adornments in the airAnd has-relations everywhereAdopted majorrevision(2004)I've lookedat cloudsthat way.UMLBut now I've purged them from my SunGradyCurrent minor Eliminatedrevision 2001every oneUMLSo many things I would have doneTo drive the clouds away.Minor revision 1999UMLI've looked at clouds from both sides nowBoth inNovand1997out, and still somehowOMG Acceptance,JimIt'stoclouds'delusionsUMLFinal submissionOMG, Sept1997 I appallI really can't stand clouds at all Balls for multiplicityUML partnersUMLBlack and white for clarityAnd data flows arranged in treesWeb - June 1996 Were part of OMT.UMLIvarBut now I've had to let them goOOPSLA 95 We'll do it differently, you knowUnified Method'Cause Grady said, they've got to goWe can't use OMT.Other methods OOSE2.01.51.31.11.00.90.8Booch method OMT9

IBM Software GroupApproach 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.x10

IBM Software GroupFormal 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 GroupInfrastructure 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 GroupOCL Requirements! Define an OCL metamodel and align it with the UMLmetamodel!OCL navigates through class and object diagrams must share acommon definition of Class, Association, Multiplicity, etc.! New modeling features available to general UML users!Beyond constraints!General-purpose query language13

IBM Software GroupDiagram Interchange Requirements! Ability to exchange graphical information between tools!Currently only non-graphical information is preserved during modelinterchange!Diagrams and contents (size and relative position of diagramelements, etc.)14

IBM Software GroupSuperstructure 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 modeling15

IBM Software GroupSuperstructure 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 required16

IBM Software GroupLanguage Architecture!A core language a set of optional “language units”! Some language units have multiple “levels”StateMachinesStructuredClasses andComponentsActivitiesMultipleMultiple levelslevels ofofcompliancecomplianceLevelLevel 33InteractionsDetailedActionsFlowsLevelLevel 22MOFProfiles OCLLevelLevel 11Basic UML(Classes, Basic behavior, Internal structure, Use cases )UML Infrastructure17

IBM Software GroupThe UML 2.0 Specification! Can be downloaded 8

IBM Software GroupAgenda! The Importance of Modeling! The Unified Modeling Language! Model-Driven Architecture! UML Diagrams! Extending the UML19

IBM Software GroupModel-Driven Architecture (MDA)! An OMG initiative to support model-driven developmentthrough a series of open standards(1) ABSTRACTION(2) AUTOMATIONMDA(3)(3) OPENOPEN STANDARDSSTANDARDS ModelingModeling languageslanguages InterchangeInterchange facilitiesfacilities ModelModel transformationstransformations SoftwareSoftware processesprocesses etc.etc.20

IBM Software Group! Set of modeling languages for specific purposesThe Languages of acility (MOF)(MOF)MOFMOF“core”“core”A modeling languagefor defining modelinglanguagesGeneralGeneralStandardStandard UMLUMLGeneral-purposemodeling amodel (CWM)(CWM)For exchanginginformation aboutbusiness and dataReal-TimeReal-TimeprofileprofileEAIEAI profileprofileSoftwareSoftwareprocessprocess profileprofileetc.etc.etc.etc.21

IBM Software GroupMOF (Metamodel) Example!Uses (mostly) class diagram concepts to define! Language conceptsement! Relationships betweenElconcepts0.1 /owner*Relationship/ownedE e1.*/target1.*22

IBM Software GroupAgenda! The Importance of Modeling! The Unified Modeling Language! Model-Driven Architecture! UML Diagrams! Extending the UML23

IBM Software GroupMeta-models and Notations24

IBM Software GroupMetamodel Description of ObjectsObjectObjectNamedElementElement(from Ownerships)(from sets bsets owner}0.1Va lueS pe ci fic at ionval ue(from Expres uredefiningFeature(from StructuralFeatures)1classifierClassifier1.*inst ance(from Classifiers)1ValueSpecification(from Expressions)ObjectObject IdentifierIdentifierInstanceValue25

IBM Software GroupMetamodel StructureDifferentDifferent ared BehaviorBehaviorSemanticsSemantics26

IBM Software GroupDiagram Elements! Each diagram has a frame, a content areaand a heading! The frame is a rectangle and is used todenote a border kind name parameters !Frame is optional! The heading is a string contained in aname tag which is a rectangle with cut offcorners in the upper left hand corner of theframe!Format [ kind ] [ name ] [ parameters ]! kind can be activity, class, component,interaction, package, state machine, usecase27

IBM Software GroupFrame ExamplePackage PClass 1Class 228

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams29

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams30

IBM Software GroupActivities! Significantly enriched in UML 2.0 (relative to UML 1.x activities)!More flexible semantics for greater modeling power (e.g., richconcurrency 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 industryplayers (Microsoft, IBM, etc.)!Functional modeling from the systems engineering community(INCOSE)31

IBM Software GroupActivity 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 GroupActivity Diagram«post condition» Flight selectedFlight SelectionCancelRequestEnter DepartureAirportDepartureAirportList ofAlternativesLookup CityCancelSelectionSelect Flight[found 1flight][found 1 flight][found 0 flights]33

IBM Software GroupPartitioning tpaymentSendinvoiceCustomerInvoiceMakepayment34

IBM Software GroupPartitioning tpaymentSendinvoiceCustomerInvoiceMakepayment35

IBM Software GroupActivities: Basic Notational ElementsControl/Data FlowControl ForkActivity or ActionControl JoinObject Node(may include state)Initial NodePin (Object)Activity FinalChoiceFlow Final(Simple) Join36

IBM Software GroupExtended Concurrency Model!Fully independent concurrent streams (“tokens”)ConcurrencyConcurrency joinjoinConcurrencyConcurrency forkforkBCAZX“Tokens”“Tokens” representrepresentindividualindividual executionexecutionthreadsthreads (executions(executions ofofactivities)activities)NB:NB: NotNot partpart ofof thethenotationnotationYValid output streams:ABCXYZAXYBCZABXCYZAXBYCZABXYCZAXBCYZ37

IBM Software GroupActivities: Token Queuing Capabilities! Tokens can!queue up in “in/out” pins!backup in network!prevent upstream behaviors from taking new inputsActivity 2Activity 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 node38

IBM Software GroupActions 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 GroupObject Behavior Basics! Support for multiple ol .Action1Action1Action2Action2.Action3Action3.Input Pin(typed).VariableAVariableAData Flow40

IBM Software GroupCategories 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 GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams42

IBM Software GroupUse Case Diagram! Use case diagrams are created to visualize the relationshipsbetween actors and use cases! Use cases are a visualization the functional requirements of asystem43

IBM Software GroupActors! An actor is someone or some thing that must interact with thesystem under developmentPassengerBank44

IBM Software GroupUse Cases! A use case is a pattern of behavior the system exhibits!Each use case is a sequence of related transactions performed byan 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 FlightSearch for FlightsMake ReservationPay for Flight45

IBM Software GroupDocumenting Use Cases! A use case specification document is created for each usecases!Written from an actor point of view! Details what the system must provide to the actor when the usecases is executed! Typical contents!How the use case starts and ends!Normal flow of events!Alternate flow of events!Exceptional flow of events46

IBM Software GroupUse Case DiagramFlight Reservation SystemSearch for flightsCondition: {seatSelection available on flight}Extension point: Seat Selection«include»Make reservationExtension pointsSeat Selection«extend»Select seatPassengerPay for FlightBank47

IBM Software GroupUML 2.0 Changes! No notational changes for use case diagrams in UML 2.048

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams49

IBM Software GroupInteraction Diagrams! Interaction diagrams show the communication behaviorbetween 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 betweenparts!Timing diagram! Emphasis on change in state over time!Interaction overview diagram! Emphasis on flow of control between interactions50

IBM Software GroupSequence Diagram: tionMake reservationEnter PINverify PIN(number)validAsk for destinationDestinationDestinationShow flights (destination)51

IBM Software GroupFramed Sequence DiagramSD Make Reservation: tionMake reservationEnter PINverify PIN(number)validAsk for destinationDestinationDestinationShow flights (destination)52

IBM Software GroupComposite DiagramsSD Make ReservationSD Check PIN: tionMake reservationEnter PINrefCheckPinverify PIN(number)validAsk for destinationDestination: CustomerreservationsystemreservationmanagerEnter PINverify PIN(number)validDestinationShow flights (destination)53

IBM Software GroupCombined 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: [ min , max , Boolean-expression ]!No guard means no specified limit! Break (break)!Represents an alternative that is executed instead of the remainderof the fragment (like a break in a loop)54

IBM Software GroupCombined 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 participatinglifelines55

IBM Software GroupCombined Fragments DiagramSD Make chk OK]altrefDoTransactionerror(badPIN)[else]56

IBM Software GroupCommunication Diagram Examplesd Reserve Flightsightslferov1appightslfmonfir1.3 c:WebClient:WebServery2 paeiptcer2.11.2 confirmflights1.1 approveflights:Flight DB57

IBM Software GroupTiming Diagram Example{d.d 0.5}sd ReaderReadingr : Reader IdleReadReadDoneRead{t1.t1 0.1}UninitializedInitializet158

IBM Software GroupInteraction Overview Example! Like flow charts! Use activity graph notation forcontrol constructs! Better overview of complexinteractionssd OverviewDiagram lifelines Client, :ServerrefAuthorizationsd:Server:Clientrequest! Alternatives, options etc.! Multiple diagram types couldbe included/referenced [more][more]refDoMore59

IBM Software GroupUML 2.0 Changes! Interaction occurrences and combined fragments added! Communication diagrams created to replace collaborationdiagrams used to show interactions! New diagrams: Timing Diagram and Interaction OverviewDiagram60

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams61

IBM Software GroupClass Diagram! Class diagrams show static structure!This is the diagram that is used to generate code62

IBM Software GroupClasses! A class defines a set of objects with common structure,common behavior, common relationships and commonsemantics! Classes can be “discovered” by examining the objects insequence 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 letter63

IBM Software ightCorporatePassenger64

IBM Software GroupOperations! The behavior of a class is represented by its operations! Operations may be found by examining interaction Assign seat row and positionassignSeat(row, position)65

IBM Software GroupAttributes! The structure of a class is represented by its attributes! Attributes may be found by examining class definitions, theproblem requirements, business rules and by applying domainknowledgeThe name, address andphone number for eachperson is neededbefore a reservationcan be madePersonnameaddressphoneNumber66

IBM Software GroupClasses with Operations and ilergetName ( )getAddress ( )PassengerInterfacegetName ( )getAddress ( )ReservationaddItem ( )assignSeat ( )deleteSeat ( trowpositionFlightairlineflightNumberupdate( )67

IBM Software GroupRelationships! Relationships provide a pathway for communication betweenobjects! Sequence and/or communication diagrams are examined todetermine what links between objects need to exist toaccomplish the behavior -- if two objects need to “talk” theremust be a link between them! Relationship cy68

IBM Software GroupRelationships! An association is a bi-directional connectionbetween classes! An aggregation is a stronger form ofassociation where the relationship is betweena whole and its parts! A composition is a stronger form ofaggregation where the part is contained in atmost one whole and the whole is responsiblefor the creation of its parts! A dependency is a weaker form ofrelationship showing a relationship between aclient and a supplier where the client does nothave semantic knowledge of the supplier69

IBM Software GroupFinding Relationships! Relationships are discovered by examining interactiondiagrams!If two objects must “talk” there must be a pathway ervationManagerAssign seat row and positionReservation70

IBM Software PersonMailergetName ( )getAddress ( )PassengerInterfacegetName ( )getAddress ( )ReservationaddItem ( )assignSeat ( )deleteSeat ( trowpositionFlightairlineflightNumberupdate( )71

IBM Software GroupMultiplicity and Navigation! Multiplicity defines how many objects participate in arelationships!Multiplicity is the number of instances of one class related to ONEinstance of the other class!For each association and aggregation, there are two multiplicitydecisions to make: one for each end of the relationship! Although associations and aggregations are bi-directional bydefault, it is often desirable to restrict navigation to onedirection!If navigation is restricted, an arrowhead is added to indicate thedirection of the navigation72

IBM Software ersonMailergetName ( )getAddress ( )1PassengerInterfacegetName ( )getAddress ( )0.*Reservation0.* addItem ( )assignSeat ( )deleteSeat ( untrowposition1FlightairlineflightNumberupdate( )73

IBM Software sonMailergetName ( )getAddress ( )1PassengerInterfacegetName ( )getAddress ( )0.*Reservation0.* addItem ( )assignSeat ( )deleteSeat ( untrowposition1FlightairlineflightNumberupdate( )74

IBM Software GroupInheritance! Inheritance is a relationships between a superclass and itssubclasses! There are two ways to find inheritance:!Generalization!Specialization! Common attributes, operations, and/or relationships are shownat the highest applicable level in the hierarchy75

IBM Software rsonMailergetName ( )getAddress ( )1PassengerInterfacegetName ( )getAddress ( )0.*Reservation0.* addItem ( )assignSeat ( )deleteSeat ( untrowposition1FlightairlineflightNumberupdate( )76

IBM Software GroupRealization! Realization is a relationship between a specification and itsimplementation77

IBM Software rsonMailergetName ( )getAddress ( )1PassengerInterfacegetName ( )getAddress ( )0.*Reservation0.* addItem ( )assignSeat ( )deleteSeat ( untrowposition1FlightairlineflightNumberupdate( )78

IBM Software GroupUML 2 Interface NotationPassengerInterfacegetName ( )getAddress ( )MailerIPersonIPersonPassengerInterface is the implementationIPerson interfaceMailer uses theIPerson interfacePassengerInterfaceMailerIPersongetName ( )getAddress ( )79

IBM Software aceMailerIPersongetName ( )getAddress ( )0.*Reservation0.* addItem ( )assignSeat ( )deleteSeat ( untrowposition1FlightairlineflightNumberupdate( )80

IBM Software GroupUML 2.0 Changes! Notation for a required interfaces () added81

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams82

IBM Software GroupComposite Structure Diagrams! Composite Structure diagrams show the internal structure ofa classifier and its interaction points to other parts of thesystem!Instance view of the world! They show how the contained parts work together to supply thebehavior of the container83

IBM Software GroupAren’t Class Diagrams Sufficient?! No!!Because they abstract out certain specifics, class diagrams arenot suitable for performance analysis! Need to model structure at the instance/role eNodeleft 0.1N3:NodeN3:NodeSame class diagramdescribes both systems!84

IBM Software GroupCollaborations! In UML 2.0 a collaboration is a purely structural conceptcollaborationcollaboration!More general than an instance onnector(link(link role)role)primaryprimaryetga2b get2cgetbackup1backup1backup2backup285

IBM Software GroupRoles and Instances! Specific object instances playing specific the roles in ackup2:Dbase:Dbase86

IBM Software GroupStructured 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 upClass Namebrokerclientservice87

IBM Software GroupPorts! Interaction points! Each port is dedicated to a specific purpose and presents theinterface appropriate to that purposePorts88

IBM Software GroupPort 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» interface r«provides» interface SellTicketWebClient«uses»Proposal()Confirm()89

IBM Software GroupPorts: Alternative Notation! Shorthand “lollipop” notation with 1.x backward compatibilityProvided InterfacebuyTicketWebClientsellTicketRequired Interface90

IBM Software GroupAssembling Communicating Objects! Ports can be joined by connectors to model communicationchannels!At runtime, the WebClient is linked to the TicketServerCustomer:WebClientAgency:TicketServerA connector is constrained by a protocolStatic typing rules apply (compatible protocols)91

IBM Software GroupProtocols: 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 firmconfirm92

IBM Software GroupModeling Protocols with UML 2.0! A collaboration structure with interactionsTicket Purchase etbuyTicketrequest(request( omercustomeragencyagency93

IBM Software GroupStructured Classes: Putting Them ientsdSelectFlightsAgency:TicketServer94

IBM Software GroupStructured Classes: Putting Them tReservationsdsd95

IBM Software GroupUML 2.0 Changes! Composite structure diagrams, structured classes, ports andconnectors are new96

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams97

IBM Software GroupState 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 significantdynamic behavior98

IBM Software GroupState Diagramstate machine Make PaymentcancelEnter creditcard dataOKDo transaction:Payment TransactionaborteddoneDisplayConfirmation PageDisplayCancellation Page99

IBM Software GroupSubmachinePayment TransactionOKUser confirmationFor ansactionnot authorizedPIN requiredabortedEnter PINOKAuthorizePINPIN rejectedPIN confirmed100

IBM Software GroupSpecialization! Redefinition as part of standard class outOfService()amount() Redefine tTransaction()101

IBM Software GroupExample: State Machine RedefinitionATM! State machine of ATM to be 2

IBM Software GroupState Machine RedefinitionATM adAmount VerifyTransaction{final}{final}ReleaseCard103

IBM Software GroupUML 2.0 Changes! Protocol state machines added104

IBM Software GroupUML 2.0 agramsStateStateMachineMachineDiagramsDiagrams105

IBM Software GroupComponent Diagram! A component is a modular unit with well defined interfacesthat is replaceable within its environment! Components can be logical or physical!

IBM Software Group 9 UML: The Language of Software Development UML partners UML 1.0 Adopted major revision (2004) UML 2.0 Public Feedback OOPSLA 95 Unified Method 0.8 Other methods OOSE Booch method OMT Web - June 1996 UML 0.9 OMG Acceptance, Nov 1997 Final submission to OMG, Sept 1997 UML 1.1 Minor revision 1999 UML 1.3 Current minor revision .