Use Cases - NTUA

Use Cases - NTUA

ECE 355: Software Engineering CHAPTER 2 Unit 4 (Part 1) Presentation material based on past ECE 355 notes by Prof. K. Czarneszki. 1 Course outline Unit 1: Software Engineering Basics Unit 2: Process Models and Software Life Cycles Unit 3: Software Requirements Unit 4: Unified Modeling Language (UML) Unit 5: Design Basics and Software Architecture Unit 6: OO Analysis and Design Unit 7: Design Patterns Unit 8: Testing and Reliability Unit 9: Software Engineering Management and Economics 2 What does the system do in response to

an event? In the traditional approach, a system is viewed as a collection of processes, processes interact with data elements, and processes accept inputs and produce outputs. In the OO approach, a system is a collection of interacting objects, objects interact with the outside world and with each other, and objects send and respond to messages. 3 Unified Modeling Language (UML) Sources: Largely based on a series of 3 UML Tutorials from OMG, see http://www.omg.org/uml/ UML Specification Document v1.4, see

http://www.omg.org/uml/ The Unified Modeling Language User Guide by Grady Booch, James Rumbaugh, Ivar Jacobson (Addison-Wesley, 1999) 4 UML - Outline Introduction Behavioral modeling Structural modeling 5 What is UML A graphical language for

visualizing, specifying, constructing, and documenting the artifacts of distributed object systems. It is not a OO method, but a OO modeling notation only 6 A brief history of UML 1989-1994: 50+ OO methods Clearly prominent methods Jacobsons OOSE: support for use cases to capture requirements Booch: expressive during design/construction Rumbaughs OMT: analysis+ data intensive systems

1994: Rumbaugh joined Booch at Rational 1995: Jacobson joined Rational 1996: UML version 0.9 1997: Standardized by OMG UML 1.11.4 (2.0) 7 UML Goals Define an easy-to-learn but semantically rich visual modeling language Unify the Booch, OMT, and Objectory modeling languages Include ideas from other modeling languages Data modeling (e.g., ERD) Business modeling (e.g., workflow modeling) ... Incorporate industry best practices Address contemporary software development issues scale, distribution, concurrency, executability, etc. Provide flexibility for applying different processes

Enable model interchange and define repository interfaces 8 Unifying Concepts classifier-instance dichotomy e.g. an object is an instance of a class OR a class is the classifier of an object specification-realization dichotomy e.g. an interface is a specification of a class OR a class is a realization of an interface analysis-time vs. design-time vs. run-time modeling phases (process creep) usage guidelines suggested, not enforced 9 Conceptual model of UML UML Building blocks

Rules name, scope, visibility Things Structural Behavioral Grouping Class Interaction Package Interface State machine Active class Component Node Use case Collaboration Relations Annotate

Note Common mechanisms Diagrams Class Dependency Object Association Use case Generalization Sequence Realization Collaboration Statechart Activity Component 10 Deployment Summary of diagram kinds in UML

(nine concrete kinds) Structural diagrams Static structural diagrams Class diagrams Object diagrams Implementation diagrams Component diagrams Deployment diagrams Behavior diagrams Use case diagrams Interaction diagrams Sequence diagrams Collaboration diagrams Statechart diagrams Activity diagrams 11

What will be covered Will learn some syntax, semantics, and modeling techniques Further details of UML can be found in the supplementary text: Bennet, Sketon, Lunn: UML, Schaums Outline Series, McGraw-Hill, 2001 The Unified Modeling Language User Guide by Grady Booch, James Rumbaugh, Ivar Jacobson (AddisonWesley, 1999) And in the UML Specification Document and other resources available from http://www.omg.org/uml/ 12 UML - Outline Introduction Structural modeling Behavioral modeling Use case diagrams Interaction diagrams Sequence diagrams and collaboration diagrams More about collaborations

State diagrams Activity diagrams 13 Use Cases Use-case model describes ways in which an application is to be used. Requirements are often naturally expressed as an interaction between app and user. A use case consists of an interaction between actors (user/external systems) and the application. 14 Use Case Diagram Tour Shows use cases, actor and their relationships Use case internals can be specified by text and/or interaction diagrams Kinds

