Software Summary 500 Pages
Software Summary 500 Pages
1
IEEE Definition
• “Software engineering is the application of a systematic, disciplined,
quantifiable approach to the development, operation, and
maintenance of software; that is, the application of engineering to
software.”
3
Software Crisis (cont.)
Laptop or Desktop =
Rs.45,000/-
Rational suite node locked =
Hw cost Rs.3,14,600/-
Sw cost
Rational suite floating license=
Rs.6,03,200/-
49% Delayed or
cost overrun
23% Cancelled
Craft
Systematic Use of Past
Experience and Scientific
Basis
Unorganized Use of
Past Experience
Art Time
9
What is Exploratory Software Development?
• Early programmers used exploratory (also called build and fix) style.
• A `dirty' program is quickly developed.
• The bugs are fixed as and when they are noticed.
• Similar to how a junior student develops programs…
11
What is Wrong with the Exploratory Style?
Software
Exploratory Engineering
time, cost
Machine
Effort,
Program Size 13
What is Wrong with the Exploratory Style? Cont…
Effort, time,
Machine
cost
completely breaks down
Program Size
when the size of software
becomes large? 15
Human Cognition Mechanism
• Suppose I ask: “It is 10:10AM now,
how many hours are remaining today?"
• 10AM would be stored in the short-term memory.
• “A day is 24 hours long.” would be fetched from the
long term memory into short term memory.
17
• An item stored in the short Short Term
term memory can get lost: Memory
• Either due to decay with time or
• Displacement by newer information.
• This restricts the time for which an item is
stored in short term memory:
• Typically few tens of seconds.
• However, an item can be retained longer in the
short term memory by recycling.
19
Chunking
• If I ask you to remember the number
110010101001
• It may prove very hard for you to understand
and remember.
• But, the octal form of 6251 (110)(010)(101)(001)
would be easier.
• You have managed to create chunks of three
items each. 21
• If a person deals with seven or less number of
items: The Magical Number 7
• These would be accommodated in the short term memory.
• So, he can easily understand it.
23
Implication in Program Development
• Instead of a human, if a machine could be writing
(generating) a program,
• The slope of the curve would be linear.
• But, how does use of software engineering principles
helps hold down the effort-size curve to be almost
linear?
• Software engineering principles extensively use
techniques specifically targeted to overcome the
25
27
Abstraction Example
• Suppose you are asked to develop an
overall understanding of some country.
• Would you:
• Meet all the citizens of the country, visit every
house, and examine every tree of the country?
• You would possibly refer to various types of
maps for that country only. 29
Does every Problem have a single Abstraction?
• Several abstractions of the
same problem can be created:
• Focus on some specific
aspect and ignore the rest.
• Different types of models
help understand different
aspects of the problem.
31
Abstraction of Complex Problems -- An Example
• Suppose you are asked to understand all life forms
that inhabit the earth.
2
Factors responsible for accelerated growth of
services…
• Now lots of code is available in a company:
– New software can be developed by modifying the
closest.
4
Scenario of Indian Software Companies
6
Traditional versus Modern Projects
• Projects are increasingly becoming services:
– Either tailor some existing software or reuse pre-built
libraries.
• Facilitate and accommodate client feedbacks
• Facilitate customer participation in project
development work
• Incremental software delivery with evolving
functionalities.
• No software is being developed from scratch ---
Significant reuse is being made…
8
Computer Systems Engineering
• The high-level problem:
–Deciding which tasks are to be solved by
software.
–Which ones by hardware.
10
Computer Systems Engineering (CONT.)
Feasibility
Study
Requirements
Analysis and
Specification Hardware
Development
Hardware
Software
Partitioning Software
Development
Integration
and Testing
Project Management
12
Emergence of Software Engineering Techniques
Why reduces?
16
Control Flow-Based Design (late 60s)
• Size and complexity of programs increased
further:
–Exploratory programming style proved to be
insufficient.
• Programmers found:
–Very difficult to write cost-effective and
correct programs.
18
Control Flow-Based Design (late 60s)
• What is a program's control
structure?
– Sequence in which a program's
instructions are executed.
22
Control Flow-Based Design (Late 60s)
• What causes program complexity?
–GO TO statements makes control
structure of a program messy.
–GO TO statements alter
the flow of control arbitrarily.
–The need to restrict use of GO TO statements
was recognized.
24
Control-flow Based Design (Late 60s)
• At that time, Dijkstra published his
article:
–“Goto Statement Considered Harmful”
Comm. of ACM, 1969.
• Many programmers were unhappy to
read his article.
26
Control Flow-Based Design (Late 60s)
• It soon was conclusively proved:
–Only three programming constructs are
sufficient to express any programming logic:
•sequence (a=0;b=5;)
•selection (if(c==true) k=5 else m=5;)
•iteration (while(k>0) k=j-k;)
28
Structured Programming
• A program is called structured:
–When it uses only the following types of
constructs:
•sequence,
•selection,
•iteration
–Consists of modules.
30
Advantages of Structured programming
32
Data Structure-Oriented Design (Early 70s)
34
Data Structure Oriented Design (Early 70s)
• An example of data structure-oriented
design technique:
36
A Data Structure Oriented Design (Early
70s)
JSP methodology:
40
Data Flow-Oriented Design (Late 70s)
• Data flow technique is a generic
technique:
–Can be used to model the working of any
system.
• not just software systems.
Design
Maintain
Deliver Code
Test
2
Life Cycle Model (CONT.)
10
Life Cycle Model: Milestones
12
Project Management Without Life Cycle Model
–V model,
–Evolutionary, Traditional models
–Prototyping
–Spiral model,
–Agile models
16
Classical Waterfall Model
• Classical waterfall model divides life
cycle into following phases:
–Feasibility study, Conceptualize
Retire Specify
–Requirements analysis and
Design
specification, Maintain
Relative Effort
• Among all life cycle phases
–Maintenance phase consumes
maximum effort.
• Among development phases,
–Testing phase consumes the
maximum effort.
Classical Waterfall Model (CONT.)
• The guidelines and methodologies of an
organization:
–Called the organization's software
development methodology.
28
The business case
• Benefits of delivered
project must outweigh
Benefits
costs
Costs • Costs include:
- Development
Rs - Operation
Rs • Benefits:
– Quantifiable
– Non-quantifiable
30
1. Executive summary
2. Project background:
The focus must be on what, exactly, the project is undertaking, and should
not be confused with what might be a bigger picture.
3. Business opportunity
- What difference will it make? Writing an Effective
- What if we don’t do it?
Business Case
4. Costs
- Should include the cost of development, implementation, training, change
management, and operations.
5. Benefits
Benefits usually presented in terms of revenue generation and cost
reductions.
6. Risks
− Identify risks.
− Explain how these will be managed.
32
Requirements Analysis and Specification
• Aim of this phase:
–Understand the exact requirements of
the customer,
–Document them properly.
• Consists of two distinct activities:
–Requirements gathering and analysis
–Requirements specification.
34
Requirements Gathering
• Gathering relevant data:
–Usually collected from the end-users
through interviews and discussions.
–Example: for a business accounting
software:
• Interview all the accountants of the
organization to find out their requirements.
36
Requirements Analysis (Cont...)
• Ambiguities and contradictions:
–must be identified
–resolved by discussions with the
customers.
modules, Handle-
order
Handle-indent Handle-
query
–represent invocation
relationships among modules.
Accept-
• Detailed design: Get-
order
order Process-
order
–Better maintainability.
44
Life Cycle Models
Continued….
1
Coding and Unit Testing
• During this phase:
–Each module of the design is coded,
–Each module is unit tested
•That is, tested independently as a stand
alone unit, and debugged.
M3 M4 M6 M8
• During each integration step,
–the partially integrated system is tested.
5
Feasibility Study
Classical Waterfall
Req. Analysis Model
Design
Coding
Testing
Maintenance
7
Types of Maintenance?
• Corrective maintenance:
–Correct errors which were not discovered during
the product development phases.
• Perfective maintenance:
–Improve implementation of the system
–enhance functionalities of the system.
• Adaptive maintenance:
–Port software to a new environment,
9
• e.g. to a new computer or to a new operating system.
Iterative Waterfall Model (CONT.)
11
Iterative Waterfall Model (CONT.)
Feasibility Study
Req. Analysis
Design
Coding
Testing
Maintenance
13
Phase Containment of Errors
• Reason: rework must be carried out not only to the
design but also to code and test phases.
• The principle of detecting errors as close to its
point of introduction as possible:
–is known as phase containment of
errors.
• Iterative waterfall model is by far the most widely
used model.
–Almost every other model is derived from the
waterfall model. 15
Waterfall Strengths
• Easy to understand, easy to use, especially
by inexperienced staff
• Milestones are well understood by the
team
• Provides requirements stability during
development
• Facilitates strong management control
(plan, staff, track) 17
When to use the Waterfall Model?
• Technology is understood
21
What are Requirements?
• A Requirement is:
Feasibility
Study Requirements
gathering
Requirements
analysis
Feasibility Requirements
report specification
SRS Document
• Good SRS reduces development cost:
– Req. errors are expensive to fix later Need for SRS…
– Req. changes cost a lot (typically 40% of requirements
change later)
– Good SRS can minimize changes and errors
– Substantial savings --- effort spent during req. saves
multiple times that effort
Cost
• An Example:
– Cost of fixing errors in req. , design , coding , acceptance
testing and operation increases exponentially
Forms A Basis for User Manual
• The SRS serves as the basis for writing User
Manual for the software:
Gathering
• Specification
Analysis
and review may
Specification
lead to further
gathering and
Review
analysis.
SRS Document
Requirements Gathering Activities
• 1. Study existing documentation
• 2. Interview
• 3. Task analysis
• 4. Scenario analysis
• 5. Form analysis
Requirements Gathering (CONT.)
– Experience…
Case Study: Automation of Office Work at CSE Dept.
Analysis
– Systematically organize the
Specification
requirements analysis.
SRS
Document
• If necessary:
– Later a formal requirement specification
may be developed from it.
Properties of a Good SRS Document
(cont...)
• It should be traceable
– You should be able to trace which part of the
specification corresponds to which part of the
design, code, etc and vice versa.
• It should be verifiable
– e.g. “system should be user friendly” is not
verifiable
SRS Document (CONT.)
– External Interfaces
– Non-functional requirements,
– Constraints
Functional Requirement
Documentation
• Overview
– describe purpose of the function and the
approaches and techniques employed
• Inputs and Outputs
– sources of inputs and destination of outputs
– quantities, units of measure, ranges of valid
inputs and outputs
– timing
Nonfunctional Requirements
• Characteristics of the system which can not be
expressed as functions:
• Maintainability,
• Portability,
• Usability,
• Security,
• Safety, etc.
Constraints
• Hardware to be used,
• Operating system
– or DBMS to be used
• 2. Overall Description
– 2.1 Product Perspective •Summarize the major functional capabilities
– 2.4 Constraints
– 2.5 Assumptions and Dependencies
•Describe other constraints that will limit
developer’s options; e.g., regulatory policies;
• 3. Specific Requirements target platform, database, network,
development standards requirements
• 4. Appendices
• 5. Index
IEEE 830-1998 Standard – Templates
16
Functional Requirements
• It is desirable to consider every system as:
– Performing a set of functions {fi}.
• Each function fi considered as:
– Transforming a set of input data to
corresponding output data.
Input Output
Data fi Data
Functional Requirements
• Functional requirements describe:
– A set of high-level requirements
– Each high-level requirement:
• takes in some data from the user
• outputs some data to the user
– Each high-level requirement:
• might consist of a set of identifiable sub-functions
Is it a Functional Requirement?
• A high-level function is one:
– Using which the user can get some useful
piece of work done.
• Can the receipt printing work during withdrawal
of money from an ATM:
– Be called a functional requirement?
• A high-level requirement typically involves:
– Accepting some data from the user,
– Transforming it to the required response, and
then
– Outputting the system response to the user.
Example Functional
• Req. 1: Requirements
– Once user selects the “search” option,
• he is asked to enter the key words.
– The system should output details of all books
• whose title or author name matches any of the key
words entered.
• Details include: Title, Author Name, Publisher name,
Year of Publication, ISBN Number, Catalog Number,
Location in the Library.
High-Level Function: A Closer View
• A high-level function:
– Usually involves a series of interactions between
the system and one or more users.
• Even for the same high-level function,
– There can be different interaction sequences (or
scenarios)
– Due to users selecting different options or
entering different data items.
Examples of Bad SRS
Documents
• Noise:
– Presence of text containing information
irrelevant to the problem.
• Silence:
– Aspects important to proper solution of the
problem are omitted.
Examples of Bad SRS Documents
• Ambiguity:
– Literary expressions
– Unquantifiable aspects, e.g. “good user interface”
• Forward References:
– References to aspects of problem
• defined only later on in the text.
• Wishful Thinking:
– Descriptions of aspects
• for which realistic solutions will be hard to find.
Suggestions for Writing Good Quality
Requirements
9/28/2024
1
Production,
Project Planning Operation &
Maintenance
Integration
High Level Design Testing
Coding
3
V Model: Strengths
• Starting from early stages of
software development:
– Emphasizes planning for verification
and validation of the software
• Easy to use
5
When to use V Model
• Natural choice for systems requiring high
reliability:
– Embedded control applications, safety-
critical software
7
Prototyping Model
• A derivative of waterfall model.
• Before starting actual development,
– A working prototype of Prototype Construction
the system should first be built. Design
Testing
implementation of a system: Maintenance
13
Prototyping Model (CONT.)
• The developed prototype is submitted to the
customer for his evaluation:
Build Prototype
Requirements
Customer
Evaluation of
Customer
Gathering Quick Design Prototype Design
satisfied
–Based on the user feedback,
Refine
Requirements Implement
• Susceptible to over-engineering:
19
Major difficulties of Waterfall-Based Life Cycle
Models
21
• “The basic idea… take advantage of what was
being learned during the development of earlier,
incremental, deliverable versions of the system.
Learning comes from both the development and
use of the system… Start with a simple
implementation of a subset of the software
requirements and iteratively enhance the
evolving sequence of versions. At each version
design modifications are made along with adding
new functional capabilities. “ Victor Basili
2
Customer’s Perspective
C
A AB A
B B
4
Incremental Model: Requirements
Split into
Features
Slice
Slice
Slice
Slice
Slice
Slice
Slice
Slice
Slice
Slice
Slice
Slice
6
Incremental delivery
increment design
1 build
install
Customer
Feedback
design
increment
build
2
install
Customer
Feedback
design
increment build
3
install
Customer
Feedback
8
Which step first?
• Some steps will be pre-requisite because
of physical dependencies
• Others may be in any order
• Value to cost ratios may be used
– V/C where
– V is a score 1-10 representing value to
customer
– C is a score 0-10 representing cost to
developers 10
Evolutionary Model
with Iterations
12
Evolutionary Model with Iteration
14
Evolutionary Model
• First develop the core modules of the
software.
• The initial skeletal software is refined
into increasing levels of capability:
(Iterations)
–By adding new functionalities in successive
versions.
16
Evolutionary Model with Iteration
• Outcome of each iteration: tested, integrated,
executable system
• Iteration length is short and fixed
– Usually between 2 and 6 weeks
Initial
Specification version
Initial Rough
Intermediate
Requirements
Development versions
Final
Validation version
20
Advantages of evolutionary model
22
Evolutionary Model: Problems
• The process is intangible:
–No regular, well-defined deliverables.
• The process is unpredictable:
–Hard to manage, e.g., scheduling, workforce
allocation, etc.
• Systems are rather poorly structured:
–Continual, unpredictable changes tend to
degrade the software structure.
• Systems may not even converge to a final version.
24
Rapid Application Development (RAD) Model
• Sometimes referred to as the rapid
prototyping model.
• Major aims:
– Decrease the time taken and the cost incurred
to develop software systems.
– Facilitate accommodating change requests as
early as possible:
• Before large investments have been made in development
and testing. 26
Methodology
•Plans are made for one increment at a time.
• The time planned for each iteration is called
a time box.
28
How Does RAD Facilitate Faster Development?
• RAD achieves fast creation of working
prototypes.
– Through use of specialized tools.
32
Prototyping versus RAD
• In contrast:
• In RAD the developed prototype evolves
into deliverable software.
34
RAD versus Iterative Waterfall Model
• The iterative waterfall model:
– Does not facilitate accommodating requirement
change requests.
• Iterative waterfall model does have some
important advantages:
– Use of the iterative waterfall model leads to
production of good documentation.
– Also, the developed software usually has better
quality and reliability than that developed using
RAD. 36
Agile Models
9/28/2024
2
Agile Model
• To overcome the shortcomings of the waterfall
model of development.
– Proposed in mid-1990s
• The agile model was primarily designed:
– To help projects to adapt to change requests
• In the agile model:
– The requirements are decomposed into many small
incremental parts that can be developed over one to
four weeks each.
4
Agile Methodologies
• XP
• Scrum
• Unified process
• Crystal
• DSDM
• Lean
6
• At a time, only one increment is planned,
developed, deployed at the customer site.
– No long-term plans are made.
10
• Travel light: Agile Documentation
– You need far less documentation than you think.
• Agile documents:
– Are concise
– Describe information that is less likely to change
– Describe “good things to know”
– Are sufficiently accurate, consistent, and detailed
• Valid reasons to document:
– Project stakeholders require it
– To define a contract model
– To support communication with an external group
– To think something through
12
Adoption Detractors
• Sketchy definitions, make it possible to
have
– Inconsistent and diverse definitions
• High quality people skills required
• Short iterations inhibit long-term
perspective
• Higher risks due to feature creep:
– Harder to manage feature creep and customer
expectations 14
• Steps of Agile Model versus Waterfall Model
Waterfall model are a planned sequence:
– Requirements-capture, analysis, design, coding,
and testing .
• Progress is measured in terms of delivered
artefacts:
– Requirement specifications, design documents,
test plans, code reviews, etc.
• In contrast agile model sequences:
– Delivery of working versions of a product in
several increments. 16
Agile versus RAD Model
• Agile model does not recommend
developing prototypes:
– Systematic development of each
incremental feature is emphasized.
• In contrast:
– RAD is based on designing quick-and-dirty
prototypes, which are then refined into
production quality code.
18
Extreme Programming
(XP)
20
Taking Good Practices to Extreme
• If code review is good:
– Always review --- pair programming
• If testing is good:
– Continually write and execute test cases ---
test-driven development
• If incremental development is good:
– Come up with new increments every few days
• If simplicity is good:
– Create the simplest design that will support
only the currently required functionality.
22
• Communication: 4 Values
– Enhance communication among team members
and with the customers.
• Simplicity:
– Build something simple that will work today
rather than something that takes time and yet
never used
– May not pay attention for tomorrow
• Feedback:
– System staying out of users is trouble waiting to
happen
• Courage:
– Don’t hesitate to discard code 24
Best Practices
• Designing:
– Without proper design, a system
implementation becomes too complex
– The dependencies within the system become
too numerous to comprehend.
• Feedback:
– Feedback is important in learning customer
requirements.
26
Extreme Programming Activities
• XP Coding
• Recommends the construction of unit test cases before
coding commences (test-driven development)
• Encourages “pair programming”
• XP Testing
• All unit tests are executed daily
• “Acceptance tests” are defined by the customer and
executed to assess customer visible functionalities
28
Full List of XP Practices
7. Refactoring – programmers continuously
restructure the system without changing its
behavior to remove duplication and simplify
8. Pair-programming -- all production code is
written with two programmers at one machine
9. Collective ownership – anyone can change any
code anywhere in the system at any time.
10. Continuous integration – integrate and build the
system many times a day – every time a task is
completed. 30
Emphasizes Test-Driven Development (TDD)
• Based on user story develop test cases
• Implement a quick and dirty feature every
couple of days:
– Get customer feedback
– Alter if necessary
– Refactor
6
Developments to UML
• UML continues to UML 2.0 2003
develop, due to: Application
to embedded
– Refinements systems
UML 1.X
– Making it applicable to
new contexts
UML 1.0 1997
8
UML Diagrams
• Nine diagrams in UML1.x :
• Used to capture 5 different views of a system.
• Views:
• Provide different perspectives of a software
system.
• Diagrams can be refined to get the actual implementation
of a system.
10
Diagrams
Behavioural View
Structural View - Sequence Diagram
and views
- Class Diagram
- Object Diagram
- Collaboration Diagram
- State-chart Diagram
in UML
- Activity Diagram
User’s View
-Use Case
Diagram
12
• Use Case Diagram
– high-level behaviors of the system, user goals, external entities:
actors
• Activity Diagram
– flow of control between activities 14
Are All Views Required for
• NO Developing A Typical System?
• For a simple system:
• Use case diagram, class diagram and one of the interaction
diagrams only.
• State chart diagram:
• when class has significant states.
• When states are only one or two, state chart model becomes
trivial
• Deployment diagram:
• In case several hardware components used to develop the
system.
16
Use Case Model Behavioural View
Structural View - Sequence Diagram
- Class Diagram
• Consists of a set of “use cases” - Object Diagram
- Collaboration Diagram
User’s View
-State-chart Diagram
- Activity Diagram
-Use Case
Diagram
18
–Use cases for a Library information system
•issue-book
•query-book
•return-book Example
Use Cases
•create-member
•add-book, etc.
20
An Example Use Case Diagram
Play Move
Tic-tac-toe game
Player
22
• Represented in a use case diagram Representation of
• A use case is represented by an ellipse Use Cases
Play Move
actor and use case by a line <<external
system>>
Tic-tac-toe game
Player
• External system by adding a stereotype
24
Relationships between Use Cases and Actors
• Association relation indicates that the actor and the
corresponding use case communicate with one another.
update
grades
faculty
26
Yet Another Use
Telephone Order System
Case Example
Check
Status Salesperson
Place
Order
Fill
Shipping
Orders
Customer Clerk
Establish
credit
Supervisor
28
Generalization
• The child use case inherits the
parent
behavior of the parent use case.
–The child may add to or override some
child
of the behavior of its parent.
30
Factoring Use Cases Using Generalization
32
<<include>> Common
Base use case
use case
Factoring Use
Cases Using
Include
Base use case 2 Base use case 1
<<include>>
<<include>>
<<include>>
<<include>>
34
Extend
• Use when a use-case optionally can do a little bit more:
– Capture the normal behavior
36
Extension Point
• The base use case may include/extend other use cases:
– At certain points, called extension points.
<<extend>>
Perform Sale Product is a gift
Gift wrap
After checkout Product
38
• Video Store Information System supports the following
business functions: Example 1: Video Store Information System
– Recording information about videos the store owns
• This database is searchable by staff and all customers
– Information about a customer’s borrowed videos
• Access by staff and customer. It involves video database searching.
– Staff can record video rentals and returns by customers. It involves
video database searching.
– Staff can maintain customer and video information.
– Managers of the store can generate various reports.
40
Name
Actors Use Case
Trigger Description
Preconditions
Post conditions
Mainline Scenario
Alistair Cockburn
“Writing
Effective Use
Cases”
Alternatives flows
42
ATM Money Withdraw Example
• Actors: Customer
• Pre Condition:
– ATM must be in a state ready to accept transactions
– ATM must have at least some cash it can dispense
– ATM must have enough paper to print a receipt
• Post Condition:
– The current amount of cash in the user account is the amount before withdraw
minus withdraw amount
– A receipt was printed on the withdraw amount
44
ATM Money Withdraw (cont.)
• Alternative flow of events:
– Step 3: Customer authorization failed. Display an error message, cancel the
transaction and eject the card.
– Step 8: Customer has insufficient funds in its account. Display an error
message, and go to step 6.
– Step 8: Customer exceeds its legal amount. Display an error message, and go to
step 6.
• Exceptional flow of events:
– Power failure in the process of the transaction before step 9, cancel the
transaction and eject the card.
46
Example 2: Use Case Model for Course Management Software
• At the beginning of each semester,
– Each professor shall register the courses that he is going to teach.
• A student can select up to four-course offerings.
– During registration a student can request a course catalogue showing course offerings for the
semester.
– Information about each course such as professor, department and prerequisites would be
displayed.
– The registration system sends information to the billing system, so that the students can be
billed for the semester.
• For each semester, there is a period of time during which dropping of courses is
permitted.
• Professors must be able to access the system to see which students signed up for each
of their course offerings.
48
• Use case name should begin with a verb. Style Notes
• While use cases do not explicitly imply timing:
(Ambler, 2005)
– Order use cases from top to bottom to imply timing -- it improves readability.
• The primary actors should appear in the left.
• Actors are associated with one or more use cases.
• Do not use arrows on the actor-use case relationship.
• To initiate scheduled events include an actor called “time”, or
“calendar”
• Do not show actors interacting with each other.
• <<include>> should rarely nest more than 2 levels deep.
50
Use Case Packaging
Accounts
Print
Query balance
Balance sheet
Receive Make
grant payments
52
UML Class Representation
• A class represents a set of objects having similar attributes,
operations, relationships and behavior.
Class Name
Window
A class can
size: Size implicitly
Attributes have a few
visibility: boolean association
attributes
display()
Operations hide()
54
What are the Different Types of Relationships
Among Classes?
• Four types of relationships:
– Inheritance
– Association
– Aggregation/Composition
– Dependency
56
Inheritance Example
Animal “A Dog ISA Animal”
“A Cat ISA Animal”
Dog Cat
58
Multiple LibraryMember Base Class LibraryMember Base Class
Inheritance
Derived
Faculty Students Staff Faculty Students Staff
Classes
Multiple
Inheritance
60
Objects myRectangle and myBox Rectangle
issuable reference
Issuable Reference
Issuable Reference
Single Volume Single Volume
BookSet BookSet
Book Book
64
Association Relationship
• How implemented in program?
• Enables objects to communicate with each other:
–One object must “know” the ID of the corresponding
object in the association.
• Usually binary:
–But in general can be n-ary.
66
1-1 Association tax_file
– example
Rakesh Shukla 760901-1234
V. Ramesh
691205-5678
Keshab Parhi
People Tax_files
1 1
People Associated Tax_files
with
68
Association UML Syntax
role B
Class A role A Class B
Association Name
70
Navigability
opens 0..5
Key * Door
72
Quiz: Draw Class Diagram
• A Student can take up to five Courses.
74
Student credits hasEnrolmentOf Course
Identify as 20..300 Enrols in 1..5
Correct or
Wrong Student credits hasEnrolmentOf Course
20..300 Enrols in 1..5
76
Association and Link
• A link:
– An instance of an association
– Exists between two or more objects
– Dynamically created and destroyed as the run of a
system proceeds
• For example:
– An employee joins an organization.
– Leaves that organization and joins a new organization.
78
Self Association: Example of
Computer Network
Connects to
Computer *
80
Association Exercise 1
• A Person works for a Company.
Role Implicit attribute of type Company
Association Name
82
Aggregation Relationship
• Represents whole-part relationship
• Represented by a diamond symbol at the composite end.
• Usually creates the components:
–Also, aggregate usually invokes the same operations of all its
components.
–This is in contras to plain association
• Usually owner of the components:
–But can share with other classes
84
Aggregation cont…
86
Composition
• A stronger form of aggregation
– The whole is the sole owner of its part.
• A component can belong to only one whole
– The life time of the part is dependent upon the whole.
• The composite must manage the creation and destruction of its
parts. 1
Circle Point Circle
3..* Point
Polygon
88
Composition: Alternate Notation
Car
4 1
Wheel Engine
2 1
Door Chassis
1 1
Axle Steering
90
• Composition: Aggregation vs. Composition
– Composite and components have the same life line.
• Aggregation:
– Lifelines are different.
• Consider an order object:
– Aggregation: If order items can be
changed or deleted after placing order.
– Composition: Otherwise.
92
public class Car{
Implementing
Composition private Wheel wheels[4];
public Car (){
wheels[0] = new Wheel();
wheels[1] = new Wheel();
wheels[2] = new Wheel();
wheels[3] = new Wheel();
}
1 4 Wheel
} Car
94
Class Dependency
96
Association Vs. Aggregation
• Is aggregation an association?
• Is composition an aggregation?
98
UML Class Class
Relation Notation Generalization
Relationship
dependency
Summary
Object Object
Aggregation Composition
Object Association Association Association
1..* 1
n n
0..* 0..*
100
Association and Link
• A link:
– An instance of an association
– Exists between two or more objects
– Dynamically created and destroyed as the run of a
system proceeds
• For example:
– An employee joins an organization.
– Leaves that organization and joins a new organization.
102
Self Association: Example of
Computer Network
Connects to
Computer *
104
Association Exercise 1
• A Person works for a Company.
Role Implicit attribute of type Company
Association Name
106
Aggregation Relationship
• Represents whole-part relationship
• Represented by a diamond symbol at the composite end.
• Usually creates the components:
–Also, aggregate usually invokes the same operations of all its
components.
–This is in contras to plain association
• Usually owner of the components:
–But can share with other classes
108
Aggregation cont…
110
Composition
• A stronger form of aggregation
– The whole is the sole owner of its part.
• A component can belong to only one whole
– The life time of the part is dependent upon the whole.
• The composite must manage the creation and destruction of its
parts. 1
Circle Point Circle
3..* Point
Polygon
112
Composition: Alternate Notation
Car
4 1
Wheel Engine
2 1
Door Chassis
1 1
Axle Steering
114
• Composition: Aggregation vs. Composition
– Composite and components have the same life line.
• Aggregation:
– Lifelines are different.
• Consider an order object:
– Aggregation: If order items can be
changed or deleted after placing order.
– Composition: Otherwise.
116
public class Car{
Implementing
Composition private Wheel wheels[4];
public Car (){
wheels[0] = new Wheel();
wheels[1] = new Wheel();
wheels[2] = new Wheel();
wheels[3] = new Wheel();
}
1 4 Wheel
} Car
118
Dependency
• Dependency relationship can arise due to a variety of reasons:
– Stereotypes are used to show the precise nature of the dependency.
*
– The parts live and die with the whole Page
(team- 1..5 1
teaching is
possible) 0..* 1..*
CourseTeaching SalesOrderLineItem
124
Class Diagram Inference Based on Text Analysis
(based on Dennis, 2002)
• A common noun implies a class e.g. Book
• A proper noun implies an object (instance of a class): CSE Dept, OOSD, etc.
• An adjective implies an attribute e.g. price of book
• A “doing” verb implies an operation
– Can also imply a relationship e.g. student issues Book
• A “having” verb implies an aggregation relationship
• A predicate or descriptive verb phrase elaborates an operation e.g. ISBN
numbers are integers
• An adverb implies an attribute of an operation e.g. fast loading of image…
126
• A square is a polygon
Identify Classes &
• Shyam is a student
Relations
• Every student has a name
• 100 paisa is one rupee
• Students live in hostels
• Every student is a member of the library
• A student can renew his borrowed books
• The Department has many students
128
• Describes static structure of a system
• Main constituents are classes and their
relationships:
Class Diagram: Recap
–Generalization
–Aggregation
–Association
–Various kinds of dependencies
130
Object Diagram
LibraryMember
Mritunjay LibraryMember
LibraryMember
B10028
C-108, Laksmikant Hall Mritunjay
1119 B10028
Mrituj@cse C-108, Laksmikant Hall
25-02-04 1119
25-03-06 Mrituj@cse
NIL 25-02-04
25-03-06
IssueBook( ); NIL
findPendingBooks( );
findOverdueBooks( ); Different representations of
returnBook( ); the LibraryMember object
findMembershipDetails( );
132
A First Look at Sequence Diagrams
• Captures how objects interact with each other:
– To realize some behavior (use case execution).
• Emphasizes time ordering of messages.
• Can model:
– Simple sequential flow, branching, iteration, recursion,
and concurrency.
134
Sequence Diagram
• Shows interaction among objects in a two-dimensional
chart member:
LibraryMember
book:Book
:Book
Copy
136
member: :Book
book:Book
LibraryMember Copy
• iteration marker *[for all objects]
ok = canBorrow()
• [condition] borrow(book)
[ok] borrow(member)
– message is sent only if the condition is true setTaken(member)
• self-delegation
– a message that an object sends to itself
Gist of Syntax
• Loops and conditionals:
– UML2 uses a new notation called interaction frames to support
these
138
Elements of A Sequence Diagram
X-Axis (objects)
member: :Book
book:Book
LibraryMember Copy
Y-Axis (time)
condition
How do you show Mutually exclusive conditional messages?
140
140
:Library
:Library
:Library Book :Library
Book :Book
Boundary Renewal Member
Register
Controller
renewBook
renewBook find MemberBorrowing
displayBorrowing
selectBooks
Sequence
bookSelected
* find Diagram for
[reserved] the renew
[reserved] apology
update book use
apology case
confirm
confirm
updateMemberBorrowing
142
Example: Solution
:client
setItinerary
calculateRoute
<<destroy>>
144144
Method Population in Classes
• Methods of a class are determined from the
interaction diagrams…
:Registration :Registration
form manager
add course
RegistrationManager
(joe, math 01)
addCourse(Student,Course)
146
Object Creation
• An object may create another object via a <<create>>
message.
:A
<<create>>
:B
148
Control Information
Iteration
example
:CompoundShape :Shape
UML 1.x:
draw()
*draw()
150
Quiz: Write Code for class B
a:A
m1
create
:B
flag=doA(this)
create
doB(c) c:C
152
Software Design - I
1
Items Designed During Design Phase
• Module structure,
• Control relationship among the modules
– call relationship or invocation relationship
• Interface among different modules,
– data items exchanged among different modules,
• Data structures of individual modules,
• algorithms for individual modules.
Module Structure
Stages in Design
• Design activities are usually classified into two stages:
– Preliminary (or high-level) design
– Detailed design.
Bad design
may look
like this…
Modularity
• Arrangement of modules in a hierarchy
ensures:
– Low fan-out
– Abstraction
Cohesion and Coupling
• Cohesion is a measure of:
– functional strength of a module.
– A cohesive module performs a single task or function.
• Coupling between two modules:
– A measure of the degree of interdependence or
interaction between the two modules.
Advantages of Functional Independence
• Better understandability
• Complexity of design is reduced,
No dependencies
Print-all-students(); Function C
Communicational
}; Access same data
Functional cohesion
• Different elements of a module cooperate:
– to achieve a single function,
– e.g. managing an employee's pay-roll.
• When a module displays functional cohesion,
– we can describe the function using a single sentence.
Coupling
• Coupling indicates:
– how closely two modules interact or how
interdependent they are.
– The degree of coupling between two modules
depends on their interface complexity.
Classes of coupling
data
stamp
control Degree of
coupling
common
content
Stamp coupling
• Two modules are stamp coupled,
– if they communicate via a composite data item
• or an array or structure in C.
Common Coupling
Fan out=1
Fan in=1
Fan in=2
Fan out=0
Large Fan Out
• A module that invokes a large
number of other modules:
– likely to implement several different functions:
– not likely to perform a single cohesive function.
Visibility and Layering
• A module A is said to be visible by another module B,
– if A directly or indirectly calls B.
• d3 d4
d1
•
•
fn
Design Approaches
• These two design approaches are radically different.
– However, are complementary
• rather than competing techniques.
– Each technique is applicable at
• different stages of the design process.
Example
• The function create-new-library- member:
class alarm
attributes: location, status
operations: create, ring-alarm, get_location, reset-alarm
– Appropriate number of instances of the class detector and alarm are created.
Object-Oriented versus Function-Oriented Design
101
Structured analysis and Structured Design
• During Structured analysis:
– High-level functions are successively decomposed:
•Into more detailed functions.
• During Structured design:
– The detailed functions are mapped to a module
structure. 103
SA/SD (Structured Analysis/Structured Design)
• SA/SD technique draws heavily from the following
methodologies:
– Constantine and Yourdon's methodology
We largely use
– Hatley and Pirbhai's methodology
– Gane and Sarson's methodology
– DeMarco and Yourdon's methodology
• SA/SD technique results in:
– high-level design. 105
Structured Analysis
• Textual problem description converted into a graphic
model.
107
Structured Design
• The functions represented in the DFD:
• Module structure:
109
Structured Analysis: Recap
• Based on principles of:
– Top-down decomposition approach.
– Divide and conquer principle:
• Each function is considered individually (i.e. isolated from other
functions).
• Decompose functions totally disregarding what happens in other
functions.
– Graphical representation of results using
• Data flow diagrams (or bubble charts). 111
DFD Concepts
• It is useful to consider each function as a processing
station: move
113
Pros of Data Flow Diagrams (DFDs)
• A DFD model:
115
A Hierarchical Model
117
External Entity Symbol
• Represented by a rectangle
119
Data Flow Symbol
• A directed arc or line. book-name
121
Data Store Symbol
• Direction of data flow arrow:
find-book
– Shows whether data is being read from
or written into it.
Books
• An arrow into or out of a data store:
– Implicitly represents the entire data of the data store
– Arrows connecting to a data store need not be annotated
with any data name. 123
Synchronous Operation
• If two bubbles are directly connected by a data flow
arrow:
– They are synchronous
Read- number Validate-
numbers numbers
0.1 0.2 Valid
Data- number
items
125
Yourdon's vs. Gane Sarson Notations
127
How is Structured Analysis Performed?
129
Context Diagram
• A context diagram shows:
– External entities.
131
Level 1 DFD Construction
• Examine the SRS document: Display-
game
move board
0.1 result
– Represent each high-level
function as a bubble. Validate-
move
Check-
winner
0.2 board 0.4
135
Decomposition Pitfall
• Too many bubbles at a level, a sign of poor
modelling:
– More than 7 bubbles at any level of a DFD.
137
Example 1: RMS Calculating Software
• Consider a software called RMS calculating software:
– Reads three integers in the range of -1000 and +1000
– Finds out the root mean square (rms) of the three input
numbers
139
Example 1: RMS Calculating Software
Data- Compute-
items
RMS
0
User result
141
Example 1: RMS Calculating Software
143
Example: RMS Calculating Software
145
Importance of Data Dictionary
• Provides the team of developers with standard terminology
for all data:
– A consistent vocabulary for data is very important
147
Data Dictionary
• CASE (Computer Aided Software Engineering)
tools come handy:
– CASE tools capture the data items appearing in a
DFD automatically to generate the data
dictionary.
149
• Composite data are defined in terms of primitive data items using
simple operators:
151
Data Definition
• {name}* represents
– zero or more instances of name data.
• = represents equivalence,
– e.g. a=b+c means that a represents b and c.
153
Structured Analysis and Design
Cont…
155
c
Balancing a DFD
b c
c1
d1
a d
e
Level 1 d
e1
e
Level 2
157
Example 2: Tic-Tac-Toe Computer Game
• A human player and the computer make
alternate moves on a 3 X 3 square.
• A move consists of marking a previously unmarked square.
• The user inputs a number between 1 and 9 to mark a square
• Whoever is first to place three consecutive marks along a
straight line (i.e., along a row, column, or diagonal) on the
square wins.
159
Tic-tac-toe
display software
0
Context
move Diagram for
Human Player Example
161
Data Dictionary
Display=game + result
move = integer
board = {integer}9
game = {integer}9
result=string
163
Example 3: Trading-House Automation System (TAS)
• The trading house maintains names and addresses of its
regular customers.
• Each customer is assigned a unique customer identification
number (CIN).
• As per current practice when a customer places order:
– The accounts department first checks the credit-worthiness of the
customer.
165
Example: Trading-House Automation System (TAS)
• If a customer is credit-worthy:
– Items he/she has ordered are checked against the list of items the
trading house deals with.
• The items that the trading house does not deal with:
– Are not processed any further
– An appropriate message for the customer for these items is
generated.
167
Example: Trading-House Automation System (TAS)
169
Example: Trading-House Automation System (TAS)
• The purchase department:
– would periodically issue commands to generate indents.
• When generate indents command is issued:
– The system should examine the "pending-order" file
– Determine the orders that are pending
– Total quantity required for each of the items.
171
Example: Trading-House Automation System (TAS)
173
Customer-history Item-file
query
Accept inventory
Customer-file -order
0.1 Handle- statistics
query
0.3
order Process
Accepted-
orders -order
Vendor-list
0.2 Level 1
Handle-
indent-
DFD
Indent- Sales-statistics
request request
0.4
Indents Material-issue-
pending-order slip + bill
175
• item-name: string
• house#: string Example: Data
• street#: string Dictionary
• city: string
• pin: integer
• customer-id: integer
• bill: {item + quantity + price}* + total-amount + customer-address
• material-issue-slip: message + item + quantity + customer-address
• message: string
• statistics: {item + quantity + price }*
• sales-statistics: {statistics}*
• quantity: integer
177
Observation
• As a DFD is refined into greater levels of detail:
– The analyst performs an implicit functional
decomposition.
179
Guidelines For Constructing DFDs
• All external entities should be represented in the
context diagram:
– External entities should not appear at any other level DFD.
• Only 3 to 7 bubbles per diagram should be allowed:
– Each bubble should be decomposed to between 3 and 7
bubbles.
181
Guidelines For Constructing DFDs
• A DFD model does not represent control information:
– When or in what order different functions (processes) are invoked
– The conditions under which different functions are invoked are not
represented.
– For example, a function might invoke one function or another depending on
some condition.
– Many beginners try to represent this aspect by drawing an arrow between
the corresponding bubbles.
183
item query
statistics
inventory
Item-file Handle-
query
Process- 0.3
order
0.2
statistics
Handle-
Find 4
indent-
request Sales-statistics Errors
0.4
Material-issue-slip +
pending-order bill
185
Find Error Example-2
• A function accepts the book name to be searched from
the user
• If the entered book name is not a valid book name
– Generates an error message, Search-
Get- Good-book- book
name
• If the book name is valid, book- Book-
name details
Print-
– Searches the book name err-
Error-
in database. Book-name message
message
187
• Unbalanced DFDs
Commonly
• Forgetting to name the data flows Made Errors
• Unrepresented functions or data
• External entities appearing at higher level DFDs
• Trying to represent control aspects
• Context diagram having more than one bubble
• A bubble decomposed into too many bubbles at next level
• Terminating decomposition too early
• Nouns used in naming bubbles 189
Shortcomings of the DFD Model
• For example, a bubble named find-book-position has only
intuitive meaning:
– Does not specify several things:
• What happens when some input information is missing or is
incorrect.
• Does not convey anything regarding what happens when book is
not found
• What happens if there are books by different authors with the
same book title. 191
Shortcomings of the DFD Model
• Decomposition is carried out to arrive at the successive
levels of a DFD is subjective.
• The ultimate level to which decomposition is carried out is
subjective:
– Depends on the judgement of the analyst.
• Even for the same problem,
– Several alternative DFD representations are possible:
– Many times it is not possible to say which DFD representation is
superior or preferable. 193
Structured Analysis and Design
Cont…
195
Structure Chart
• Structure chart representation
root
– Easily implementable using programming languages.
• Main focus of a structure chart: Process-
order
Handle-indent Handle-
query
root
move board
result
– afferent branch,
Validate- Check-
move board winner
– central transform,
– efferent branch. Play-
move
Transform Analysis
• First level of structure chart:
root
– Draw a box for each input and output units
– A box for the central transform. Process- Handle- Handle-
order indent query
• Next, refine the structure chart:
– Add subfunctions required by each high-level module.
– Many levels of modules may required to be added.
Example 1: RMS Calculating Software
Data-items Compute-
RMS
0
User result
Context Diagram
numbers
Read- Validate-
numbers numbers
0.1 0.2
Valid -
Data- numbers
items error
Example 1: RMS
Compute- Calculating
Display rms Software
0.4 0.3
result RMS
root Example 1:
rms RMS
rms
Valid-numbers Calculating
Valid-numbers
Software
Get-good-data Compute-solution Display-solution
Get-data Validate-
data
Context Diagram for Example 2
Tic-tac-toe
display software
0
move
Human Player
root
2
Fault, defect, or bug Error or mistake
Failure
Design Code
Specification
4
How to Reduce Bugs?
Review
Testing
6
Examine Test Result…
8
Testing Facts
Test automation
10
10
Monkey Testing is Passe…
Testing through random
inputs.
Problems:
Many program parts may not
get tested. •Two types of monkeys:
14
14
Testing Levels
16
Test Levels
Unit testing
Test each module (unit, or component) independently
Acceptance testing
Validation of system functions by the customer
18
Basic Concepts in
Testing
20
Quiz 1
As testing proceeds more and more bugs
are discovered.
How to know when to stop testing?
System testing?
22
Integration Testing
After modules of a system
have been coded and unit
tested:
Modulesare integrated in steps
according to an integration plan
The partially integrated system
is tested at each integration
step.
24
Types of System Testing
Based on types test:
Functionality test
Performance test
Alpha
Beta
26
Acceptance test 26
User Acceptance Testing
28
28
V&V
Feasibility Study
Req. Analysis
Design
Testing by developers
Coding
Testing by Tester
Review,
Simulation, etc. Testing
Maintenance
30
Capers Jones Rule of Thumb
32
Quiz 1. When are verification
undertaken in waterfall
model?
Feasibility Study 2. When is testing
undertaken in waterfall
Req. Analysis
model?
Design
3. When is validation
Coding undertaken in waterfall
model?
Testing
Maintenance
34
Test Cases
Each test case typically tries to
establish correct working of some
functionality:
Executes (covers) some program
elements.
Forcertain restricted types of
faults, fault-based testing can be
used. 36
Test Cases and Test Suites
number…” 40
Test Case number
Test Case author
Test purpose Sample: Recording of Test Case & Results
Pre-condition:
Test inputs:
Expected outputs (if any):
Post-condition:
Test Execution history:
Test execution date
Person executing Test
Test execution result (s) : Pass/Fail
42
44
If test cases are selected randomly:
Many test cases would not contribute to
the significance of the test suite,
Wouldonly detect errors that are already
detected by other test cases in the suite.
If (x>y) max = x;
else max = x; // should be max=y;
52
Unit Testing
PROCEDURE
STUB UNDER TEST
DRIVER
CALL CALL
54
Design of Unit Test Cases
Grey-box approach
56
56
What is Hard about BB Testing
58
Solution
60
Software considered as a black box:
Test data derived from the specification
No knowledge of code necessary Black Box
Testing
Also known as:
Data-driven or
Input/output driven testing
Alternative flow 2
Alternative flow 4
end use case
end use case
end use case
64
Identify use case scenarios: Example
1 Basic flow
66
Equivalence Class
Testing
68
Why Define Equivalence Classes?
Premise: E1 E2 E3
Scalene
Equilateral, etc.
Invalid
Valid
74
Equivalence Class Partitioning
76
Example
SQRT
78
Example (cont.)
80
Design Equivalence class test cases: Quiz 1
A bank pays different rates of interest on a
deposit depending on the deposit period.
84
Boundary Value Analysis
94
Boundary Value Analysis: Robustness
Char / 0 1 2 3 4 5 6 7 8 9 :
ASCII 47 48 49 50 51 52 53 54 55 56 57 58
96
Quiz: BB Test Design
Condition2 Yes X No X
Conditions
Condition3 No Yes No X
Action3 No No No Yes
100
Test cases from Decision Tables
Test Case
ID a b c Expected
output
TC1 4 1 2 Not a
Triangle
TC2 2888 2888 2888 Equilateral
TC3 ? | ) Impossible
TC4
…
TC11
102
Case a b c Expected
Output
ID
DT1 4 1 2 Not a
Triangle
DT2 1 4 2 Not a
Triangle
DT5 ? ? ? Impossible
DT6 ? ? ? Impossible
DT7 2 2 3 Isosceles
DT8 ? ? ? Impossible
DT9 2 3 2 Isosceles
DT10 3 2 2 Isosceles
104
DT11 3 4 5 Scalene
104
Quiz: Develop BB Test Cases
Policy for charging customers for certain
in-flight services:
106
POSSIBLE COMBINATIONS
Analyze
column by more than
N N N N Y Y Y Y
column to half-full
CONDITONS
determine
which actions more than Rs.
N N Y Y N N Y Y
are 3000 per seat
appropriate
for each domestic
combination N Y N Y N Y N Y
flight
ACTION
serve meals X X X X
S
free X
108
Final Combinations
solution more than half-full N Y Y Y
domestic flight - - N Y
ACTIONS
serve meals X X X
free X
110
Guidelines and Observations
Decision Table testing is most appropriate for
programs for which:
There is a lot of decision making
There are important logical relationships among
input variables
There are calculations involving subsets of input
variables
There are cause and effect relationships between
input and output
There is complex computation logic
114
What is White-box Testing?
116
Several white-box testing strategies have become
very popular :
Statement coverage
Branch coverage
White-Box
Path coverage Testing
Condition coverage
MC/DC coverage
Mutation testing
Data flow-based testing
118
Coverage-Based Testing Versus Fault-Based
Testing
Stronger
Weaker
122
Stronger, Weaker, and Complementary
Testing
Complementary
Weaker
124
Statement Coverage
126
Statement Coverage
Coverage measurement:
# executed statements
# statements
128
Example
130
Branch Coverage
132
Example
{(x=3,y=3),(x=3,y=2), (x=4,y=3),
(x=3,y=4)}
134
Quiz 1: Branch and Statement
Coverage: Which is Stronger?
136
Coverage
Report
138
Statements vs Branch Testing
Traversing all edges of a graph causes all nodes
to be visited
digit_high == 1 || digit_low == -1
((c1.and.c2).or.c3):
144
Branch Testing
To think of it:
146
MC/DC Testing
148
Condition Testing
Condition/decision coverage:
150
Shortcomings of Condition Testing
152
Multiple Condition Coverage
true false
158
MC/DC Requirement 3
• Every condition in the decision independently affects the
decision’s outcome.
160
Another Example
If( (A B) C) ….
A B C Result A B C MC/DC
1 1 1 1 1
2 1 1 0 0 * *
3 1 0 1 1 * *
4 0 1 1 1 * *
5 1 0 0 0 * *
6 0 1 0 0
7 0 0 1 0
8 0 0 0 0
* * *
162
Critique
MC/DC criterion is stronger than
condition/decision coverage MCC
criterion,
MC/DC
164
166
Path Coverage
Design test cases such that:
Defined in terms of
168
How to Draw Control Flow Graph?
Number all statements of a program.
Numbered statements:
Represent nodes of control flow graph.
172
Cyclomatic Complexity
174
Derivation of Test Cases
Draw control flow graph.
Determine V(G).
Determine the set of linearly
independent paths.
Prepare test cases:
Force execution along each path.
Not practical for larger programs. 176
178
180
182
184
186
188
Derivation of Test Cases
1,2,3,5,1,6
1,2,4,5,1,6
190
192
194
Derivation of Test Cases
196
Cyclomatic Complexity
Cyclomatic complexity of a
program:
Also indicates the psychological
complexity of a program.
200
White-Box Testing : Recap
statement
weakest coverage
condition branch
coverage (or decision)
coverage
multiple- condition
coverage
202
Data Flow-Based Testing
204
Data Flow-Based Testing
For a statement numbered S,
DEF(S) = {X/statement S contains a definition
of X}
USES(S)= {X/statement S contains a use of
X}
Example: 1: a=b; DEF(1)={a}, USES(1)={b}.
Example: 2: a=a+b; DEF(1)={a}, USES(1)={a,b}.
206
DU Chain Example
1 X(){
2 int a=5; /* Defines variable a */
3 While(c>5) {
4 if (d<50)
5 b=a*a; /*Uses variable a */
6 a=a-1; /* Defines variable a */
7 }
8 print(a); } /*Uses variable a */
208
Data Flow-Based Testing
210
Data Flow-Based Testing
[a,1,5]: a DU chain.
Assume:
DEF(X) = {B1, B2, B3, B4, B5}
216
Mutation Testing
If a mutant remains alive:
222
The Mutation Process
Program If program is
not error-free,
Create fix it
Mutants Test
Process
Mutation
Mutation Tests
Problem
New Testwith
Mutant Test Tests?
Cases
Mutants
Yes
224
Disadvantages of Mutation Testing
Equivalent mutants
226
Quiz 1: Solution
Identify two advantages and two
disadvantages of the mutation test
technique.
Adv:
Can be automated
Helps effectively strengthen black box and
coverage-based test suite
Disadv:
Equivalent mutants
228
How to Draw Control flow Graph?
Sequence: 1
1 a=5;
2 b=a*b-1;
2
230
How to Draw Control Flow Graph?
Iteration:
1
1 while(a>b){
2 b=b*a; 2
3 b=b-1;}
3
4 c=b+d;
4
232
All Path Criterion
234
Independent path
It is straight forward:
238
Cyclomatic Complexity
242
Coding Phase
Coding is undertaken once design
phase is complete.
During coding phase:
every module identified in the design
document is coded and unit tested.
Unit testing (aka module testing):
testing of different modules (aka units)
of a system in isolation. 2
Coding
At the end of the design phase we have:
modulestructure (e.g. structure chart) of
the system
module specifications:
data structures and algorithms for each
module.
Objective of coding phase:
transform design into code
unit test the code. 4
Coding Standards
Many software development
organizations:
formulatetheir own coding
standards that suits them most,
requiretheir engineers to
follow these standards
rigorously. 6
Coding Standards
A coding standard
sets
out standard ways of doing
several things:
the way variables are named,
code is laid out,
maximum number of source lines
allowed per function, etc.
8
8
Code inspection and code walk
throughs
After a module has been coded:
codeinspection and code walk
through are carried out
ensures that coding standards
are followed
helpsdetect as many errors as
possible before testing. 10
Coding Standards and
Guidelines
Good organizations usually develop
their own coding standards and
guidelines:
depending on what best suits their
organization.
For example,
if a global variable is changed obscurely in
a called module,
for(i=1;i<100;i++)
{…..}
i=2*p*q;
return(i);
22
Use of a variable for multiple
purposes
There are several things wrong
with this approach:
hence should be avoided.
Each variable should be given a
name indicating its purpose:
Thisis not possible if an identifier is
used for multiple purposes.
24
Representative Coding Guidelines
28
28
Code Walk Through
Even though an informal technique:
several guidelines have evolved over the
years
making this naive but useful analysis
technique more effective.
These guidelines are based on
personal experience, common sense, and
several subjective factors.
30
Code Walk Through
Discussion should focus on discovery of
errors:
and not on how to fix the discovered
errors.
To foster cooperation:
avoid the feeling among engineers that
they are being evaluated in the code walk
through meeting,
managers should not attend the walk
through meetings.
32
Code Inspection
For instance, consider:
classical error of writing a procedure that
modifies a formal parameter
while the calling routine calls the procedure
with a constant actual parameter.
It is more likely that such an error will be
discovered:
by looking for this kind of mistakes in the code,
rather than by simply hand simulating execution
of the procedure.
34
Commonly made errors
Use of uninitialized variables.
Nonterminating loops.
Array indices out of bounds.
Incompatible assignments.
Improper storage allocation and
deallocation.
Actual and formal parameter mismatch in
procedure calls.
Jumps into loops. 36
Software Documentation
When developing a software product we develop
various kinds of documents :
In addition to executable files and the source code:
users' manual,
software requirements specification (SRS)
document,
design document, test document,
installation manual, etc.
Internal documentation:
documentation provided in the
source code itself.
External documentation:
documentation other than those
present in the source code.
40
Internal Documentation
Good software development
organizations:
ensure good internal documentation
48
Summary
Widgets are the building blocks of
user interface design.
To develop a modern GUI:
put together the widgets you require
stitch them together.
makes user interface development easy.
50
Summary
Coding standards:
enforce good coding practice
Coding guidelines:
suggestions to programmers
exact implementation depends on
discretion of the programmers.
52
Summary
Documentation
Internal
External
Internal documentation
provided in the source code itself.
Comprehensibility of text
documents: 54
Contents
1 Introduction 4
1.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Definitions, Acronyms, and Abbreviations . . . . . . . . . . . . . 4
1.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Overall Description 5
2.1 Product perspective . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Product Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.1 Registration: . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Patient check out. . . . . . . . . . . . . . . . . . . . . . . 6
2.2.3 Report Generation: . . . . . . . . . . . . . . . . . . . . . . 6
2.3 User characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.1 Front-desk staff: . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.2 Administrators: . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 General Constraints . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 Assumptions and Dependencies . . . . . . . . . . . . . . . . . . . 7
3 Specific Requirement 7
3.1 External Interface Requirements . . . . . . . . . . . . . . . . . . 7
3.1.1 User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2 Hardware Interfaces . . . . . . . . . . . . . . . . . . . . . 7
3.1.3 Software Interfaces . . . . . . . . . . . . . . . . . . . . . . 7
3.1.4 Communications Interfaces . . . . . . . . . . . . . . . . . 8
3.2 Functional Requirements . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.1 Registration . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.2 Check Out . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.3 Report Generation . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Logical Database Requirements . . . . . . . . . . . . . . . . . . . 9
3.4 Design Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.5 Non Functional Requirements . . . . . . . . . . . . . . . . . . . . 9
3.5.1 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.5.2 Performance Requirements . . . . . . . . . . . . . . . . . 10
2
1 Introduction
1.1 Purpose
The purpose of this document is to describe the requirements for the Hospital
Patient Info Management System (HPIMS). The intended audience includes all
stakeholders in the potential system. These include, but are not necessarily
limited to, the following: Administrative Staff, patients and developers.
Developers should consult this document and its revisions as the only source
of requirements for the project. They should not consider any requirements
statements, written or verbal as valid until they appear in this document or its
revision.
1.2 Scope
The proposed software product is the Hospital Patient Info Management System
(HPIMS). The system will be used to get the information from the patients and
then storing that data for future usage. The current system in use is a paper-
based system. It is too slow and cannot provide updated lists of patients within
a reasonable timeframe.The intentions of the system are to reduce over-time pay
and increase the number of patients that can be treated accurately. Require-
ments statements in this document are both functional and non-functional.
4
2.2.2 Patient check out.
If a patient checks out, the administrative staff shall delete his PHN from the
system and the just evacuated bed is included in available-beds list.
They all have general reception and secretarial duties. Every staff has some basic
computer training. They are responsible for patient’s check-in or notification of
appropriate people.
2.3.2 Administrators:
6
3.1.4 Communications Interfaces