56
CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Embed Size (px)

Citation preview

Page 1: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

CS5103 Software Engineering

Lecture 04Requirement Specification

UML Use Cases

Page 2: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

2

Last class

Requirement Engineering Concepts

Definition

Stakeholders

Types of requirements

Process

Elicitation

Analysis

Specification

Validation

Page 3: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

3

Elicitation Approaches

Brainstorming Interviewing Ethnography Strawman/Prototype Testable User Story

Page 4: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

4

Today’s class

Requirement Engineering Analysis

Specification

Validation

Use case diagram A good notation for requirement specification

Page 5: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

5

Combination of different approaches

Brainstorm + interview Raise some questions, then ask more people

Interview + strawman/prototype Talk to interviewee with a strawman/prototype

Interview + ethnography Asking people after observing their work

Prototype + ethnography Observe how people work on a prototype

Page 6: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

6

Requirements Engineering Process

Elicitation

Analysis

Specification

Validation

Page 7: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

7

Requirements Analysis 

Requirements analysts have to understand the

system from each stakeholder's point of view

Stakeholders have different views of the system

Requirements analysts resolve conflicting views

Requirements analysts prioritize requirements Essential requirements

Desirable requirements

Optional requirements

Page 8: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

8

Requirements Analysis 

Goal Determine the scope of the software

Categorization, negotiation, and decision: Few established fixed approaches

Large amount of mental work based on domain

knowledge

Project manager/customer representative often

plays the key role

Page 9: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

9

Requirements Specification

Specify requirements Document what is required of the system to be

developed

State the requirements from the perspective of the

developers

May be a formal document (IEEE-SRS)

Page 10: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

10

Requirements Specification

Natural Language Specification

Structure Specification

Graph Notation Specification

Mathematical SpecificationFormal

Page 11: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Natural language specification

The requirements are written using numbered sentences in natural language.

Each sentence should express one requirement.

Diagrams and tables can be used for better understanding of the specification

11

Page 12: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Guidelines for writing requirements

Formatting Invent a standard format and use it for all requirements

Font, size, indentation, …

Use text highlighting to identify key parts of the requirement.

Wording Use language in a consistent way.

E.g. always use shall for mandatory requirements, should for desirable requirements

Avoid the use of computer jargon

Including a list of term definitions

Page 13: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Guidelines for writing requirements

Contents Avoid ambiguity in expression

Add as much details as you can (think as a developer)

Page 14: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

An example of natural language specification

1.1 If sales for current month are below target sales, then report is to be printed, unless difference between target sales and actual sales for the current month is under 5%

Any problems with this specification?

Page 15: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

An example of natural language specification

1.1 If sales for current month are below target sales, then report is to be printed, unless difference between target sales and actual sales for the current month is under 5%

Any problems with this specification?

Ambiguity: 5% of actual sales or target sales?

Page 16: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

An example of natural language specification

1.1 If sales for current month are below target sales, then report is to be printed, unless difference between target sales and actual sales for the current month is under 5%

Any problems with this specification?

Potential term inconsistency: sales & actual sales

Page 17: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

An example of natural language specification

1.1 If sales for current month are below target sales, then report is to be printed, unless difference between target sales and actual sales for the current month is under 5%

Any problems with this specification?

Lack of details:

What are contents in the report? When and how to print?

Page 18: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

An example of natural language specification

1.1 If sales for current month are below target sales, then report is to be printed, unless difference between target sales and actual sales for the current month is under 5%

Any problems with this specification?

Terms require definition:

Actual sales, target sales, current month

Page 19: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Advantages of Natural Language

Expressive, can express almost any concepts, although not precisely

Can be understood by users, customers, developers, etc.

Easy to write

Page 20: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Problems with natural language

Ambiguity, imprecision

Contradictions can happen

Functional and non-functional requirements tend to be mixed-up

Several different requirements may be expressed together

Page 21: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

21

Requirements Specification

Natural Language Specification

Structure Specification

Graph Notation Specification

Mathematical SpecificationFormal

Page 22: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Structured specifications

The structure of a requirement is predefined

The freedom of the requirements writer is limited

Some common structures: Forms

Tables

Chapter 4 Requirements engineering 22

Page 23: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Form-based specifications

Definition Definition of the function or entity Description of the action to be taken

Input & Output Description of inputs and where they come from. Description of outputs and where they go to Pre and post conditions (if any)

Dependencies Information needed & other entities used The side effects (if any) of the function

E.g., reduced credit score when you query it

Page 24: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Example: Insulin pump for blood sugar control

24Chapter 4 Requirements engineering

Page 25: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Example: Insulin Pump

25Chapter 4 Requirements engineering

Page 26: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Tabular specification

A map from inputs to outputs in the form of a table Each line corresponds to a case in inputs

The corresponding action is filled in

Particularly useful when you have to define a number of possible alternative courses of action.

Page 27: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Example: Insulin Pump

Condition Action

Sugar level falling (r2 < r1) CompDose = 0

Sugar level stable (r2 = r1) CompDose = 0

Sugar level increasing and rate of increase decreasing ((r2 – r1) < (r1 – r0))

CompDose = 0

Sugar level increasing and rate of increase stable or increasing ((r2 – r1) ≥ (r1 – r0))

CompDose = round ((r2 – r1)/4)If rounded result = 0 then CompDose = MinimumDose

27Chapter 4 Requirements engineering

Page 28: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Pros & Cons: structures

Pros Easier to control quality compared with pure natural

language Still easy to write and understand Reduce imprecision and missing of details

Cons The form of structure has strong impact on the quality of

specification, and is not easy to design Less expressiveness due to the rigid structures Still has the problem of natural language expression,

such as ambiguity, missing term definitions, etc.