use case diagram use case description 15 Use case diagrams Diagram of use cases, actors & relationships Show outwardly visible services. Uses (2 ways) Model the context of a system. Which actors interact with the system. Model requirements of a system. What the system should do. 16 Use Case Modeling: Core Elements Construct Description use case

Describes what a system /subsystem/class/interface does. A set of sequences of actions performed by a system to yield an observable result to an actor. A coherent set of roles that users of use cases play when interacting with these use cases. They live outside the system. Represents the boundary between the physical system and the actors who interact with the physical system. actor system boundary Syntax

U seC aseN am e A c to rN a m e 17 Use Case Modeling: Core Relationships <> 18 Use Case Modeling: Core Relationships (contd) <> 19 Use Case Diagram The same person (or system) may

play the roles of a number of actors at the same time Telephone Catalog Check status Place order Salesperson F ill o r d e r s Shipping Clerk Customer Billing System

Establish credit Fig. 3-53, UML Notation Guide Supervisor 20 Use Case Relationships Supply Customer Data include Order Product include Arrange

Payment include Place Order 1 * Extension points additional requests : after creation of the order extend the salesperson asks for the catalog Request Catalog

21 Use Case Relationships 1 * Place Order Salesperson 1 Supervisor * Establish Credit 22

Use Case Relationships Place order <> (set priority) Extension points set priority Place rush order <> Check password Track order <>

Validate user Retinal scan 23 Use Case Model: Use Case Diagrams and Descriptions Name Brief description Flows of Events

Preconditions Postconditions Interaction, activity and state diagrams Relationships Use-Case diagrams Special requirements Other diagrams Use Case Model Actors Use Cases .. . Use-Case Descriptions 24 Flow of events in a use case

Has one normal, basic flow (Happy Path) Several alternative flows Happy Path Regular variants Odd cases Exceptional flows handling error situations 25 Use Case Description: Change Flight Actors: traveler, client account db, airline reservation system Preconditions: Traveler has logged on to the system and selected change flight itinerary option

Basic course System retrieves travelers account and flight itinerary from client account database System asks traveler to select itinerary segment she wants to change; traveler selects itinerary segment. System asks traveler for new departure and destination information; traveler provides information. If flights are available then System displays transaction summary. Alternative courses If no flights are available then 26

When to model use cases Model user requirements with use cases. Model test scenarios with use cases. If you are using a use-case driven method start with use cases and derive your structural and behavioral models from it. If you are not using a use-case driven method make sure that your use cases are consistent with your structural and behavioral models. 27 Use case model drives the work from analysis through test Use-Case Model Realized by Design Model Verified by

Implemented by Implementation Model Test Model 28 Model requirements of a system Establish the context (actors). Consider behavior expected by an actor. Name the common behaviors as use cases. Create use case descriptions. Factor common behavior into new use cases Model use cases, actors and their

relationships in a use case diagram. 29 Use Case Modeling Tips Make sure that each use case describes a significant chunk of system usage that is understandable by both domain experts and programmers When defining use cases in text, use nouns and verbs accurately and consistently to help derive objects and messages for interaction diagrams Factor out common usages that are required by multiple use cases If the usage is required use <> If the base use case is complete and the usage may be optional, consider use <> A use case diagram should contain only use cases at the same level of abstraction include only actors who are required Large numbers of use cases should be organized into packages 30 Using use-cases

First describe flow of events for a use case in text. With refinement of your understanding, use interaction diagrams to specify these flows. Use one diagram to specify the main flow. Use variations of the main diagram to specify exceptional cases. 31 Further reading Book Writing Effective Use Cases by Alistair Cockburn (Addison-Wesley, 2000) For a use case description template and other materials see http://www.usecases.org/ 32 UML - Outline Introduction Structural modeling

Behavioral modeling Use case diagrams Interaction diagrams Sequence diagrams and collaboration diagrams More about collaborations State diagrams Activity diagrams Advanced modeling 33 What are interactions? Interaction: describes a collection of communications between instances, including all ways to affect instances, like operation invocation, as well as creation and destruction of instances The communications are partially ordered (in time) 34

