Professional Documents
Culture Documents
Course Overview
Part I Part II
University University
Course Overview
✓ Software Testing
✓ Web Engineering
✓ Project Management
Part I:
QUIZ 1: 20%
Part II:
QUIZ 2: 20%
IE4001
Software Engineering
Part I - Overview
Q2exam
The materials of Part I covers the most essential and fundamental knowledge in Software
Engineering. These are obtained from many books after in-depth understanding, hence,
◦ It is Very IMPORTANT to follow the lecture so that you can have a good understanding of
References
❑
Pressman Roger S, Software Engineering: A Practitioner's Approach, 9th Edition,
McGraw-Hill, 2020.
❑
Sommerville Ian, Software Engineering, 10th Edition, Pearson/Addison- Wesley, 2016.
❑
Mark Priestley, Practical Object-Oriented Design with UML, 2004, McGraw-Hill.
Paul C. Jorgensen, Software Testing: A Craftman’s Appraoch, 2nd Edition, CRC Press,
2002.
❑
Mauro Pezze, and Michal Young, Software Testing and Analysis: Process, Principles
and Techniques, Wiley, 2008.
❑
Roger S. Pressman and David Lowe, Web Engineering: A Practitioner’s Approach,
McGraw-Hill, 2009.
❑
Bob Hughes and Mike Cotterell, Software Project Management, 5th Edition, McGraw-Hill,
2009.
Unit 1 Introduction
❑ Software
❑ Software Process
DEC 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG;; TEL:67905377 1
Software
What is Software?
Today, software is almost used in any area including home, business, health care,
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
2
Software Engineering
Definition
Software
Some Areas
◦ Software Modeling: Theory and methods for specifying software requirements and
design
◦ Software Security: Implement and audit security defense in software systems (most
◦ Software Economics: Theory and methods for estimating resources and costs of
◦ Many more
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
3
❑ Software engineering deals with the development of large and complex systems which
✓ these methods are called modeling methods; outputs created by them are called models
or specifications
➢ Communication skills
➢ Management skills
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
4
Software Process
memov
I 1
Each activity is populated by a set of actions. Each action is defined by a set of tasks to
2.Planning: plan technical tasks, resources, work products, work schedule; analyze risks
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
5
Software process model gives a brief view (abstracted view) on how software is developed
We
shall discuss:
❑ Prescriptive models that are not specific to any software engineering approach (e.g., USDP
discussed in Unit 5)
❑ The general characteristics of agile software development (does not follow any fixed
model, and is also not specific to any software engineering approach)
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
6
Prescriptive Process Models
Three
types:
❑ Waterfall Model
memorise
❑ Incremental Model
❑ Evolutionary Model
practice, these models are chosen depending on the environment, resources,
In
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
7
Communication
Project initiation
Estimating
Scheduling Modeling
requirements
Design Code
Deployment
Test
project Delivery
models
plan Support
exe
✓ Five phases are arranged in sequence.
✓ The result of each phase is one or more documents that are approved.
✓ The following phase should not start until the previous phase has finished.
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
8
Waterfall Model
✓ Well-defined requirements
✓ Adequate resources
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
9
Communication
Planning
Software Functionality and
Features
delivery of
2nd increment
overlap
delivery of
1st increment
Project Calendar Time
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
10
computerhardware
Incremental Model – Main Characteristics
Rather
than deliver the system as a single delivery, the development and
delivery
is broken down into increments
✓ Each increment delivering part of the required functionality.
✓ The first increment is called the core product which addresses the basic
requirement, later increments address modifications and additional
functions and features.
✓ Different process model can be used for different increment.
User
requirements are prioritised and the highest priority requirements are
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
1 11
quickly and then refine and expand on that functionality in later software
releases.
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
12
Evolutionary models
software.
Two sub-models
❑ Prototyping guideoverview
❑ Spiral
of project
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
13
Prototyping –
definition is mandatory
occurs.
of a prototype.
✓ Iteration occurs as the prototype is tuned to satisfy the needs of the customer
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
14
Prototyping
✓ Small systems
✓ User-interface intensive
✓ Unclear requirements
✓ Lack of expertise/experience
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
15
Combines
iterative nature of prototyping and the controlled and systematic
aspects
of the waterfall model.
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
16
The spiral
The space around the spiral is divided into five segments, each representing one
key process activity, the circuit around the spiral represents the activity to carry out
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
17
The Spiral
✓ Complex requirements
Compare with
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
18
Choose
In
practice, one may combine a number of process models together for a project.
Example:
✓ Problem: A large system with (1) reasonably well-defined requirements; (2) except
a small user-interface intensive part of it, the project team has sufficient
✓ Solution: (1) Develop the system using incremental model such that each
increment is of moderate size and the part that the project team does not have
increment using waterfall model and develop J using prototyping (Note that our
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
19
guidelines
Manifesto
While the items on the right are still important the items on the left are more valuable
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
20
What is “Agility”?
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
21
Agility
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
22
An Agile Process
implementation
DEC 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG;; TEL:67905377
23
Dec 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG 1
Requirements Analysis program
data f algorithm
-
We can classify the requirements for software into two aspects:
▪ Data: Information to deal with
-
In traditional techniques for requirement analysis:
• Data and processes are modeled (systematically described) separately and
conceptually
• The modeling of data is called data modeling.
• The modeling of processes is called process or behavioral modeling.
-
In this unit, we shall cover some well-known modeling techniques for
requirements analysis:
• For data modeling: we shall cover Entity-Relationship (ER) modeling
memof• For process modeling: we shall cover Data Flow Diagram (DFD) technique
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
2
Basic Principle:
logical) viewpoint
process
◦ focus attention on the data domain intelligent
fundamental task to focus on some target aspect and ignore other aspects)
Basically, ER modeling describe the data in a system by entity types and the
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
3
t student
Each entity plays a necessary role in the system, i.e., the system could
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
4
quiz
content
model things?
◦ Student
◦ Supplier name;
◦ Student address
example:
◦ IBM: a supplier
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
5
Things that the system need to keep track of their status. For example:
example:
◦ Order Processing System: Customer Order (to monitor the delivery and
subsequently)
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
6
Defining entity types in ER diagram
entity type is described by a set of attributes to show
An the characteristics of
each
instance of the entity type
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
7
interactions
The
types.
Each
relationship type.
In
general, a relationship type may relate one, two, three, etc., entity types.
However,
we shall discuss only the first two. These two are quite sufficient
for
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
8
things?
example:
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
9
Relationship Type
represented
by a line connecting the two entity types. The name
of
Example:
The teach relationship type discussed in the slide 8 can be specified as
follows:
entity entity
relationship
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
10 I
memorise
mat min
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
11
Specifying Further Information to a Relationship Type in ER
Diagram
◼
We can specify a pair of cardinalities at each entity type end in a
relationship type as shown in the following example:
ez fi
ez
exactly otomany Cea fz
◼
Definition: A pair of cardinalities specified at an entity type F end to
define that:
Each instance of entity type (E) at the other end is related to, at least the
minimum number and at most the maximum instances, of F.
We can add Role to each end of a relationship type to tell the function that
the entity type plays in the relationship type.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
12
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
13
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
14
ER Diagram : An Example
The next slide will interpret the relationship type between Shipment and Supplier as an
illustration
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
15
The meaning of the relationship type between Supplier and Shipment entity type in
◦ Each individual supplier (an instance of Supplier entity type) sends 0 to many
◦ Each shipment (an instance of Shipment entity type) is sent by exactly one
supplier.
◦ Supplier entity type plays the role of “sends” in the relationship type and
supplier S also sends shipment Y, then these are represented by two instances
respectively. l
tuple l
◦ If supplier T (an instance of Supplier entity type) does not send any shipment at
this point in time, T will not involve in any instance of this relationship type.
Following the above mathematical representation, this means that T will not form
Dec 2022
CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
16
x
Building an ER Diagram
Level 1—identify the data entities in the problem and model them as entity
types.
Level 2— identity the interactions between the data entities in the problem and
Level 3—refine and fine tune the initial model and include attributes for entity
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
17
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
18
DFD – Principle
level
information
transformer output
input
information system
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
19
of processing)
key
collection of “functions” that interact with its external environment. You can
A DFD is drawn by just using four basic concepts: external entity; process;
data flow and data store. These basic concepts will be explained in the next
five slides.
DFD does not include control flow (sequence, selection and looping).
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
20
rectangle
the circle
direction
files dB cloud
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
21
External Entity
system
Basic Principle
something
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
22
Process
I to output), a task
Basic Principle
function
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
23
Data Flow
of data
onedirection
Example: base and height are input data flows and area is an
base
compute
area
triangle
height area
Basic Principle
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
24
Data Stores
input sensor #
sensor #, type,
sensor
type,
sensor data
Basic Principle
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
25
All
decompose the requirements from the highest to the lowest level) – the
process
process and the DFD must be consistent (balanced, will illustrate in the
◦ All data flows from the process must be shown in the lower level DFD
correctly
◦ Do not re-show any higher level process in the lower level DFD
always
always
do
not show control flow (that is the sequence, selection and looping of
processes)
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
26
processing
video
digital signal
video monitor
processor
video
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
27
there are a b
x P y level 0
pips
a c p2
p1
f
b
p4
d p5
p3 e g
level 1
Two DFDs on this slide (one for level 0 and one for level 1)
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
28
levell
levels
(1) Three DFDs are shown on this slide (level 0, one and two).
For simplicity reason, the external entities are skipped in the context diagram.
(2)
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG 2
The Process of Constructing DFD
Start
by drawing DFDs to describe the existing system. The resulting DFDs are called
existing physical DFDs. In these DFDs, we may name a process by the person who
Transform
existing physical DFDs to DFDs for the target system by:
◦ Removing physical features: for example if a process is named by a person who
performs the task, we change the name to describe its function instead.
◦ Include enhancements to improve the system
Draw higher-level DFD before lower-level DFD: use a 1:5 (approx.) expansion ratio as
Define
all the data flows and data stores using a data dictionary: discuss later
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
30
DFD – An Example – SafeHome Security System
Configuration: homeowner registers his/her id and password, and other
configuration information through control panel.
Start and Stop: homeowner activates and deactivates respectively the
system.
Upon detection of an external sensor event: according to the configuration
information, the system:
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
31
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
32
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
33
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
34
In the DFDs shown in the last three slides, assuming that in the level 1 DFD,
except the “Monitor sensors” process, other processes do not need further
decomposition, then the DFDs shown in the last three slides together form
the diagrams of a complete set of DFDs for modeling the SafeHome security
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
35
Data Dictionary
Data specification: A specification is included for each data flow and data
store.
process.
◦ Note that once all the lowest-level processes are specified, any higher-
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
36
Data Specification (I)
To
describe each data flow and data store in DFD by a combination of data
items
in a hierarchical way. Data items are combined using four basic
structures--
sequence; iterate; optional; case.
Sequence:
sequential combination of data items
◦ Notation: +
◦ To indicate that data item B is after data item A, we specify A + B
◦ Example: Student name has surname and other name, and surname
appears first. So, we specify:
◦ Name = Surname + Other Name
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
37
◦ Notation: {}*
Otomany
◦ To indicate the combination of multiple values of data item A together, we specify {A}*
◦ Notation: ()
◦ To indicate the optional combination of data item A – A may or may not have a value--, we
specify (A)
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
38
Case:
OR
specify [A |B |C]
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
39
Data Specification – A more complete Example
An
incomplete DFD:
Tania
the above DFD, the data flow, Order (a purchase order), consists of four attributes: Supplier-
In
▪ Supplier-Name always has a First Name and a Last Name, and there may be a Middle Name
also.
▪ Date-Ordered is an elementary data item.
▪ Method-of-Payment must be one of the three values: Check, Credit-Card or Money-Order.
▪ Order-Items is formed by a number of values of the lower-level attribute Order-Item, which in
turns, has two mandatory elementary attributes, Item-Name and Qty-Ordered.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
40
Item-Name Qty-Ordered
HP xw4400 Workstation 2
………. ……..
iompulsory
o ormany
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
41
bubble
PSPEC
narrative
pseudocode (PDL)
equations
tables
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
42
Using programming language like syntax for the three basic control
You have studied in EE2008, so, we will just take a quick look of an
example.
Example:
read (x);
while x y loop
End
if x > y then
x := x – y;
else
gqyggmm.in
8
ceanauage
y := y – x; compile
I
end loop;
end if; w
another 0110011000111
end;
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
43
Requirements analysis
◦ indicates software's interface with other system elements: all the external
interactions
◦ establishes constraints that software must meet: the environment that the target
engineering tasks
◦ build conceptual models (that is logical without taking physical implementation into
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
44
A Bridge
system
description
analysis
model
design
model
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
45
Rules of Thumb
The model should focus on requirements that are visible within the problem or
business domain. The level of abstraction should be relatively high (that is, it should
not include physical details of the target environment, for example, the hardware
software requirements and provide insight into following need of the system:
◦ information: data
◦ Behavior: processing
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
46
Structured Analysis
The main requirements analysis methodologies are: Structured Analysis and Object-
Oriented Analysis
data and the processes that transform on data separately through performing:
the requirements captured (the operating environments of the software should not
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
47
Unit 3
UML Modeling I – Structural Modeling
-
UML stands for Unified Modeling Language
-
UML has been accepted as a standard language for modeling software problem
and solution in the industry
-
UML is a semi-formal language that is graphical-oriented and supplemented by
textual language
-
We shall study:
- Structural modeling (modeling the structure of information and processes) : the
basic UML modeling technique, Class Diagram, in details.
-
This unit covers structural modeling. Next unit covers behavioral modeling.
Dec 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG 1
UMLI
Organize software problem and solution in terms of the basic concept, Object, that
will be discussed shortly: That is, the problem is decomposed into problem objects
Object has many attractive features to support good software design and make
Class diagram can be used for both requirements analysis and design: a design
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
2
Object – Concept and Properties
◼
An object is an abstraction of something in a problem domain,
reflecting the following things
sort together
together:
◼ its information
◼ tasks that it can perform or can be performed on it
◼
Objects have state and behaviour:
◼ State: the condition of an object at any moment, affecting its behaviour
◼ Behaviour: what an object can do, or how it can respond to events (tasks)
◼
Object is specified by:
◼
Objects in a system interact: Relationships are used to specify
the interactions between objects.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
3
Examples of Objects
worn.
cancelled.
ketchup. empty.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG 4
Specifying Objects
under i was
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
5
Class:
◦ Lecturer
◦ Student
Object:
◦ IBM: a supplier
◦ Supplier name
◦ Student Address
Operation:
◦ Compute interest
◦ Draw a circle
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
6
Notation
Class Name
•••
•••
methods
Example
Person
name
age
job
address
change-job
change-address
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
7
Bank Account
Owner: String
Balance: Dollars = 0
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
8
and use relationship types to specify all the interactions between them.
Classes: to specify all the objects designed to solve the target problem.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
9
Types of Relationships
boonschapter
superclass
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
10
Specifying Associations
connecting the two associated classes with its name shown along the
line.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
11
Specifying Associations
Person
address address
Project
Supplier Part
Ship
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
12
similarto cardinality
Notation
for Multiplicity:
✓ j..j is simplified as j. I
✓ Example:
- 6..8 617,8
- 1
- * jimann
- 0..1
O or I
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
13
We
A key
can specify a multiplicity j..k (in general) at each associated class end in an
slid
associated
Each combination of C1,… Cn-1 instances, one from each of them, associates to at
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
14
Role: Optionally, each class end in an association can be labeled with a role
name
association may also have attributes.
An Aiman michael trompany
Example:
michael 72 iompanies
i t
onmany Person
Company 1 *
name name mienae
address El employer employee social security no.
address
Works-for
went
salary
E Peter job title
I E george
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
on YMployees 15
ECKCHAN@NTU.EDU.SG
For
example, we can uses a “Work-for” association to represent the
interactions
between companies and people working for them:
-- Each person works for one company.
-- Zero to many people work for each company
Company 1 Works-for *
Person
name name
social security no.
address
address
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
16
specified has two attributes: salary and job title. We can refine the
Company 1 *
Person
name name
address
Works-for
salary
job title
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
17
File
O *
O * User Oto many
files
Accessible by
access permission
Meaning: each file is accessible by zero to many users and each user accesses zero to many files and the
Person
Company 1 *
name
name boss
social security no.
address 0..1
address
Works-for worker *
salary
job title
Manage
performance rating
Note that Manage is an association that associates different objects of Person Class: Each boss manages
many
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
18
The
Iprjl S1 P1
IF Project IFyp si pl
* Otomany
Supplier * * Part
Use
Quantity
This
Quantity
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
19
in Association
by the association.
✓ Examples will be given in the next few slides to further illustrate the
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
20
In the “Work-for” binary association shown at the bottom of this slide, if there are three people
p1, p2 and p3 working for company c1, then there are three links (instances) to represent the
fact:
Each link is also called an instance of the “Work-for” association. Mathematically, these three
In the above association, if c2 is a newly formed company and has not employed any employee
yet, then c2 will not involve in any instance (or link) of the association.
name name
social security no.
address
address
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
21
In the “Use” ternary association shown at the bottom of this slide, as an illustration,
✓ Project proj1 uses 30 pieces of part pt1 from vendor v1: this is described by the
instance of “Use” that associates v1, pt1 and proj1, with attribute Quantity = 30.
Mathematically, this instance is denoted as (v1, pt1, proj1) with attribute Quantity = 30.
✓ Project proj2 uses 10 pieces of part pt1 from vendor v1: this is described by the
instance of “Use” that associates v1, pt1 and proj2, with attribute Quantity = 10.
Mathematically, this instance is denoted as (v1, pt1, proj2) with attribute Quantity = 10.
✓ Project proj2 uses 20 pieces of part pt1 from vendor v2: this is described by the
instance of “Use” that associates v2, pt1 and proj2 with attribute Quantity = 20.
Mathematically, this is denoted as (v2, pt1, proj2) with attribute Quantity = 20.
Project
Vendor Part
* *
Use
Quantity
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
22
multiplicity
Company Works-for Person
1 *
a 92 I 3 Pl P 2 173 P4
same person Iannotwork for 2 wmpanies
Multiplicity has implication on the instance structure: If we know the instances of the associated
classes,
from the multiplicities, we can make some deduction on possible sets of instances of this
“Work-for”
association. For example, if at this moment, there are three companies, c1, c2 and c3,
and
◦
Some possible sets of instances of this association are:
◦ {(c1, p1), (c2, p2), (c3, p3), (c3, p4)}
seiginstances
◦
Some impossible sets of instances of this association are:
works
◦ {(c1, p1), (c2, p1), (c2, p2), (c3, p3), (c3, p4)}: this is not possible as p1 works for two
Zaniest companies - violate the “1” multiplicity at Company.
◦ {(c1, p1), (c2, p2), (c3, p3)}: this is not possible as p4 does not work for any company –
violate the “1” multiplicity at Company
Note
that the above possible and impossible sets are not exhaustive: There could be some more.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
23
Instance Structure and Multiplicity in Ternary Association -- Example
test
R alibi C
* 1
ah A a C
*
by B bi pas b4 4
195163,64
In the association R, from the multiplicity specified:
◦ For each combination of instances one from A and one from B, there is a
unique C instance associates with it.
◦ For each combination of instances one from A and one from C, there are
Is
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
24
Instance Structure and Multiplicity in Ternary Association -- Example
R
* 1
A C
*
B
Multiplicity has implication on the instance structure: Similar to binary association case, at any
point in time, if we know how many objects each class has, then we can deduce possible sets of
instances
of R.
For
example, if class A has one object, a1; class B has two objects, b1 and b2; class C has two
objects c1 and c2. Then:
◦ Some possible sets of instances of R are:
◦ {(a1, b1, c1), (a1, b1, c2)}: this is not possible as the combination of A and B object, a1 and
b2, does not associate with any C object - violate the “1” multiplicity at class C.
◦ {(a1, b1, c1), (a1, b2, c1), (a1, b2, c2)}: this is not possible as the combination of A and B
object, a1 and b2, associates with two C objects, c1 and c2 – violate the “1” multiplicity at
class C.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
25
part andassembly
“assembly” class
Document Assembly
1 do made
document
1 A para is
of many
sentenies
instance is a part of a
* paragraph instance
Sentence
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
26
further
classified into several sub-types.
type is represent by a class called the super-class in a generalization. Each sub-type is represented
The
one class called a subclass in the generalization.
by
object ofsub lass
Each object (instance) of a subclass is an object (instance) of the super-class.
is an objectofsuffy
A
subclass inherits all the properties and operations from the super-class, and can override them by
redefinition
if not applicable.
gvingthing
ton
Iggy
no
tank Ii object
Yass overriding
instance of
• Class Y inherits attribute x1 from class X. It overrides the attribute x2 inherited from class X
by redefining it. In addition, it also defines a new attribute y2. So, altogether class Y has three
attributes: x1 inherited from X, and x2 and y2 defined in Y itself.
• Class Z inherits attribute x1 and x2 from class X. It defines attribute z1. So, altogether class Z
has three attributes: x1 and x2 inherited from X, and z1 defined in Z itself.
• Each instance of Y and Z is an instance of X.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
27
Generalization - Examples
EMPLOYEE
EmplNumb
X EmplName
superclass RegNew
f Salary
Y HOURLY SALARIED
EMPLOYEE
inherit
EMPLOYEE empinum
g OverTime
Salary
Salary computed
• Y is a sub-type of X. differently
• There are two types employees, hourly employee and salaried employee.
• classes HOURLY and SALARIED define their own version of operation Salary
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
28
However,
the converse is not true. That is, an instance of a super-class may not be an
instance
of any of the sub-class.
example, in the following generalization: A NBS student is an instance of the super-class,
For
NTU
Student. But, he/she is not an instance of any of the two subclass (EEE Student, SCE
Student).
above fact is because the classification represented by a generalization is not an
The
exhaustive classification.
Note
that a generalization represents the relationship between type and sub-types. Such
relationship is in fact constructed from a classification.
instanceof new studentsmany
super last maynot beinstanceofsubclass
Meaning: EEE student
Albert Mary NBS
and SCE student are
types of NTU students
sub albert
class
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
29
How
to use association, aggregation, generalization, and their Instances (if any) to
model things?
Association:
to model a general type of interactions, for example:
◦ Suppliers ship products
◦ Teachers teach students
Instance
Aggregation:
to model a part-and assembly kind of interactions, for example:
◦ A personal computer has a CPU
◦ The book titled “C programming for beginner authored by C. K. Lee” has 10 chapters
◦ Students are classified into course work and research students
◦ Employees are classified into daily-rated and monthly-rated.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
30
rep of us
Dileaver
Aggregation Versus Association
◦The decision to use aggregation is a matter of judgment. Often it is not obvious if an association should be
modeled as an aggregation. If you exercise careful judgment and are consistent, the imprecise distinction
between aggregation and ordinary association does not cause problems in practice.
◦Association is not the same thing as generalization. Association relates instances. Distinct objects are
involved. Generalization relates classes and is a way of structuring the description of a single object. With
generalization, an object of a subclass is simultaneously an instance of the subclass and its super-class.
Aggregation
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
31
Meaning:
lecturers
teach
students
car
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
32
Properties
✓ Generalization:
✓ Aggregation:
✓ Association:
◦Association describes the connections (links), each of which connects different objects
✓ If it does not satisfy the properties of generalization, then check on the above properties of
✓ If it does not satisfy both the properties of Generalization and Aggregation, then it is an
association.
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
33
Example for using class diagram technique – The problem
Draw
a class diagram to model the structural properties of the program committee of an
The
committee is formed by a program chair and more than twenty program committee
members.
The program chair manages the program committee. Each paper submitted
by
authors is managed by one program committee member and reviewed by four
reviewers.
A program committee member manages at least twelve papers. A reviewer
reviews
many papers. After the review of all the papers has been completed, a paper is
either
accepted or rejected. Authors may submit multiple papers.
dans T Tay
Vs
Dec 2022
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
ECKCHAN@NTU.EDU.SG
34
relationship
paper
generalisation
paperon
Dec 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG 1
Requirements Specification
To describe the requirements gathered from users systematically, the major
techniques can be classified into the following types:
✓ meetings are conducted and attended by both software engineers and customers
✓ rules for preparation and participation are established
✓ an agenda is suggested
✓ a "facilitator" (can be a customer, a developer, or an outsider) controls the
meeting
✓ a "definition mechanism" (can be work sheets, flip charts, or wall stickers or an
electronic bulletin board, chat room or virtual forum) is used
✓ the goal is
◦ to identify the problem
◦ propose elements of the solution: business solution not software solution
◦ negotiate different approaches
Prioritization of requirements: prioritize the requirements for implementation according
to their importance, dependency, resources, etc.
I
Homeowner uses the first four use-cases and system administrator uses the last
one.
The last three use-cases also interact with sensors.
I Ar ms / di s ar ms
s y s t em
non human
actor
2
Ac c es s es s y s t em s ens or s
v i a Int er net
homeow ner
numan 3
actor Res ponds t o
al ar m ev ent
4
Enc ount er s an
er r or c ondi t i on
human 5
Rec onf i gur es s ens or s
actor s y s t em
admi ni s t r at or and r el at ed
s y s t em f eat ur es
Basic Task:
◼ Check the consistent through verifying the various parts of requirements
specifications against each others
◼ Check the correctness and completeness through review the requirements
specifications with users
After paper jammed is cleared, it will invoke read operator command to allow user to
start making copies again (continue).
event start
full and start y
invoke manage-copying reading
operator
commands full
copies done invoke
read-op-
ma Invoke read-op-input
input
making copies
reloading paper
empty
jammed invoke reload paper
invoke problem-diagnosis
problem state
not jammed
invoke read-op-input
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG
22
Example - a Simple Microwave Oven
It has a switch to select full or half power, a numeric keypad to input the cooking time,
a start/stop button, and a numeric display.
The sequence of actions in using it is:
◦ Select the power level (half or full power).
◦ Input the cooking time using a numeric keypad.
◦ Press start and the food is cooked for the given time.
For safety reasons, it should not operate when the door is open and, on completion of
cooking, a buzzer is sounded. It has a very simple display for showing messages.
It starts from waiting state.
door
Exit
door closed
open
Disabled
do/ display
‘Waiting’
Half power The oven power is set to 300 watts. The display shows ‘Half power’.
Full power The oven power is set to 600 watts. The display shows ‘Full power’.
Set time The cooking time is set to the user’s input value. The display shows the cooking time
selected and is updated as the time is set.
Disabled Oven operation is disabled for safety. Interior oven light is on. Display shows ‘Not
ready’.
Enabled Oven operation is enabled. Interior oven light is off. Display shows ‘Ready to cook’.
Operation Oven in operation. Interior oven light is on. Display shows the timer countdown. On
completion of cooking, the buzzer is sounded for five seconds. Oven light is on.
Display shows ‘Cooking complete’ while buzzer is sounding.
Disabled Waiting
Identify all the changes between these states as state transitions and show all the
transitions in the state diagram
Identify the event that causes each state transition and the task that will be
performed during the transition, and include them in the state diagram.
attributes
iampaign
a Fg
Mt lifeline
star start
if then
else
if then use Note: dashed arrows
give explanations
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG
30
Creating Sequence Diagram and the Implication
We specify how to implement a use-case, conceptually first, then refine it to specify
final implementation.
To specify how to implement a use-case, we perform tasks on things (objects).
The responsibility for performing a task on a thing (an object) is delegated to the thing
(the object) by sending a message to it to request for a service (to perform the task).
From the sequence diagrams:
◦ Objects identified are specified by classes in a class diagram.
◦ Each message sends to an object implies that an operation is required to be
provided by the class that specifies the object: This is because the receiving
object needs to provide the operation to perform the task requested.
◦ The arguments and return type of a message implies the same for the operation
implied from the message. That is, the message protocol implies the operation
protocol.
◦ Hence, use-case implementation using sequence diagram leads to the discovery of
objects and associated operations.
3tries
time
same
m 4MS z nth
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG
37
Unit 5
Unified Software Development Process (USDP)
‾ USDP is an Object-Oriented (OO) software development
methodology that uses the UML modeling techniques
discussed in the previous units from requirements capture
via design to implementation.
‾ This unit gives a brief introduction of USDP.
Dec 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG 1
USDP - Overview
A software system is developed through carrying out the following processes iteratively
and incrementally:
◦ Requirements Capture
◦ Requirements Analysis
◦ Design
◦ Implementation
◦ Testing
Iteration is for:
◦ building or prototyping a part of the target system
◦ refining or correcting a part of the system or the whole system built in a previous
iteration
Incremental is for:
◦ building a system from small to large
◦ building a system from lower quality or performance to higher quality or performance
i
class class
J
operation
During the testing, the testers verify that the system indeed implements
functionality described in the use cases and satisfies the non-functional
requirements for the use cases (performance, reliability, etc.).
Dec 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG; S2-B1B-51; TEL:67905377 1
How to Ensure Accuracy of Software?
❑For ensuring the accuracy of software, we perform Verification and
Validation (V&V)
a
❑Verification: Checking the consistency of an output in software
development with its input.
❑Validation: Assessing the degree to which a software system actually
fulfills its requirements, in the sense of meeting user’s real needs.
❑Software Testing plays an extremely important role in V&V.
Costs can increase exponentially with time between injection and discovery.
COST
TIME
The next two slides will show that in general exhaustive testing
is not possible.
D
Black-Box Testing: Testing based solely on
analysis of requirements (unit/component
specification, user documentation, etc.). Also
know as functional testing. requirements
pof
D
White-Box Testing: Testing based on analysis
of internal logic (design, code, etc.). But
expected results still come from requirements.
Also known as structural testing.
l
classes such that, according to the specification, every element of a given
class is “handled” (e.g., mapped to output, etc.) “in the same manner.”
If the program is implemented in such a way that being “handled in the same
manner” means that either:
✓every element of the class would be mapped to a correct output, or
✓every element of the class would be mapped to an incorrect output,
testing the program with just one element from each equivalence class would
be tantamount to exhaustive testing.
y
According to the specification, for each class (a block in
the diagram), each value (represented by a dot) in the
class is handled in the same way.
Four equivalence classes for Hours Worked: [0,20]; (20,40]; (-∞, 0); (40, ∞).
fid
Test Cases: pickone
◦ Hours Worked = 10; Message = “Low”
◦ Hours Worked = 40; Message = “High” invalid t
◦ Hours Worked = -10; Message = “Invalid”
◦ Hours Worked = 50; Message = “Invalid”
I
gooseSales Total (MST)
Monthly Monthly Commission (MC)
I
Test Cases:
The first input is a yes/no response to the question “Do you reside within
the city?” The second input is gross pay for the year in question.
A non-resident will pay 1% of the gross pay in city tax.
Residents pay on the following scale: resident
grosspay D tax
- If gross pay is not more than $30,000, the tax is 1%.
- If gross pay is more than $30,000, but not more than
$50,000, the tax is 5%.
- If gross pay is more than $50,000, the tax is 15%.
Cartesian product = the following 2-dimensional tables (as there are two input
variables).
There are twelve equivalence classes each of them is represented by one
box in the following table.
Gross_Pay
<0 [0, 30K] (30K, 50K] > 50K
Invalid 1% 1% 1%
Res? no
ifdropdown Invalid Invalid Invalid Invalid
others
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S2-B1B-51; TEL:67905377
27
Equivalence Class Testing -- Example 3 (Cont’d)
Select any value from each class and design a test case for the
input value: So, we have the following twelve test cases:
1) input: Res = yes, Gross_Pay = -$1,000; Invalid case
2) input: Res = yes, Gross_Pay = $1,000; output: City Tax = $10 1010
3) input: Res = yes, Gross_Pay = $40,000; output: City Tax = $2000 59
4) input: Res = yes, Gross_Pay = $51,000; output: City Tax = $7650 1159
5) input: Res = no, Gross_Pay = -$10; Invalid case
6) input: Res = no, Gross_Pay = $1,000; output: City Tax = $10 I 0lol
7) input: Res = no, Gross_Pay = $50,000; output: City Tax = $500 1 lol
8) input: Res = no, Gross_Pay = $51,000; output: City Tax = $510 11 lol
9) input: Res = ye, Gross_Pay = -$10; Invalid case
x city tax
10) input: Res = ye, Gross_Pay = $1,000; Invalid case
x city tax
11) input: Res = ye, Gross_Pay = $50,000; Invalid case
X City tax
12) input: Res = ye, Gross_Pay = $100,000; Invalid case X city tax
General Rule: Values exactly on the edges and values just miss the edges.
Range Case: For an input range bounded by a and b, test cases should
include values a and b and just below and just above a and b respectively.
Discrete Value Case: If an input condition specifies a set of discrete
numbers, test cases should be designed to exercise the minimum and
maximum numbers and values just below and above these limits.
From the specification, extract the valid input conditions for the input
variable.
For each input condition, identify the boundary values.
Combine the boundary values identified for all the input conditions (remove
the repeated values) to form the boundary values for the input variable.
The resulting boundary values form the boundary values for the whole
program.
definition
oftesting
invalid boundary
key V
❑Input conditions: (1) 0 ≤ MST < 200,000; (2) 200,000 ≤ MST < 1,000,000;
(3) MST ≥ 1,000,000
❑Boundary Values for individual conditions: 0,200000
✓For input condition (1): MST = 0, -100, 200,000
✓For input condition (2): MST = 200,000, 199,900, 1,000,000 200000,1000
✓For input condition (3): MST = 1,000,000, 999,900
❑Required Boundary Values: MST = -100, 0, 200,000, 199,900, 1,000,000,
999,900.
0
2
I
✓ Stock-Name: must be a valid listed company.
✓ Quantity-to-Buy: must be in the multiple of 1000.
✓ Available Fund: Must be sufficient, that is greater than sum of the
total cost and charges involved.
Actions
Buy? No No No No No No No Yes
❑ In previous case, all the three basic conditions are independent, as such, we have
23 rules.
❑ If the basic conditions are interdependent, then the total number of rules will not
equal to the total number of combinations of condition values as the previous case.
❑ In the following case, as some of the conditions are interdependent, as such, we
only have 4 rules, but not 24 rules.
a
included in the table, such that, for each combination of values of
C1,….., Cn, the value of C can always be uniquely determined
(computed).
Second, we check the next condition, (X 5), we find that based on the
condition (X > 5) in the table:
onionsa
▪ When (X > 5) = true, (X 5) always false
III'D
▪ When (X > 5) = false, (X 5) always true
that is, for each value of (X > 5), the condition considered, (X 5), can
always be uniquely determined. Hence, we do not include (X 5).
Y
Dec 2022 Dr Chan Chee Keong, School of EEE, NTU; email: eckchan@ntu.edu.sg; S2-B1B-51; Tel:67905377 48
Example – Finding Minimal Set of Conditions
Third, we check (Y > 2). For each value of the only condition (X > 5) in the
decision table, clearly, (Y > 2) can be any value (true or false). Hence, we
include (Y > 2) in the decision table.
Fourth, we check the next condition, (Y 2), we find that based on the
condition (Y > 2) in the table:
that is, for each value of (Y > 2), the condition considered, (Y 2), can always
be uniquely determined. Hence, we do not include (Y 2).
Hence, we only include {(X > 5), (Y > 2)} in the decision table
Dec 2022 Dr Chan Chee Keong, School of EEE, NTU; email: eckchan@ntu.edu.sg; S2-B1B-51; Tel:67905377 49
Unit 7
Software Testing II --
Structural Testing and Others
Introduce control flow graph
Introduce three basic structural testing techniques
Introduce basic structural coverage analysis for test suites
Briefly introduce approaches for overall testing
Dec 2022 DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL: ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377 1
convertfromprogram to IFG
mom
Control Flow Graph (CFG)
Control flow graph (CFG) shows the control flow between program
statements during execution.
CFG is a graph that is formed by nodes and edges.
Each node (circle) represents a sequence of statements that is always
executed from the first statement to the last statement sequentially during
program execution. Such sequence is called a basic block.
Each edge shows the flow between basic blocks. É
In a CFG, a node that has more than one outgoing edges is called a
decision node.
We can use a diamond to denote a decision node and circle to denote non-
decision node. But, variation is allowed.
C
itdecision
then
machinecode
optional
Mitre
LOOP
y
bygone
It
◦ Statement Coverage
◦ Branch Coverage
bestone
◦ Basis Path Coverage
Note that as each node represents a basic block – a sequence of statements that is
always executed from the first statement to the last statement sequentially -- each
node is executed at least once implies that each statement is executed at least once.
This technique designs a test suite to execute each node in the CFG of a program at
least once as follows:
◦ Choose a set of paths through the CFG that pass through all the nodes.
◦ By defining appropriate input values, design test cases to execute all the above
paths: In order to execute a path, input values are defined to satisfy the conditions
of all the branches that the path follows.
xp tests
since y99
misstating
output
exit
A test suite for statement coverage testing of the above program (the design is explained in
the next slide):
This is not a minimal test suite to achieve statement coverage. Try to construct a minimal test
suite. DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
11
Detailed Explanation of the Previous Example entry
1) A set of paths that pass through all the nodes:
{(1, 2, 3, 4, 6, 2, 7), (1, 2, 3, 5, 6, 2, 7)}
2 paths
2) A test suite for Statement Coverage Testing:
• Test Case 1 (to execute path (1, 2, 3, 4, 6, 2, 7)):
Inputs: i = 99, y = -1; Expected Results: a=2, b=2
• Test Case 2 (to execute path (1, 2, 3, 5, 6, 2, 7)):
Inputs: i = 99, y = 1; Expected Results: a=3, b=3
3) Instead of designing the above test suite, we can also design the following test suite for
Statement Coverage Testing:
a) Choose a set of paths with only one element: {(1, 2, 3, 4, 6, 2, 3, 5, 6, 2, 7)}
b) So, we design a test suite that has only the following test case to execute the only
path in the set:
Test case 1 (to execute path (1, 2, 3, 4, 6, 2, 3, 5, 6, 2, 7)): Inputs : i= 98, y = -1;
Expected results: a = 3, b =3
c) The latter test suite is a minimal test suite for Statement Coverage Testing.
Branch coverage testing is to exercise each branch in the CFG of a program at least
once.
By defining input values, it designs a test suite to execute each branch in the CFG of a
program at least once:
◦ Choose a set of paths through the CFG that pass through all branches.
◦ By defining appropriate input values, design test cases to execute all the above
paths: In order to execute a path, input values are defined to satisfy the conditions of
all the branches that the path follows.
A test suite for branch coverage testing of the above program (the design is explained in the next
slide):
▪ Test Case 1: Inputs: i = 99; y = -1; Expected Results: a=2, b=2 (this forces through the
branch from node 3 to node 4 and both branches from node 2)
▪ Test Case 2: Inputs: i = 99; y = 1; Expected Results: a=3, b=3 (this forces through the
branch from node 3 to node 5 and both branches from node 2)
This is also not a minimal test suite to achieve branch coverage. Try to construct a minimal test
suite.
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
14
Detailed Explanation of the Previous Example
1) The branches in the CFG are: (2, 3), (2, 7), (3, 4), (3, 5)
2) A set of paths that pass through all the branches:
{(1, 2, 3, 4, 6, 2, 7), (1, 2, 3, 5, 6, 2, 7)}
4) Instead of designing the above test suite, we can also design the following test
suite for Branch Coverage Testing:
a) Choose a set of paths with only one element: {(1, 2, 3, 4, 6, 2, 3, 5, 6, 2, 7)}
b) So we design a test suite that has only the following test case to execute the
only path in the set:
Test case 1 (to execute path (1, 2, 3, 4, 6, 2, 3, 5, 6, 2, 7)):
Inputs i = 98, y = -1; Expected results: a = 3, b =3
c) Dec 2022
The latter test suite is a minimal
DR CHAN CHEE KEONG, test
SCHOOLsuite forEMAIL:
OF EEE, NTU; Branch Coverage Testing.
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
15
Relationship between Branch and Statement Coverage
Branch Coverage always implies Statement Coverage : This is because every
statement falls under one branch.
However, Statement Coverage does not imply Branch Coverage. The following
example illustrates this fact:
1
(1) read (x) n 3 F
T
if (x > 0) then
(2) x := x + 1
endif 2
▪ The following test suite of one test case provides statement coverage but not
branch coverage for the above program:
statement all
Test case 1: input: <x = 3>; expected output: <x = 4> covered
tested
butbranch i snot
The false-branch is not exercised ! (the details are explained in the next slide)
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
16
Detailed Explanation of the Previous Example 1
F
T
1) Statement Coverage Testing:
a) A set of paths that pass through all the nodes: {(1, 2, 3)}
2
b) A test suite for Statement Coverage Testing:
Test case 1 (to execute path (1, 2, 3)):
Inputs: x = 3; Expected Results: x = 4 3
2) The above test suite does not execute the branch (1,3 ). Thus, it does not
provide branch coverage, and hence, it cannot be a test suite for branch
coverage testing.
3) For Branch Coverage Testing, we must design as follows:
need a tests
a) There are two branches: (1, 2), (1, 3).
b) A set of paths that pass through all the branches: {(1, 2, 3), (1, 3)}
c) A test suite for Branch Coverage Testing:
• Test Case 1 (to execute path (1, 2, 3)):
Inputs: x = 3; Expected Results: x = 4
• Test Case 2 (to execute path (1, 3)):
Inputs: x = 0; Expected Results: x = 0
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
17
Basis Path Testing
✓ Basis set of linearly independent paths is not unique. Thus, there could be
multiple basis sets of linearly independent paths.
modules
V(G)
Informal Method:
pick a
◼ Firstly, include the shortest path
through the CFG in the set.
◼ Then, each time include a path
through the CFG in the set, based
on the previous path by making a
minimal change to the branches
followed, until all the reachable
nodes and edges have been
included.
CC = 3 and a basis set of linearly independent paths is: {(1, 2, 7), (1, 2, 3, 4, 6, 2,
7), (1, 2, 3, 5, 6, 2, 7)}
Fortestpath
Test cases:
Path (1, 2, 7): Inputs: i =101 y=1; Expected Results: a=1, b=1
Path (1, 2, 3, 4, 6, 2, 7): Inputs: i = 99; y = -1; Expected Results: a=2, b=2
Path (1, 2, 3, 5, 6, 2, 7): Inputs: i = 99; y = 1; Expected Results: a=3, b=3
DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
24
More on Execution Paths through CFGs
A path through a CFG is an alternative logic path to execute the program
represented by the CFG.
When a CFG has a loop, in total, there is an infinite number of paths through
the CFG. For example, in the following CFG, (1, 2, 7), (1, 2, 3, 5, 6, 2, 7), (1, 2,
3, 5, 6, 2, 3, 5, 6, 2, 7), (1, 2, 3, 5, 6, 2, 3, 5, 6, 2, 3, 5, 6, 2 , 7), ….…. , etc., are
all the paths through this CFG (in total, there is an infinite number of paths.
However, the following CFG has only 3 paths in a basis set of linearly
independent paths (discussed earlier).
It is easy to understand that if a test suite does not execute some codes, then
these codes are not tested at all. Therefore, coverage analysis is a good
measurement for measuring a test suite.
▪ A Test Suite has only one test case to test the above program:
Inputs: i = 99; y = -1; Expected Results: a=2, b=2
▪ Statement Coverage = (12/14)*100% = 85.7%
(else, endif and endwhile are not statements, they are part of if and while statements)
▪ Branch Coverage = 75% (cover 3 out of 4 branches, the branch from node 3 to node 5
is not exercised )
▪ Basis path coverage = 33.33% (cover only 1 path out of 3 paths in a basis set of
linearly independent paths) DR CHAN CHEE KEONG, SCHOOL OF EEE, NTU; EMAIL:
Dec 2022
ECKCHAN@NTU.EDU.SG; S1-B1B-51; TEL:67905377
29
Findthe smallestunit
requires
drivers
a bottom daffy
Levels or Phases of Testing
Unit: testing of the smallest programmer work assignments that can reasonably be
planned and tracked (e.g., function, procedure, module, class, etc.)
Test Planning
Test Design
Test Implementation
Test Execution
Execution Analysis
Result Documentation
Final Reporting