Page 29: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

29

Requirements Specification

Natural Language Specification

Structure Specification

Graph Notation Specification

Mathematical SpecificationFormal

Page 30: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

30

Graph Notation Specification

Predefined Graphical models Supplemented by text annotations Existing techniques:

UML: Use case diagram Widely used: we will introduce later

Page 31: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

31

Requirements Specification

Natural Language Specification

Structure Specification

Graph Notation Specification

Mathematical SpecificationFormal

Page 32: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Mathematic Specification

Write specification using predefined formal languages

Define all concepts, inputs, and corresponding outputs /actions formally

Some popular specification languages: Z language Alloy …

Page 33: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Example: word split with Z language

Textual Description Purpose: Breaking a text into words

A text is a sequence of characters.

Certain characters are blanks: spaces, line breaks, and tabs

A word is a sequence of non-blank characters

A separator is a sequence of blank characters.

Page 34: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Example: word split with Z language

Concept Definition:

char == [CHAR] (CHAR is defined as all characters)blank == [space, line break, tab]

TEXT == seq char (seq is a predefined function, meaning a sequence of ele

ments from its set-type argument) SEPARATOR == seq1 blank WORD == seq1 (char \ blank)

Note: TEXT includes the empty sequence, but SPACE and WORD must have at least one character, so we declare them to be seq1 (non-empty sequences).

Page 35: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Example: word split with Z language

Requirement of function words

words: TEXT -> seq WORD

\forall s: SPACE; w: WORD; l,r: TEXT words <> = <> & words s = <> & words w = < w > & words (sr) = words r & words (ls) = words l & words (lsr) = words l + words r

Page 36: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Pros & Cons

Pros Precise, little ambiguity (almost pseudo code) Computer readable, so correctness can be checked with

automatic tools (e.g. model checker) Easy to write test case based on the specification

(providing oracles) Cons

Hard to understand Hard to write, costly to find people writing it and using it Expressiveness depending on the specification language

(often not expressive enough)

Page 37: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

In practice

Natural language Widely used, especially for small projects

Structure Often used as a supplement to natural language

Graph Notation Widely used in industry, business information systems

Mathematics What software often involves mathematical

specification? Compilers (programming language) Browsers (HTML) Database systems (SQL)

Page 38: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

38

Today’s class

Requirement Engineering Specification

Validation

Use case diagram A good notation for requirement specification

Page 39: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Requirements validation

Concerned with demonstrating that the requirements define the system that the customer really wants.

Requirements error costs are high so validation is very important Fixing a requirements error after delivery may cost up to

100 times the cost of fixing an implementation error.

39

Page 40: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

40

Requirements Validation

Validation can be done with techniques

Review

Prototype

Writing test cases

Verification of properties

Page 41: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Requirements validation techniques

Requirements reviews Systematic manual analysis of the requirements Regular reviews should be held while the requirements

definition is being formulated

Both client and contractor staff should be involved in reviews

Reviews may be formal (with completed documents) or informal

41

Page 42: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Requirements validation techniques

Prototyping Using an executable model of the system to check

requirements. Covered in previous lectures

Test-case generation Developing tests for requirements to check testability Used in extreme programming, also used as a validation

technique

42

Page 43: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

43

Specification Verification

Verification can be done with techniques Consistency checking

No contradictions

Completeness checking

All concepts are well defined

Formal verification of the above or other properties

Usually require mathematical specification

Model checking, automatic reasoning, …

Page 44: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

History of UML

UML appeared in 1997 after many years of modeling war: 50+ modeling languages Three leading languages

Booch, OMT, OOSE 1994 Rumbaugh (OMT) joined Booch (in Rational) 1995 Rational bought Objectory

Jacobson, OOSE -- use cases UML = OMT + Booch + OOSE + …

Page 45: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Introduction

UML is a set of modeling notations, which include 13 diagrams Static structure of the system

Class diagram Object diagram … …

Dynamic behavior of the system Use case diagram Sequence diagram … …

Page 46: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

46

We will introduce:

UML Use case diagram (requirement)

Class diagram (general design)

Sequence diagram (detailed design)

Page 47: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

UML Use Case Diagram

Used as a graphics notation for requirement engineering

System: drawn as a box

Actors: outside the system

Use cases: inside the system

Relations among use cases

Page 48: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Actors

Actors are external to the system

An actor specifies a role Users that operate the system directly

Other software systems or hardware pieces that interact with the system

One person or thing may play many roles in relation to the system simultaneously or over time

Page 49: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Use Cases

Use cases are usages of the system

Use cases capture the functional requirements Use cases provide the high-level descriptions of the

system’s functionality in terms of interactions

Use cases show inputs and outputs between the system and the environment

Use cases are from the user’s point of view

Page 50: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Use Case – An Example

ATM system Withdraw cash

Check account balance

Maintain usage statistics

Page 51: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Legend  

Actor: an entity in the environment that initiates

and interacts with the system

Use case: usage of system

a set of sequences of actions

Association: relation between actor and use cases

Includes dependency: a sub use case

Extends dependency: a subtype of use cases

<<include>>

<<extend>>

Page 52: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Initial Use Case Diagram for ATM  

Customer

ATM System

WithdrawCash

CheckBalance

TransferMoney

*

*

* *

*

*

Page 53: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

Elaborated Use Case Diagram for ATM  

Page 54: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

54

Today’s class

Requirement Engineering Specification

Natural Language

Structure Graph Notation Mathematical

Validation

Use case diagram A good notation for requirement specification

Page 55: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

55

Next class

UML Use case diagram

Class diagram

Sequence diagram

Page 56: CS5103 Software Engineering Lecture 04 Requirement Specification UML Use Cases

56

Thanks!