Interactions: Core Elements Construct Description Instance (object, data value, component instance etc.) An entity with a unique identity and to which a set of operations can be applied (signals be sent) and which has a state that stores the effects of the operations (the signals). Action

A specification of an executable statement. A few different kinds of actions are predefined, e.g. CreateAction, CallAction, DestroyAction, and UninterpretedAction. Syntax name attr values textual 35 Interactions: Core Elements (contd) Construct Description Stimulus

A communication between two instances. Operation A declaration of a service that can be requested from an instance to effect behavior. Signal A specification of an asynchronous stimulus communicated between instances. Syntax textual Signal

Name parameters 36 Interaction: Core Relationships Construct Link Description Syntax A connection between instances. Attribute Link A named slot in an instance, which holds the value of an attribute. textual 37

Interaction diagram tour Show interactions between instances in the model graph of instances (possibly including links) and stimuli existing instances creation and deletion of instances Kinds sequence diagram (temporal focus) collaboration diagram (structural focus) 38 Interaction diagrams Sequence Diagram x y Collaboration Diagram

z 1.1: a 1.2: c x a y b 1.1.1: b c z 39 UML - Outline Introduction Structural modeling Behavioral modeling

Use case diagrams Interaction diagrams Sequence diagrams and collaboration diagrams More about collaborations State diagrams Activity diagrams Advanced modeling 40 Sequence diagram object symbol name : Class other lifeline stimulus

name () activation new () : Class delete return create 41 Arrow label predecessor sequence-expression return-value := message-name argument-list Sequence numbering schema: 1 : actionA 1.1. firstSubactionOfActionA 1.2. secondSubactionOfActionA 1.3. thirdSubactionOfActionA

2 : actionB 2.1. firstSubactionOfActionB 2.1. secondSubactionOfActionB ... move (5, 7) 3.7.4: move (5, 7) 3.1: res := getLocation (fig) return value sequence number message name argument list 3.7 *[1..5]: move (5, 7) iteration 3.7 [ z > 0 ]: move (5, 7)

condition 42 Different kinds of arrows Procedure call or other kind of nested (synchronous) flow of control (caller waits for the callee to return) Return Asynchronous flow of control (no waiting, no nesting, caller returns immediately) 43 Example: Different Arrows Nested Flow Nested Flow

teller : Order : Article teller : Order : Article Asynchronous flow caller exchange callee lift receiver

getValue getValue price dial tone price dial digit dial digit getName getName ringing tone ringing signal lift receiver

44 Condition, recursion, etc. calculator filter value [ x > 0]: getValue () [ x < 0]: transform () getValue () iterate () 45 Sequence diagram with concurrent objects 46

Collaboration diagram object symbol link symbol standard stereotype redisplay () stimulus window : Controller standard stereotype 1: displayPositions (window) 1.1 *[i := 1..n]: drawSegment (i)

standard stereotype 1.1.1a: r0 := position () left : Bead window parameter standard constraint 1.1.3.1 add (self) wire contents {new} local line wire :Wire self

: Window 1.1.2: create (r0, r1) 1.1.3: display (window) 1.1.1b: r1 := position () {new} : Line standard constraint right : Bead 47 Collaboration Diagram with stereotype links 48

When to Model Interactions To specify how the instances are to interact with each other. To identify the interfaces of the classifiers. To distribute the requirements. 49 Interaction modeling tips Set the context for the interaction. Include only those features of the instances that are relevant. Express the flow from left to right and from top to bottom. Put active instances to the left/top and passive ones to the right/bottom. Use sequence diagrams

to show the explicit ordering between the stimuli when modeling real-time Use collaboration diagrams when structure is important to concentrate on the effects on the instances 50 Example: A Booking System 51 Use Case Description: Change Flt Itinerary Actors: traveler, client account db, airline reservation system Preconditions: Traveler has logged in Basic course: Traveler selects change flight itinerary option System retrieves travelers account and flight itinerary from client account database System asks traveler to select itinerary segment she wants to change; traveler selects itinerary

segment. System asks traveler for new departure and destination information; traveler provides information. If flights are available then System displays transaction summary. Alternative course: If no flights are available then 52 Sequence Diagram: Change Flight Itinerary Traveler : Booking System Client Account DBMS Airline Reservation System

