Unified Modeling Language (UML)
Total Page:16
File Type:pdf, Size:1020Kb
Introduction Use Case Diagram Class Diagram Sequence Diagram Unified Modeling Language (UML) Miaoqing Huang University of Arkansas 1 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Outline 1 Introduction 2 Use Case Diagram 3 Class Diagram 4 Sequence Diagram 2 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Outline 1 Introduction 2 Use Case Diagram 3 Class Diagram 4 Sequence Diagram 3 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram What is UML? UML is a modeling language A model is an abstraction describing a system Modeling language is used to express design Use notation for depicting models UML is the de facto modeling language in software engineering Created and managed by the Object Management Group, now at version 2.4.1 (August 2011) Key persons: (three amigos) James Rumbaugh, Grady Booch, Ivar Jacobson UML includes a set of graphical notation techniques to create visual models of software-intensive systems 14 diagrams 7 structural diagrams 7 behavior diagrams 4 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram UML Diagrams 5 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram UML Diagrams – Example use case diagram class diagram sequence diagram 6 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram UML Diagrams – Example Use case diagram Describe the functional behavior of the system as seen by the user Class diagram Describe the static structure of the system: Objects, attributes, associations Sequence diagram Describe the dynamic behavior between objects of the system State machine diagram Describe the dynamic behavior of an individual object 7 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram UML Core Conventions All UML Diagrams denote graphs of nodes and edges Nodes are entities and drawn as rectangles or ovals Rectangles denote classes or instances Ovals denote functions Names of Classes are not underlined SimpleWatch Firefighter Names of Instances are underlined myWatch:SimpleWatch Joe:Firefighter An edge between two nodes denotes a relationship between the corresponding entities 8 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Use Case Diagram Use case diagrams represent the functionality of the system from user’s point of view Use case Actor ReadTime SetTime WatchUser WatchRepairPerson ChangeBattery 9 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Class Diagram Class diagrams represent the structure of the system Association Class Multiplicity Watch 1 1 1 1 2 1 2 1 PushButton state LCDDisplay Battery Time push() blinkIdx Load Now release() blinkSeconds() blinkMinutes() blinkHours() stopBlinking() Operations Attribute referesh() 10 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Sequence Diagram Sequence diagrams represent the behavior of a system as messages (“interactions”) between different objects Actor Message Object Lifeline :WatchUser :Watch :LCDDisplay :Time pressButton1() blinkHours() pressButton1() blinkMinutes() pressButton2() incrementMinutes() refresh() pressButton1and2() commitNewTime() stopBlinking() Activation 11 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram State Machine Diagram State machine diagrams represents behavior of a single object with interesting dynamic behavior Event Initial state button2Pressed button1&2Pressed Blink Increment Hours Hours Transition button1Pressed button2Pressed button1&2Pressed Blink Increment Minutes Minutes State button1Pressed button2Pressed Stop Blink Increment Blinking Seconds Seconds Final state 12 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Outline 1 Introduction 2 Use Case Diagram 3 Class Diagram 4 Sequence Diagram 13 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram What is a use case? Scenario A sequence of steps describing an interaction between a user and a system The customer browse the catalog and adds desired items to the shopping basket. When the customer wishes to pay, the customer describes the shipping and credit information and confirms the sale. The system checks the authorization on the credit card and confirms the sale both immediately and with a follow-up email. Use case A use case is a set of scenarios tied together by a common user goal Buy a Product use case: a successful purchase or authorization failure 14 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Describe a use case A set of scenarios in the Use Case “Buy a product online”: 1. Customer browses through catalog and selects items to buy 2. Customer goes to check out 3. Customer fills in shipping information 4. System presents full pricing information, including shipping 5. Customer fills in credit card information 6. System authorizes purchase 7. System confirms sale immediately 8. System sends confirming email to customer 15 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram An Example uc Use Cases System Boundary receive order Order <<extend>> Order Food Wine Waiter confirm order place order Serve Cook Food Food Chef <<extend>> {if wine was ordered} Serve Wine Eat <<extend>> Drink Food {if wine Wine Client was served} facilitate payment pay <<extend>> accept Pay for {if wine Pay for payment Food was Wine Cashier consumed} 16 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Actor and Use Case An actor is a role that a user play with respect to the system Actors are connected to the use cases by a line A single actor may perform many use cases A use case may have several actors performing it Four types of relationships in use case diagram Generalization between use cases Generalization between actors Include relationship between use cases Extend relationship between use cases 17 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Generalization between use cases Different versions of a use case share some actions in common and have some that are unique to each one Generalized use case: abstract use case It may never exist in a real system Specialized use case: concrete use case Pay utility bill 18 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Generalization between Actors Specialized actor can do everything the general actor can do, and more 19 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Generalization between Actors Specialized actor can do everything the general actor can do, and more 20 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Generalization between Actors Specialized actor can do everything the general actor can do, and more 21 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Include Relationship between Use Cases One use case includes the functionality of another use case Invocation of one use case by another one e.g., calling a function or invoking an operation within source code 22 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Extend Relationship between Use Cases One use case may be extended by the functionality in another use case 23 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Include, Generalization, Extend Include Use include when you are repeating yourself in two or more separate use cases and you want to avoid repetition Generalization Use Generalization when you are describing a variation on normal behavior and you wish to describe it casually Extend Use extend when you are describing a variation on normal behavior and you wish to use the more controlled form, declaring your extension points in your base use case 24 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Outline 1 Introduction 2 Use Case Diagram 3 Class Diagram 4 Sequence Diagram 25 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Class Diagram Class diagrams show the static structure of the classes that make up a system or subsystem Use case diagrams show the functional requirements of a system (or subsystem) from the perspective of the end-user of a system 26 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Classes Classes are shown as rectangles Class name Other compartments Attributes Operations Other predefined compartments Name convention Class’ name Have no space between multiple words Capitalize the first letter in each subsequent world Name of features in compartments Have no space between multiple words Capitalize the first letter in each subsequent world except the first world 27 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Associations among classes Associations represent relationships between (instances of) classes Classes collaborate with each other by passing messages and receiving responses Association name Indicates the nature of the association Associate name should begin with a capital letter Navigability: use arrow to indicate how to interpret the association Unidirectional association Bidirectional association: without arrow Role name Indicate the role played by a class in an association Attached to the corresponding association end Can use the same rule of naming features to name the role, i.e., low case the very first letter and capitalize the first letter of subsequent word 28 / 45 Introduction Use Case Diagram Class Diagram Sequence Diagram Multiplicity Multiplicity indicates how many objects may participate in the given relationship (during the run-time of your software system) *: 0..infinity 1: 1..1 n..m: low_bound..up_bound Multiplicity of an association end is not shown The multiplicity is not known The multiplicity