Introduction to Software Engineering
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Software Engineering Use cases Philippe Lalanda [email protected] http://membres-liglab.imag.fr/lalanda/ Philippe Lalanda 1 Reminder Function Class diagram Object diagram Entity-relationships Activity diagram Dictionary DTD Use case diagram Data Behavior State-chart diagram Interaction diagram Philippe Lalanda 2 Reminder Requirements engineering: The state of the practice, Neill et Laplante, IEEE Software, 2003 Philippe Lalanda 3 Outline q Deinition q Use cases and UML q Uniied process q Recurring issues q Conclusion Philippe Lalanda 4 What is a use case q A nominal usage of the system q By one or several users q Achieving a user’s objective Get some money Philippe Lalanda 5 What is an objective q An important, meaningful action to be achieved q Not too low level, not too high level Use ATM Withdraw money Enter Pin Philippe Lalanda 6 Use case description q A use case describes precisely the interaction between a user and a system q Nominal interaction Well, I use the system to reserve flights. To do so, first, I give my destination and a list of possible dates. Then, the system gives me flights listed by prices, … Philippe Lalanda 7 What is a scenario q A scenario is a use case instance Ok, let us be more specific Well, let us say I want to go to Madrid in the first week of May. The system proposes me cheap flights everyday at 10pm … Philippe Lalanda 8 An analysis technique? q Not really, but an excellent support for analysis q Use cases can be built during interviews, brainstorming session, seminars What do you want Ok, let us write to achieve with this this down? system? How do you Anything to add? proceed? Philippe Lalanda 9 Use cases and requirements (1) q Use cases express a set of requirements in a speciCic form q Essential functions of the system and the way they are achieved in terms of interactions Reserve a flight Cancel a reservation Get information See all flights about a flight Philippe Lalanda 10 Use cases and requirements (2) q The description of an interaction includes objects, functions, states An important goal is to reserve a flight. To do so, first, I give my destination and a list of possible dates. Then, the system presents me flights listed by prices, … Philippe Lalanda 11 Use cases and tests q Use cases can be used to structure tests q Test deinition q Integration Reserve a flight Cancel a reservation Get information See all flights about a flight Philippe Lalanda 12 Outline q Deinition q Use cases and UML q Uniied process q Recurring issues q Conclusion Philippe Lalanda 13 Use cases and UML q UML is an object-oriented notation to build q analysis models q design models q (a bit of) implementation models q UML acknowledged that OO analysis schemas were: q Not sufCicient to capture all requirements q Not user friendly q Focused on domain data (objects) Philippe Lalanda 14 UML and requirements engineering q Use cases have been integrated by Ivar Jacobson q Requirements = Use cases + analysis diagrams Compte" Banque" 1..4" 0..*" 1..*" 1..*" Client" numéro" solde" ..." numéro" nom" titulaires" 0..*" 1" signataire" 1" 0..*" Consortium CarteBleue" 0..*" 0..1" virementPossible" 1" Code" retraitMax" EstAcceptéPar>" 0..*" Distributeur 1..*" Essential functions Essential objects Philippe Lalanda 15 Use cases and UML q! UML provides simple notations to deCine use cases (and scenarios) q! Very few symbols q! Easy to understand q! Informal (mainly textual) q! Integrated in the RUP (Rational Uniied Process) q! A process deCining and orchestrating UML-based activities Philippe Lalanda 16 Base elements System Actor Use case Use case diagram Use case model Philippe Lalanda 17 System q! A system is seen as a black box q! It is deined through the functions it provides, the interactions it supports BooksOnLine! Philippe Lalanda 18 Actors q! An external element interacting with the system q! He can be active (takes decision) or passive (gets information) q! Two kinds of actors q! Human q! System (external systems, devices, peripherals) q! Several notations <<actor>> Printer! Administrator! Client Philippe Lalanda 19 Actors and inheritance q! Only possible relation between actors q! The specialized actor inherits all the use cases of his father Client VIP Philippe Lalanda 20 Example <<actor>>! Bank WebUser <<actor>>! Provider Client BooksOnLine! Administrator VIP Philippe Lalanda 21 Actors vs. users q! Actors and actual users must not be confused q! An actor = a role q! A user = a person q! Several persons can play a same role q! Paul and Pierre are two clients q! A same person can play several roles q! Paul can be a CLient and a WebUser q! A role relates to a system not to the organization using the system q! Client rather than Student Philippe Lalanda 22 Use case q! A use case refers to an essential function q! It may include several actors q! It corresponds to a high level goals ReserveBook DeleteBook BuyBook AddBook LookForBook Philippe Lalanda 23 Use case q! A use case q! Allows an actor to reach a goal q! It corresponds a a function visible by the actor(s) q! It has to make sense (speciCic enough) ValidateInput ReserveBook ManageBooks ReserveLesMisérables Philippe Lalanda 24 Use case diagram q! Use case diagrams provide a global view of the functions q! It presents q! All the actors q! All the use cases Philippe Lalanda 25 Example Register LookForBook WebUser <<actor>>! Bank LogIn BuyBook <<actor>>! BookProvider Client ReserveBook AddBook SpecialSale DeleteBook Administrator VIP Philippe Lalanda BooksOnLine! 26 Use case diagram decoration { MUST } <<actor>>! LookForBook WebUser Bank { MUST } BuyBook <<actor>>! { SHOULD } Provider Client ReserveBook { SHOULD } AddBook { MUST } { SHOULD } SpecialSale DeleteBook Administrator VIP BooksOnLine! Philippe Lalanda 27 Use cases inclusion q! For factorization purposes q! May lead to ‘low level’ use cases BuyBook « includes » « includes » LogIn ReserveBook « includes » Philippe Lalanda 28 Side note "The UML includes relationships between use cases beyond the simple « includes » such as « extends ». I strongly suggest that you ignore them. I've seen too many situations in which teams can get terribly hung up on when to use different use case relationships, and such energy is wasted. Instead, concentrate on the textual description of a use case." [UML Distilled, Martin Fowler] Philippe Lalanda 29 Use case model q! A use case model describes a use case q! Speciies the interaction q! Not standardized q! Different styles q! Different interpretations BuyBook Client Philippe Lalanda 30 Two ways to describe interactions BuyBook Client Philippe Lalanda 31 Two ways to describe interactions BuyBook Client TextualSemi formal description description of the interactions Philippe Lalanda 32 Describing a use case (1) q! A sequence diagram allows to describe a sequence of messages between different entities q! An UML notation q! Can be used in many contexts (not invented by UML btw) q! Different detail levels Philippe Lalanda 33 Example “book search” use case Client BooksOnLine Log In (id + pwd)" Check (id, pwd) " First page with client preferences " Search a book (title and author) List of books with prices" Select a book " Ask for confirmation" " ...Philippe Lalanda 34 Describing a use case (2) q! Textual form q! UC begin, pre-conditions q! UC end, post-conditions q! Nominal path (behavior) q! Possible variants and error situations q! Interactions between system and actors q! Exchanged information q! Possible non functional needs Philippe Lalanda 35 Example Pre-condition :" The server is running, the maximum number of visitors is not reached. " BuyBook " Begin : When the site is called from a web browser" " End : When a confirmation is sent by email or whenever the client quits" " Post-condition : " The bank account is updated." The book provider has received an order. " Philippe Lalanda 36 Example Nominal behavior :" (1) The client logs in" (2) The system present a first page, containing client expected preferences" (3) The client asks for a book (title and author)" BuyBook! (4) The system presents a list of corresponding books with the prices" (5) The client selects a book" (6) The system asks for confirmation " (7)…" " Variants : " (A) Invalid Id or password : during step (1) …" (B) Invalid book : during step (3) ..." " Philippe Lalanda 37 Example Non functional constraints :" " (A) Performance : the system has to react in less than 5 BuyBook! seconds, whatever the operation is" (B) Fault tolerance : if a fault occurs during the use case, transaction has to be cancelled. Bank account not updated, no order to the books provider. $ The system must be able to restart in a coherent state without human intervention. " " (C) Load : the system must be able to manage 1000 users" concurrently" Philippe Lalanda 38 Example of scenario SCENARIO 4" " BuyBook •! Paul logs in on Sunday morning (at 7:00) " •! The system presents the most recent books about SciFi" •! Paul looks for Robots by Asimov " •! The system provides 3 books corresponding to the request " •! Paul selects the first one (the cheapest)" •! The system asks for confirmation" •! …" Philippe Lalanda 39 Use case vs. scenarii model instances Philippe Lalanda 40 Outline q! Deinition q! Use cases and UML q! Uniied process q! Recurring issues q! Conclusion Philippe Lalanda 41 Uniied process q! An accompanying process to deCine and organize UML activities q! Based on UML notations q! Activities ①! System preliminary description ②! DeCine use case model ③! Deine relationships between use cases ④! Detail each use case (considering priorities) Philippe Lalanda 42 System preliminary description q! Give a name to the system q! As soon as possible q! Likely to be used all along the development q! Brief textual description (a few lines) The software system BooksOnLine is a Web site which purpose is to sell books. It is specialized on novels.