change flight itinerary get customer account get itinerary present itinerary select segment present detailed info update information available flight : : 53 Collaboration Diagram: Change Flt Itinerary 1: change flight itinerary 5: select segment 7: update information 2: get customer account 3: get itinerary

: Booking System 4: present itinerary Traveler 6: present detailed info Client Account DBMS 8: available flight Airline Reservation System 54 UML - Outline Introduction Behavioral modeling Use case diagrams Interaction diagrams Sequence diagrams and collaboration diagrams More about collaborations State diagrams

Activity diagrams Structural modeling Advanced modeling 55 Collaboration What is a collaboration? Core concepts Diagram tour When to model collaborations Modeling tips Example: A Booking System 56

What is a collaboration? Collaboration: a collaboration defines the roles a set of instances play when performing a particular task, like an operation or a use case. Interaction: an interaction specifies a communication pattern to be performed by instances playing the roles of a collaboration. 57 Collaborations: Core Elements Construct Collaboration Interaction Description A collaboration describes how an operation or a classifier, like a

use case, is realized by a set of classifiers and associations used in a specific way. The collaboration defines a set of roles to be played by instances and links, possibly including a collection of interactions. Syntax Name An interaction describes a communication pattern between instances when they play the roles of the collaboration. 58 Collaborations: Core Elements (contd) Construct

Description Collaboration- A collection of instances which Instance together play the roles declared in a collaboration. InteractionInstance Syntax Name A collection of stimuli exchanged between instances playing specific roles according to the communication pattern of an interaction. All new in UML 1.4 59 Collaborations: Core Elements (contd)

Construct Description Classifier Role A classifier role is a specific role played by a participant in a collaboration. It specifies a restricted view of a classifier, defined by what is required in the collaboration. Message A message specifies one communication between instances. It is a part of the communication pattern given by an interaction. Syntax

/ Name label 60 Collaborations: Core Relationships Construct Description Association Role An association role is a specific usage of an association needed in a collaboration. Generalization A generalization is a taxonomic

relationship between a more general element and a more specific element. The more specific element is fully consistent with the more general element. Syntax 61 Classifier-Instance-Role Trichotomy An Instance is an entity with behavior and a state, and has a unique identity. A Classifier is a description of an Instance. A Classifier Role defines a usage (an abstraction) of an Instance. id

originates from ClassName conforms to / RoleName view of 62 Classifier-Instance-Role Trichotomy Classifier Attribute-1 Attribute-2 Attribute-3 Operation-1 () Operation-2 () Operation-3 () (contd)

ClassifierRole Attribute-1 Attribute-2 originates from conforms to Operation-1 () Operation-3 () Instance AttributeValue-1 AttributeValue-2 AttributeValue-3 The attribute values of an Instance corresponds to the attributes of its Classifier. All attributes required by the ClassifierRole have corresponding attribute values in the Instance. All operations defined in the Instances Classifier can be applied to the Instance.

All operations required by the ClassifierRole are applicable to the Instance. 63 Different Ways to Name a Role / ClassifierRoleName : ClassifierName A role name is preceeded by a / Example: A classifier name is preceeded by a : / Parent : Person / Parent : Person instanceName / ClassifierRoleName : ClassifierName Example: : Person

Charlie / Parent Charlie Charlie : Person Charlie / Parent : Person 64 Association and Association Role Class Class-1 Association Class 0..5 {changeable} Class-2

view of view of / Role-1 {frozen} ClassifierRole view of 3..4 / Role-2 AssociationRole ClassifierRole An Association Role specifies the required properties of a Link used in a Collaboration. The properties of an AssociationEnd may be restricted by a

AssociationEndRole. 65 Example: A School / Teacher : Person 1 tutor student * / Student : Person program : Text position : Text faculty member * faculty 1 : Faculty 1 lecturer participant *

given course * taken course * : Course 66 Role Model vs. Class Model The Classes give the complete description while the Roles specify one usage. Role Model Class Model Extra attribute / Teacher : Person 1 position : Text * 1 : Faculty

* / Student : Person Person Resulting multiplicity program : Text * * 1 * : Course * 0..1 Faculty Resulting multiplicity

0..1 name : Text position : Text program : Text 1 * * * * Course 67 Collaboration Diagram Tour Show Classifier Roles and Association Roles, possibly together with extra constraining elements Kinds

Instance level Instances and Links Specification level Roles Static Diagrams are used for showing Collaborations explicitly 71 Collaboration Diagram at Specification Level / Teacher : Person 1 tutor position : Text faculty member * faculty 1 : Faculty student * / Student : Person program : Text * participant 1 lecturer given course *

* taken course : Course UML 1.4: The diagram shows the contents of a Collaboration 72 Collaboration Diagram at Instance Level student tutor faculty member Alice / Student John / Teacher faculty tutor student

participant Bob / Student participant : Faculty taken course faculty Sara / Teacher lecturer given course taken course English : Course faculty member

UML 1.4: The diagram shows the contents of a CollaborationInstance 73 Collaborations including Interactions Sequence Diagram x y Collaboration Diagram z 1.1: a 1.2: c x a

y b 1.1.1: b c z UML 1.4: The diagrams show the contents of a CollaborationInstance with an InteractionInstance superposed 74 Collaborations including Interactions Sequence Diagram /X /Y Collaboration Diagram

/Z 1.1: a 1.2: c /X a /Y b 1.1.1: b c /Z UML 1.4: The diagrams show the contents of a Collaboration with an Interaction superposed 75 When to Model Collaborations Use Collaborations as a tool to find the

Classifiers. Trace a Use Case / Operation onto Classifiers. Map the specification of a Subsystem onto its realization. 76 Collaboration Modeling Tips A collaboration should consist of both structure and behavior relevant for the task. A role is an abstraction of an instance, it is not a class. Look for initiators (external) handlers (active) managed entities (passive) 77

Recently Viewed Presentations

  • Prostitution

    Prostitution

    Organized Religion vs. Prostitution. Productivity? Prostitution: Fulfills man's primal urges: sex. Prostitutes make a good living. Everyone benefits. Religion. Clouds reason. Sells something of no use to consumer. Historically, reason is the cause for human's achievements and religion the cause...
  • Egyptian cotton worm - UF/IFAS

    Egyptian cotton worm - UF/IFAS

    is concerned, the distribution includes most parts of Africa, southern or mediterranean Europe and the middle east. Some of the locations include Greece, Italy, Malta, Portugal, Spain, Israel, Syria, and Turkey. ... The Egyptian cotton worm larvae will complete six...
  • Victorian Regulatory Change Measurement (RCM) - Rogers Carlisle

    Victorian Regulatory Change Measurement (RCM) - Rogers Carlisle

    Regulatory Change Measurement (RCM) is a methodology to measure reductions in regulatory burden. RCM refines and replaces the Victorian Standard Cost Model methodology (focused on administrative costs only) from 1 January 2010.
  • Database Design: Conceptual Model (cont.), UML and The ...

    Database Design: Conceptual Model (cont.), UML and The ...

    at least 5 entities with some logical connections between them The data dictionary consists of all of the attributes that you have identified for each entity, along with indication of whether the attribute is a primary key (or part of...
  • Section 5.23

    Section 5.23

    Three Aging Empires Section 5.23 Chapter 5: The Transformation of Eastern Europe, 1648-1740
  • ACCOUNTING INFORMATION SYSTEMS The Crossroads of Accounting &

    ACCOUNTING INFORMATION SYSTEMS The Crossroads of Accounting &

    DFDs can be used to identify and document control hotspots, or areas that need additional attention in order to provide adequate internal control. Step 2 is to document controls by labeling the DFD with controls. P stands for preventive control....
  • Edmodo Workshop Edmodos mission is to connect all

    Edmodo Workshop Edmodos mission is to connect all

    Arial MS Pゴシック Calibri Courier New Noto Symbol Helvetica Neue Office Theme 1_Office Theme 2_Office Theme 3_Office Theme 4_Office Theme PowerPoint Presentation Edmodo's mission is to connect all learners with the people and resources they need to reach their full...
  • PowerPoint with caring device

    PowerPoint with caring device

    Hepatitis C Testing, Treatment, Care and Support Dr Kirsty Roy Health Protection Scotland On behalf of Members of the Working Group on Testing, Treatment, Care and Support