SOFTWARE ENGINEERING
SOFTWARE ENGINEERING
Software Engineering
B.C.A - V SEMESTER
Compiled by
1
Srinivas Institute of Management Studies BCA V sem
SOFTWARE ENGINEERING
Contents
Unit-1
1. Introduction
2. Software Processes
Unit-2
3 . Software Requirement Analysis and Specification
5. Detailed Design
6. Coding
3
Srinivas Institute of Management Studies BCA V sem
7. Testing and Maintenance
7.1 Introduction
7.2 Testing Fundamentals
7.3 Test Oracles
7.4 Top-Down and Bottom-up Approaches
7.5 Test Cases and Test Criteria
7.6 Psychology of Testing
7.7 Type of Testing
7.6.1 Functional Testing
7.6.2 Structural Testing
7.8 Levels of Testing
7.9 Test Plan
7.10 Software Maintenance Activities
7.11 Definitions of Software Maintenance
7.12 Types of Software Maintenance
7.12.1 Corrective Maintenance
7.12.2 Preventive Maintenance
7.12.3 Adaptive Maintenance
7.12.4 Perfective Maintenance
Assignment 7
8. Testing tools
Value-Added Chapters
Session 1: Software Testing Techniques
Session 2: Test case design
Session 3: Two unit Testing Techniques
Session 4: Basic path Testing
4
Srinivas Institute of Management Studies BCA V sem
Unit-1
Chapter 1
Introduction
The use of computers is growing very rapidly. Now computer systems are used in areas like
business applications, scientific work, video games, aircraft control, missile control, hospital
management, airline-reservation etc.
Portability
Maintainability Reusability
Flexibility Interoperability
Testability
Product Product
Revision Transition
Product Operations
6
Srinivas Institute of Management Studies BCA V sem
The Product operation deals with the quality factors such as correctness reliability and efficiency.
Product transition deals with quality factors such as portability, interoperability. Product revision
deals with aspects related to modification of programs, including factors like maintainability and
testability.
Correctness is the extent to which a program satisfies its specifications. Reliability is the property
that defines how well the software meets its requirements. Efficiency is the factor in all issues
rating to the execution of the software. It includes considerations such as response time, memory
requirements and throughput. Usability is the effort required to learn and operate the software
properly.
Maintainability is the effort required to locate and fix errors in the programs. Testability is the
effort required to test and check that symbol or module performs correct operation or not.
Flexibility is the effort required to modify an operational program (functionality).
Portability is the effort required to transfer the software from one hardware configuration to
another. Reusability is the extent to which parts of software can be used in other related
applications. Inter-operability is the effort required to couple the system with other systems.
Requirement Analysis
Requirement analysis is done in order to understand the problem to be solved. In this phase, collect
the requirement needed for the software project.
The goal of software requirement specification phase is to produce the software requirement
specification document. The person who is responsible for requirement analysis is called as
analyst. In problem analysis, the analyst has to understand the problem. Such analysis requires a
thorough understanding of the existing system. This requires interaction with the client and end-
users as well as studying the existing manuals and procedures. Once the problem is analyzed, the
requirements must be specified in the requirement specification document.
7
Srinivas Institute of Management Studies BCA V sem
Software Design
The purpose of design phase is to plan a solution for the problem specified by the requirement
document. The output of this phase is the design document which is the blue-pint or plan for the
solution and used later during implementation, testing and maintenance.
Design activity is divided into two phases- System design and detailed design. System design
aims to identify the module that should be included in the system. During detailed design, the
internal logic of each of the modules specified during system design is decided.
Coding
The goal of coding is to translate the design into code in a given programming language. The aim
is to implement the design in the best possible manner. Testing and maintenance costs are much
higher than the coding cost, therefore, the goal of should be to reduce testing and maintenance
efforts. Hence the programs should be easy to read and understand.
Testing
After coding phase computer programs are available, which can be executed for testing purpose.
Testing not only has to uncover errors introduced during coding, but also errors introduced during
previous phases.
The starting point of testing is unit testing. Here each module is tested separately. After this, the
module is integrated to form sub-systems and then to form the entire system. During integration of
modules, integration testing is done to detect design errors. After the system is put together,
system testing is performed. Here, the system is tested against the requirements to see whether all
the requirements are met or not. Finally, acceptance testing is performed by giving user’s real-
world data to demonstrate to the user.
Assignment 1
Part-A
1. Give IEEE definition of software.
2. Mention the problems of software.
3. Differentiate program and programming system product.
4. Justify why software is expensive.
5. Expand LOC, DLOC, KDLOC.
6. Explain the problem of change and rework in a software.
7. Give IEEE definition of software engineering.
8. Mention the problems of software engineering.
9. Mention three quality dimensions of a software product.
10. List any four quality factors of software engineering.
11. Define Maintainability and Testability.
12. Define Portability and Reusability.
13. Define Reliability and Usability.
14. What are the basic objectives of software engineering?
15. Mention various phases of development process
8
Srinivas Institute of Management Studies BCA V sem
16. What is Unit testing?
17. What is Integration testing?
18. What is Acceptance testing?
19. What is corrective maintenance?
20. What is adaptive maintenance?
Part-B
1. Define Software. Briefly explain the software problem.
2. Define Software Engineering. Explain the various problems faced in software engineering.
3. Explain any four qualities attributes of software engineering.
4. Explain different phases of phased development process.
9
Srinivas Institute of Management Studies BCA V sem
chapter 2
Software Processes
10
Srinivas Institute of Management Studies BCA V sem
Software Processes
2.2.1. Predictability
Predictability of a process determines how accurately the outcome of following a process in a
project can be predicted before the project is completed. Predictability is a fundamental property of
any process. Effective management of quality assurance activities largely depend on the
predictability of the process. A predictable process is also said to be under statistical control. A
process is said to be under statistical control if following the same process produces similar results.
Statistical control implies that most projects will be within a bound around the expected value.
Any data beyond the line implies that the data and the project should be examined and followed to
pass through only if a clear evidence is found that this is a statistical aberration.
Property
of interest
Process under
statistical control
Projects
11
Srinivas Institute of Management Studies BCA V sem
Relative
cost to
fix errors 100
50
10
5
Reqts Design Coding Development Acceptance Operation
2.2.4. Process Improvement: Improving the quality and reducing the cost are the fundamental
goals of the software engineering process. This requires the evaluation of the existing process and
understanding the weakness in the process.
12
Srinivas Institute of Management Studies BCA V sem
Besides the entry and the exit criteria for the input and the output a development step needs to
produce some information for the management process. To goal of management process is to
control the development process.
13
Srinivas Institute of Management Studies BCA V sem
Reviews are formal meetings to uncover deficiencies in a product. The review reports are the
outcomes of these reviews.
Coding
Testing & Integration
Verification Programs
Operation &
Installation Installation Report Maintenance
Waterfall Model
Page 14
Srinivas Institute of Management Studies BCA V sem
5. In an interesting analysis it is found that, the linear nature of the life cycle leads to
“blocking states” in which some project team members have to wait for other team
members to complete the dependent task. The time spent in waiting can exceed the time
spent in productive work.
6. Client gets a feel about the software only at the end.
Requirement
Design
Design Code Test
Code
Test
This model is helpful when the customer is not able to state all the requirements. Because the
prototype is throwaway, only minimum documentation is needed during prototyping. For
example design document and test plan etc. are not needed for the prototype.
Problems:
This model much depends on the efforts required to build and improve the prototype which in
turn depends on computer aided prototyping tools. If the prototype is not efficient, too much
effort will be put to design it.
2.3.4. Iterative Enhancement Model
Page 15
Srinivas Institute of Management Studies BCA V sem
This model tries to combine the benefits of both prototyping and waterfall model. The basic
idea is, software should be developed in increments, and each increment adds some functional
capability to the system. This process is continued until the full system is implemented. An
advantage of this approach is that, it results in better testing because testing each increment is
likely to be easier than testing the entire system. As prototyping, the increments provide
feedback from the client, which will be useful for implementing the final system. It will be
helpful for the client to state the final requirements.
Here a project control list is created. It contains all tasks to be performed to obtain the final
implementation and the order in which each task is to be carried out. Each step consists of
removing the next task from the list, designing, coding, testing and implementation and the
analysis of the partial system obtained after the step and updating the list after analysis. These
three phases are called design phase, implementation phase and analysis phase. The process is
iterated until the project control list becomes empty. At this moment, the final implementation
of the system will be available.
The first version contains some capability. Based on the feedback from the users and
experience with the current version, a list of additional features is generated. And then more
features are added to the next versions. This type of process model will be helpful only when
the system development can be broken down into stages.
Disadvantage:
This approach will work only if successive increments can actually put into operation.
Page 16
Srinivas Institute of Management Studies BCA V sem
The risk-driven nature of the spiral model allows it to suit for any applications. The important
feature of spiral model is that, each cycle of spiral is completed by a review that covers all the
products developed during that cycle; including plans for the next cycle.
In a typical application of spiral model, one might start with an extra round-zero, in which the
feasibility of the basic project objectives is studied. In round-one a concept of operation might
be developed. The risks are typically whether or not the goals can be met within the constraints.
In round-2, the top-level requirements are developed. In succeeding rounds the actual
development may be done. In a project, where risks are high, this model is preferable.
Problems:
1) It is difficult to convince the customers that the evolutionary approach is controllable.
2) It demands considerable risk-assessment expertise and depends heavily on this expertise
for the success.
3) If major risks are uncovered and managed, major problems may occur.
Page 17
Srinivas Institute of Management Studies BCA V sem
Control
Development Process
State of Development
Time
Temporary relation between dev. Process and mgt. process
Project monitoring and control phase includes all activities that the project management has to
perform while development is going on to ensure that project objectives are met and the
development process proceeds according to the plan. If the objectives are not met, then this
phase exerts suitable actions to control development activities. Monitoring requires proper
information about the project. This information is obtained by the management process from
the development process.
Termination analysis is performed when the development phase is over. The basic reason for
performing termination analysis is to provide information about the development process. The
ideal relationship between development process and management process is given in the figure
above. It shows that, planning is done before starting the development process and termination
analysis is conducted after the development is over. During development process, quantitative
information flows to the monitoring and control phase of the management process which uses
the information to exert control on the development process.
Page 18
Srinivas Institute of Management Studies BCA V sem
SCM is a process of identifying and defining the items in the system, controlling the change of
these items throughout their life-cycle, recording and reporting the status of item and change
request and verifying the completeness and correctness of these items. SCM is independent of
development process. Development process handles normal changes such as change in code
while the programmer is developing it or change in the requirement while the analyst is
gathering the information. However it can not handle changes like requirement changes while
coding is being done. Approving the changes, evaluating the impact of change, decide what
needs to be done to accommodate a change request etc. are the issues handled by SCM. SCM
has beneficial effects on cost, schedule and quality of the product being developed.
It has three major components:
1. Software configuration identification
2. Change Control
3. Status accounting and auditing.
Page 19
Srinivas Institute of Management Studies BCA V sem
Rejected
Once the SCI is in the library, it can not be modified, even without the permission of the CM.
an SCI under SCM can be changed only if the change has been approved by the CM. A change
is initiated by a change request (CR). The reason for change can be anything. The CM
evaluates the CR primarily by considering the effect of change on the cost schedule and quality
of the project and the benefits likely to come due to this change. Once the CR is accepted,
project manager will take over the plan and then CR is implemented by the programmer.
Page 20
Srinivas Institute of Management Studies BCA V sem
levels to the next higher level when they are improved. During the course of process
improvement, a process moves from level to level until it reaches level 5.
The initial process (level 1) is essentially an ad hoc process that has no formalized method for
any activity. Organizations at this level can benefit most by improving project management,
quality assurance, and change control.
In a repeatable process (level 2), policies for managing a software project and procedures to
implement those policies exist. Ie,project management is well developed in a process at this
level.
At the defined level (level 3), each step is carefully defined with verifiable entry and exist
criteria, methodologies for performing the step, and verification mechanisms for the output of
Optimizing
Continuously
the step. (5)
improving process
Managed
Predictabl
e process (4)
Defined
Standard, (3)
Consistent
process
Repeatable
Discipline (2)
d process
Initial
(1)
At the managed level (level 4) Data is collected from software processes, which is used to build
models to characterize the process.
At the optimizing level (level 5), the focus of the organization is on continuous process
improvement. Data is collected and routinely analyzed to identify areas that can be
strengthened to improve quality or productivity. New technologies and tools are introduced and
their effects measured in an effort to improve the performance of the process. Best software
engineering and management practices are used throughout the organization.
Quality Improvement Paradigm and GQM
It gives a general method for improving a process, essentially implying that what constitutes
improvement of a process depends on the organization to which the process belongs and its
objectives. The basic idea behind this approach is to understand the current process, set
objectives for improvement, and then plan and execute the improvement actions. The QIP
consists of six basic steps:
• Characterize. Understand the current process and the environment it operates in.
Page 21
Srinivas Institute of Management Studies BCA V sem
• Set Goals. Based on the understanding of the process and the environment and
objectives of the organization, set quantifiable goals for performance improvement.
• Choose Process. Based on the characterization and goals, choose the component
processes that should be changed to meet the goals.
• Execute. Execute projects using the processes and provide feedback data.
• Analyze. Analyze the data at the end of each project.
• Package. Based on the experience gained from many projects, define and formalize the
changes to be made to processes and expectation from the new processes.
Goal/Question/Metrics (GQM) paradigm suggests a general framework for collecting data from
projects that can be used for a specific purpose. It is frequently used in the context of process
improvement. The QIP and GQM have been used successfully by many organizations to
improve their processes.
Assignment 2
Part-A
1. Define Product metrics and process metrics.
2. Define Software process.
3. Differentiate Software project and Software product.
4. List the major components of software process.
5. Expand SEPG, CCB,SCM
6. Define Optimality and scalability.
7. What is verification and validation?
8. What are work products?
9. What is entry criteria and exit criteria of a phase?
10. Mention any two limitations of the water fall model.
11. What is Project control list?
12. Mention the three phases of iterative enhancement model.
13. Mention the activities in the management process for a project?
14. Differentiate metrics and measurement.
15. Define SCM.
16. Write the three major components of SCM.
17. What is status accounting and auditing?
18. Mention the Basic step of QIP.
Part-B
1. Briefly explain the various characteristics of a software process.
2. With the help of a diagram explain the working of the waterfall model.
3. Explain the limitation of the waterfall model.
4. Explain the working of an iterative enhancement model with the help of a diagram.
5. Explain the prototyping model.
6. Explain the spiral model with the help of a diagram.
7. Briefly explain the phases of management process.
8. Briefly explain the various activities of software configuration management process.
9. Explain the software configuration item (SCI).
Page 22
Srinivas Institute of Management Studies BCA V sem
Unit-2
Chapter-3
Software Requirement Analysis and Specification
Page 23
Srinivas Institute of Management Studies BCA V sem
Client originates the requirements. The software is developed by software engineers and
delivered to clients. Completed system will be used by the end-user. There are three major
parties involved: client, developer and the end-user. The problem here is, the client usually
does not understand software or the software development process and the developer often
does not understand the client’s problem and application area. This causes a communication
gap between the client and the developer. A basic purpose of SRS is to bridge this
communication gap. SRS is the medium with which the client and user needs are identified.
Another important purpose of developing the SRS is helping the clients to understand their own
needs. In order to satisfy the client, he has to be made aware about the requirements of his
organization. The process of developing an SRS helps here. Hence developing the SRS has
many advantages as follows:
• An SRS establishes the basis for agreement between the client and the developer on
what the software product will do.
This basis for agreement is frequently formalized into a legal contact between the client and the
developer. So through SRS, the client clearly describes what is expected from the developer
and the developer clearly understands the capabilities to build the software. Without such an
agreement, it is almost guaranteed that once the development is over, the project will have an
unhappy client and an unhappy developer.
• SRS provides a reference for validation of the final product.
SRS helps the client to determine if the software meets the requirements. Without proper SRS,
there is no way for the client to determine if the software meets the requirements. Without a
proper SRS there is no way a client can determine if the software being delivered is what was
ordered and there is no way the developer can convince the client that all the requirements have
been met.
• A high-quality SRS is a prerequisite to high-quality software.
The quality of the SRS has great impact on the cost of the project. The cost of fixing the error
increases as we proceed on to the further phases in the software development life cycle. In
order to reduce the errors the SRS should be of high quality.
• A high-quality SRS reduces the development cost.
If the SRS is of high quality, effort required to design the solution, effort required for coding,
testing and maintenance will be reduced. Hence a high quality SRS reduces the development
cost.
Page 24
Srinivas Institute of Management Studies BCA V sem
The requirement process is the sequence of activities that need to be performed in the
requirement phase. There are three basic activities in case of requirement analysis. They are:
1. Problem analysis or requirement analysis.
2. Requirement specification. Client/user
3. Requirement validation. needs
Problem analysis is initiated with some general
statement of needs. Client is the originator of
these needs. During analysis, the system
behavior, constraints on the system, its inputs,
Problem Analysis
and outputs are analyzed. The basic purpose of
this activity is to obtain the thorough
understanding of what the software needs to
provide. The requirement specification clearly Product Description
specifies the requirements in the form of a
document. The final activity focuses on
validation of the collected requirements.
Requirement process terminates with the Figure (a)
Validation
production of the validated SRS.
Though it seems that the requirement process is Validated SRS
a linear sequence of these activities, in reality it
is not so. The reality is, there will be a
considerable overlap and feedback between these activities. So, some parts of the system are
analyzed and then specified while the analysis of some other parts is going on. If validation
activities reveal some problem, for a part of the system, analysis and specifications are
conducted again.
The requirement process is represented diagrammatically in figure (a). As shown in the figure,
from specification activity we may go back to the analysis activity. This happens because the
process specification is not possible without a clear understanding of the requirements. Once
the specification is complete, it goes through the validation activity. This activity may reveal
problems in the specification itself, which requires going back to the specification step, which
in turn may reveal shortcomings in the understanding of the problem, which requires going
back to the analysis activity.
During requirement analysis, the focus is on understanding the system and its requirements.
For complex systems, this is the most difficult task. Hence the concept “divide-and-conquer”
i.e., decomposing the problem into sub-problems and then understanding the parts and their
relationship.
Page 25
Srinivas Institute of Management Studies BCA V sem
Page 26
Srinivas Institute of Management Studies BCA V sem
The informal approach to analysis is the one where no defined methodology is used. Like in
any approach, the information about the system is obtained by interaction with the client, end
users, questionnaires, study of the existing documents, brainstorming etc. however, in this
approach; no formal model is built of the system. In this approach, the analyst will have a
series of meetings with the clients and the end users. In the early meetings, the clients and the
end users will explain to the analyst about their work, their environment and their needs. Any
documents describing the work may be given along with the outputs of the existing methods to
perform tasks. In these meetings, analyst is basically a listener, absorbing the information
provided. Once the analyst understands the system to some extent, he uses the next few
meetings to seek clarifications of the parts he does not understand. He may document the
information in some manner. In the final few meetings, the analyst essentially explains to the
client about what he understands the system should do and uses the meetings as a means of
verifying what he has gathered is true. An initial draft of SRS may be used in the final
meetings.
Page 27
Srinivas Institute of Management Studies BCA V sem
thinking is consciously avoided. For examples, consideration of loops and decisions must be
avoided. There are no detailed procedures that can be used to draw a DFD for a given problem.
Only some directions can be provided. For large systems, it is necessary to decompose the
DFD to further levels of abstraction. In such cases, DFDs can be hierarchically arranged.
Employee record
Company Records
Overtime Rate
Weekly Timesheet
In a DFD, data flows are identified by unique names. These names are chosen so that they
convey some meaning about what the data is. However, the precise structure of the data flows
is not specified in a DFD. The data dictionary is a repository of various data flows defined in a
DFD. Data dictionary states the structure of each data flow in the DFD. To define data
structure, different notations are used. A composition is represented by +, selection is
represented by / (i.e., either or relationship), and repetition may be represented by *. Example
of a data dictionary is given below:
Weekly timesheet= employee_name +
employee_id+[regular_hrs+Overtime_hrs]*
Pay_rate= [hourly_pay/daily_pay /weekly_pay]
Employee_name= Last_name+ First_name +Middle_name
Employee_id= digit+ digit+ digit + digit
Most of the data flows in the DFD are specified here. Once we have constructed a DFD and
associated data dictionary, we have to somehow verify that they are correct. There is no
specific method to do so but data dictionary and DFDs are examined such that, the data stored
in data dictionary should be there some where in the DFD and vice versa. Some common errors
in DFDs are listed below:
Page 28
Srinivas Institute of Management Studies BCA V sem
3.2.4. Prototyping
Prototyping is another method that can be used for problem analysis. It takes a very different
approach to problem analysis as compared to structured analysis. In prototyping, a partial
system is constructed, which is then used by the clients, developers and end users to gain a
better understanding of the problem and the needs. There are two features to prototyping:
throwaway and evolutionary. In the throwaway approach, the prototype is constructed with
the idea that it will be discarded after the analysis is complete. In the evolutionary approach,
the prototype is built with the idea that it will be used in the final system. Determining the
missing requirements is an advantage of prototyping. In case of evolutionary prototyping, more
formal techniques need to be applied since the prototype is retained in the final system.
Throwaway prototype leads to prototype model and the evolutionary prototype leads to
iterative enhancement model. It is important to clearly understand when a prototype is to be
used and when it is not to be used. The requirements can be divided into three sets — those that
are well understood those that are poorly understood, and those that are unknown. In case of
throwaway prototype, poorly understood ones that should be incorporated. Based on the
experience with the prototype, these requirements then become well understood as shown in
figure below.
Prototyping
Well Poorly
Unknown
understood understood
It might be possible to divide the set of poorly understood requirements further into two sets—
those critical to design and those not critical to design. If we are able to classify the
requirements this way, throwaway prototype should focus on the critical requirements. There
are different criteria to be considered when making a decision about whether or not to
prototype. They are listed below.
Page 29
Srinivas Institute of Management Studies BCA V sem
Page 30
Srinivas Institute of Management Studies BCA V sem
Page 31
Srinivas Institute of Management Studies BCA V sem
A SRS is correct if every requirement included in SRS represents something required in the
final system. An SRS is complete if everything the software is supposed to do and the
responses of the software to all classes of input data are specified in the SRS. Completeness
and correctness go hand-in-hand.
An SRS is unambiguous if and only if every requirement stated one and only one
interpretation. Requirements are often written in natural language, which are inherently
ambiguous. If the requirements are specified using natural language, the SRS writer should
ensure that there is no ambiguity. One way to avoid ambiguity is to use some formal
requirement specification language. The major disadvantage of using formal languages is
large effort is needed to write an SRS and increased difficulty in understanding formally
stated requirements especially by clients.
A SRS is verifiable if and only if every stored requirement is verifiable. A requirement is
verifiable if there exists some cost effective process that can check whether the final software
meets that requirement. Un-ambiguity is essential for verifiability. Verification of
requirements is often done through reviews.
A SRS is consistent if there is no requirement that conflicts with another. This can be
explained with the help of an example: suppose that there is a requirement stating that
process A occurs before process B. But another requirement states that process B starts
before process A. This is the situation of inconsistency. Inconsistencies in SRS can be a
reflection of some major problems.
Generally, all the requirements for software need not be of equal importance. Some are
critical. Others are important but not critical. An SRS is ranked for importance and/or
stability if for each requirement the importance and the stability of the requirement are
indicated. Stability of a requirement reflects the chances of it being changed. Writing SRS is
an iterative process.
An SRS is modifiable if its structure and style are such that any necessary change can be
made easily while preserving completeness and consistency. Presence of redundancy is a
major difficulty to modifiability as it can easily lead to errors. For example, assume that a
requirement is stated in two places and that requirement later need to be changed. If only one
occurrence of the requirement is modified, the resulting SRS will be inconsistent.
An SRS is traceable if the origin of each requirement is clear and if it facilitates the
referencing of each requirement in future development. Forward traceability means that each
requirement should be traceable to some design and code elements. Backward traceability
requires that it is possible to trace the design and code element to the requirements they
support.
Functional Requirements
Functional requirements specify which output should be produced from the given inputs.
They describe the relationship between the input and output of a system. All operations to be
performed on the input data to obtain the output should be specified. This includes specifying
the validity checks on the inputs and output data. Care must be taken not to specify any
algorithm. An important part of the specification is, the system behavior in abnormal
situations like invalid inputs or error during computation. The functional requirements must
clearly state what the system should to if such situations occur. It should specify the behavior
of the system for invalid inputs and invalid outputs. And also, the behavior of the system
where the input is valid but normal operation cannot be performed should also be specified.
An example of this situation is an airline reservation system, where the reservation cannot be
made even for a valid passenger if the airplane is fully booked. In short, system behavior for
all foreseen inputs and for all foreseen system states should be specified.
Performance Requirements
This part of the SRS specifies the performance constraints on the software system. There two
types of performance requirements—static and dynamic. Static requirements do not impose
constraints on the execution characteristics of the system. These include requirements like
number of terminals to be supported, the number of simultaneous operations to be supported
etc. These are also called capacity requirements of the system.
Dynamic requirements specify constraints on the execution behavior of the system. These
typically include response time and throughput constraints on the system. All these
requirements must be stated in measurable terms. Requirements like “:response time must be
good “ are not desirable because they are not verifiable.
Design Constraints
There are a number of factors in the client’s environment that may restrict the choices of the
designer. An SRS should identify and specify all such constraints.
Standard Compliance: This specifies the requirements for the standards the system
must follow. The standards may include the report format and accounting procedures.
Hardware Limitations: the software may have to operate on some existing or pre-
determined hardware, thus, imposing restrictions on the design. Hardware limitations
can include the type of machines to be used, operating systems available, languages
supported and limits on primary and secondary storage.
Reliability and Fault Tolerance: These requirements can place major constraints on
how the system is to be designed. Fault tolerance requirements make the system more
complex. Requirements in the system behavior in face of certain kinds of faults are to
be specified. Recovery requirements deal with the system behavior in case of failure.
Security: These requirements place restriction on the use of certain commands, control
access to data, provide different kinds of access requirements for different people etc.
33
Srinivas Institute of Management Studies BCA V sem
All the possible interactions of the software with the people, hardware and other software
should be clearly specified. User interface should be user friendly. To create user friendly
interface one can use GUI tools.
Regular Expressions
Regular expressions can be used to specify the structure of stings. This specification is useful
for specifying input data and content of the message. Regular expressions can be considered
as grammar for specifying valid sequences in a language and can be automatically processed.
They are routinely used in compiler construction. There are few basic constructs allowed in
regular expressions:
1. Atoms: the basic symbol or alphabet of a language.
2. Composition: formed by concatenation two regular expressions. For regular expressions
r1 and r2, concatenation is expressed as (r1 r2), and denotes the concatenation of strings
represented by r1 and r2.
3. Alternation: Specifies the either/or relationship. For r1 and r2, the alternation is
represented by (r1| r2) and denotes the union of the sets of strings specified by r1 and r2.
4. Closure: specifies the repeated occurrence of a regular expression. For a regular
expression r, the closure is represented by r*, which means that the strings denoted by r
are concatenated zero or more times.
Example: Consider a file containing student records.
Student_record=(Name Reg_no Courses)*
Name = (Last_name First_name)
Last_name, First_name= (A|B|C|D….. |Y|Z) (a|b|c|…….|y|z)*
Reg_no=digit digit digt digit digit digit
Digit=(0|1|2|……|9)
Courses=(C_number)*
C_number=(CS)(0|1|… )*
Decision Tables
Decision tables provide a mechanism for specifying complex decision logic. It is formal
table-based notation that can be automatically processed to check for qualities like
completeness and lack of ambiguity. A decision table has two parts. The top part lists
34
Srinivas Institute of Management Studies BCA V sem
different conditions and the bottom part specifies different actions. The table specifies under
what combination of conditions what action is to be performed.
Example: Consider the part of a banking system responsible for debiting from the accounts.
For this part the relevant conditions will be
C1: The account number is correct
C2: The signature matches
C3: There is enough money in the account.
The possible actions are
A1: Give money
A2: Give statement that not enough money is there in the account.
A3: Call the Police to check for fraud.
These conditions and possible actions can be
1 2 3 4 5 represented in tabular form as follows:
C1 N N Y Y Y The part of the decision table is shown here.
C2 N N Y Y For each condition a Y in the column
indicates yes or true and N indicates no or
C3 N Y N false and a blank means that it can be either
A1 X true or false. If an action is to be taken for a
particular combination of the conditions, it is
A2 X X
shown by X for that action. If there is no
A3 X mark for an action for a particular
combination of conditions, it means that the
action is not to be performed.
Push Pop
Push / Err-msg
Empty Full
Neither
Stack Empty nor Stack
Full Stack
Pop Push
35
Srinivas Institute of Management Studies BCA V sem
Push
.
3.2.m Mode m
3.2.m.1 Functional Requirement m.1
.
.
37
Srinivas Institute of Management Studies BCA V sem
Assignment 3
Part-A
1. Give IEEE definition of software requirements.
2. Mention the basic activities involved in requirement process.
3. Mention the three basic approaches to problem analysis.
38
Srinivas Institute of Management Studies BCA V sem
4. What are data source and sink? How to represent them in DFD?
5. Give any two symbols used in DFD with their purpose.
6. List some common errors while designing the DFD.
7. What is a data dictionary?
8. Mention the two approaches to prototyping.
9. What is throwaway and evolutionary approach of prototyping?
10. Mention any four characteristics of an SRS.
11. Mention the components of an SRS.
12. What is structured English?
13. What is a decision table?
14. Write a note on finite state automata.
15. In a DFD, a source is represented by ---------__and a process is represented by----
Part-B
1. Explain need of SRS.
2. Explain the activities of requirement process with a proper diagram.
3. With the help of a diagram explain the DFD of a system that pays the workers.
4. Explain the characteristics of an SRS.
5. Explain the various components of an SRS.
6. Write a note on specification languages for an SRS.
7. Explain the general structure of an SRS document..
39
Srinivas Institute of Management Studies BCA V sem
Chapter-4
Function Oriented Design
Introduction
The design activity begins when the requirements document for the software to be developed
is available. While the requirements specification activity is entirely in the problem domain,
design is the first step in moving from the problem domain toward the solution domain.
Design is essentially the bridge between requirements specification and the final solution for
satisfying the requirements. The goal of the design process is to produce a model or
representation of a system, which can be used later to build that system. The produced model
is called the design of the system. The design of a system is essentially blueprint or a plan for
a solution for the system. Here we consider a system to be a set of components with clearly
defined behavior that interacts with each other in a fixed defined manner to produce some
behavior or services for its environment.
The design process for software systems often has two levels. At the first level the focus is on
deciding which modules are needed for the system, the specifications of these modules, and
how the modules should be interconnected. This is what is called the system design or top-
level design. In the second level, the internal design of the modules, or how the specifications
of the module can be satisfied, is decided. This design level is often cal1ed detailed design or
logic design. Detailed design essentially expands the system design to contain a more detailed
description of the processing logic and data structures so that the design is sufficiently
complete for coding. Because the detailed design is an extension of system design, the system
design controls the major structural characteristics of the system. The system design has a
major impact on the testability and modifiability of a system, and it impacts its efficiency.
Much of the design effort for designing software is spent creating the system design.
A design methodology is a systematic approach to creating a design by applying of a set of
techniques and guidelines. These techniques are not formalized and do not reduce the design
activity to a sequence of steps that can be followed by the designer. The input to the design
phase is the specifications for the system to be designed. Hence reasonable entry criteria can
be that the specifications are stable and have been approved, hoping that the approval
mechanism will ensure that the specifications are complete, consistent, unambiguous, etc.
The output of the top-level design phase is the architectural design or the system design for
the software system to be built. This can be produced with or without using a design
methodology. Reasonable exit criteria for the phase could be that the design has been verified
against the input specifications and has been evaluated and approved for quality.
4.1. Design Principles
The design of a system is correct if a system built precisely according to the design satisfies
the requirements of that system. Clearly, the goal during the design phase to-produce correct
designs. However, correctness is not the sole criterion during the design phase, as there can
be many correct designs. The goal of the design process is not simply to produce a design for
the system. Instead, the goal is to find the best possible design within the limitations imposed
by requirements and the physical and social environment in which the system will operate. A
40
Srinivas Institute of Management Studies BCA V sem
design should clearly be verifiable, complete (implements all the specifications), and
traceable (all design elements can be traced to some requirements).
However, the two most important properties that concern designers are efficiency and
simplicity. Efficiency of any system is concerned with the proper use of scarce resources by
the system. The need for efficiency arises due to cost considerations. If some resources are
scarce and expensive, it is desirable that those resources be used efficiently. In computer
systems, the resources that are most often considered for efficiency are processor time and
memory. An efficient system is one that consumes less processor time and requires less
memory.
Simplicity is perhaps the most important quality criteria for software systems. We have seen
that maintenance of software is usually quite expensive. Maintainability of software is one of
the goals we have established. The design of a system is one of the most important factors
affecting the maintainability of a system. During maintenance, the first step a maintainer has
to undertake is to understand the system to be maintained. Only after a maintainer has a
thorough understanding of the different modules of the system, how they are interconnected,
and how modifying lone will affect the others should the modification be undertaken.
Creating a simple (and efficient) design of a large system can .be an extremely complex task
that requires good engineering judgment. As designing is fundamentally a creative activity, it
cannot be reduced to a series of steps that can be simply followed, though guidelines can be
provided. In this section we will examine some basic guiding principles that can be used to
produce the design of a system. Some of these design principles are concerned with providing
means to effectively handle the complexity of the design process. Effectively handling the
complexity will not only reduce the effort needed for design (i.e., reduce the design cost), but
can also reduce the scope of introducing errors during design.. In fact, the methods are also
similar because in both analysis and design we are essentially constructing models.
There are some fundamental differences between the design and the problem analysis phase.
First, in problem analysis, we are constructing a model of the problem domain, while in
design we are constructing a model for the solution domain. Second, in problem analysis, the
analyst has limited degrees of freedom in selecting the models as the problem is given, and
modeling has to represent it. In design, the designer has a great deal of freedom in deciding
the models, as the system the designer is modeling does not exist; in fact the designer is
creating a model for the system that will be the basis of building the system. That is, in
design, the system depends on the model, while in problem analysis the model depends on
the system. Finally, as pointed out earlier, the basic aim of modeling in problem analysis is to
understand, while the basic aim of modeling in design is to optimize (in our case, simplicity
and performance)
as together form the system. The different pieces have to cooperate and communicate to solve
the larger problem. This communication adds complexity, which arises due to partitioning
and may not have existed in the original problem. As the number of components increases,
the cost of partitioning, together with the cost of this added complexity, may become more
than the savings achieved by partitioning. The designer has to make the judgment about when
to stop partitioning. Clearly proper partition minimizes the maintenance cost.
The two of the most important quality criteria for software design are simplicity and
understandability. It can be argued that maintenance is minimized if each part in the system
can be easily related to the application and each piece can be modified separately. If a piece
can be modified separately, we call it independent of other pieces. If module A is
independent of module B, then we can modify A without introducing any unanticipated side
effects in B. Total independence of modules of one system is not possible, but the design
process should support as much independence as possible between modules. Dependence
between modules in a software system is one of the reasons for high maintenance costs.
Clearly, proper partitioning will make the system easier to maintain by making the design
easier to understand
4.1.2. Abstraction
An abstraction of a component describes the external behavior of that component without
bothering with the internal details that produce the behavior. The abstract definition of a
component is much simpler than the component itself.
Abstraction is a crucial part of the design process and is essential for problem partitioning.
Partitioning essentially is the exercise in determining the components of a system. However,
these components are not isolated from each other; they interact with each other, and the
designer has to specify how a component interacts with other components. To decide how a
component interacts with other components, the designer has to know, at the very least, the
external behavior of other components. To allow the designer to concentrate on one
component at a time, abstraction of other components is used. Abstraction is used for existing
components as well as components that are being designed. Abstraction of existing
components plays an important role in the maintenance phase. Using these abstractions, the
behavior of the entire system can be understood. This also helps determine how modifying a
component affects the system.
During design, the components do not exist, and in the design the designer specifies only the
abstract specifications of the different components. The basic goal of system design is to
specify the modules in a system and their abstractions. Once the different modules .are
specified, during the detailed design the designer can concentrate on one module at a time.
The task in detailed design and implementation is essentially to implement the modules so
that the abstract specifications of each module are satisfied.
There are two common abstraction mechanisms for software systems: functional abstraction
and data abstraction. In functional abstraction, a module is specified by the function it
performs. For example, a module to compute the log of a value can be abstractly represented
by the function log. Similarly, a module to sort an input array can be represented by the
specification of sorting. Functional abstraction is the basis of partitioning in function-oriented
approaches. That is, when the problem is being partitioned, the overall transformation
42
Srinivas Institute of Management Studies BCA V sem
function for the system is partitioned into smaller functions that comprise the system
function.
The second unit for abstraction is data abstraction. Any entity in the real world provides
some services to the environment to which it belongs. Often the entities provide some fixed
predefined services. Data abstraction supports this view. Data is not simply a collection of
objects but is treated as objects with some predefined operations. It is possible top view this
object at an abstract level. From outside an object, the internals of the object – are hidden.
Only the operations on the object are visible. Data abstraction forms the basis fop object-
oriented design.
Modularity
As mentioned earlier, the real power of partitioning comes if a system is partitioned into
modules so that the modules are solvable and modifiable separately. It will be even better if
the modules are also separately compliable. A system is modular if it consists of discreet
components so that each component can implemented separately, and a change to one
component has minimal impact on the other components. The modularity is a clearly a
desirable property in a system. Modularity helps in system debugging. Software system
cannot be made modular by simply chopping it into a set of modules. For modularity, each
module needs, to support a well-defined abstraction and a clear interface through which it can
interact with other modules
Top-Down and Bottom-Up Strategies
A system consists of components; a System is a hierarchy of components. The highest level
component corresponds to the total system. To design such a hierarchy there is two possible
approaches: top-down and bottom-up. The top-down approach starts from the highest-level
component of the hierarchy and proceeds through to lower levels. By contrast, a bottom-up
approach starts with the lowest-level component of the hierarchy and proceeds through
progressively higher levels to the top-level component. A top-down design approach starts by
identifying the major components of the system, decomposing them into their lower-level
components and iterating until the desired level of detail is achieved. Top-down design
methods often result in stepwise refinement. Starting from an abstract design, in each step the
design is refined to a more concrete level, until we reach a level where no more refinement is
needed and the design can be implemented directly.
A bottom-up design approach starts with designing the most basic or primitive components
and proceeds to higher-level components that use these lower-level components. Bottom-up
methods work with layers of abstraction. Starting from the very bottom, operations that
provide a layer of abstraction are implemented. The operations of this layer are then used to
implement more powerful operations and a still higher layer of abstraction, until the stage is
reached where the operations supported by the layer are those desired by the system.
A top-down approach is suitable only if the specifications of the system are clearly known
and the system development is from scratch. Hence, it is a reasonable approach if a waterfall
type of process model is being used. However, if a system is to be built from an existing
system, a bottom-up approach is more suitable, as it starts from some existing components.
So, for example, if an iterative enhancement type of process is being followed, in later
43
Srinivas Institute of Management Studies BCA V sem
iterations, the bottom-up approach could be more suitable (in the first iteration a top-down
approach can be used.) Pure top-down or pure bottom-up approaches are often not practical.
A common approach to combine the two approaches is to provide a layer of abstraction.
4.2.1 Coupling
Two modules are considered independent if one can function completely without the
presence of other. If two modules are independent, they are solvable and modifiable
separately. However, all the modules in a system cannot be independent of each other, as they
must interact so that together they produce the desired behavior of the system. The more
connections between modules more knowledge about one module is required to understand or
solve the other module. Hence, the fewer and simpler the connections between modules, the
easier it is to understand one without understanding the other.
Coupling between modules is the strength of interconnections between modules or a measure
of interdependence among modules. In general, the more we must know about module A in
order to understand module B, the more closely connected A is to B; "Highly coupled"
modules are joined by strong interconnections, while "loosely coupled" modules have weak
interconnections. Independent modules have no interconnections. To solve and modify a
module separately, we would like the module to be loosely coupled with other modules. The
choice of modules decides the coupling between modules. Coupling is an abstract concept
and is not easily quantifiable. So, no formulas can be given to determine the coupling
between two modules. However, some major factors can be identified as influencing coupling
between modules. Among .them the most important are the type of connection between
modules, the complexity of the interface, and the type of information flow between modules.
Coupling increases with the complexity of the interface between modules. To keep coupling
low we would like to minimize the number of interfaces per module and the complexity of
each interface. An interface of a module is used to pass information to and from other
modules. Coupling would increase if a module is used by other modules via an indirect and
obscure interface, like directly using the internals of a module or using shared variables.
Complexity of the interface is another factor affecting coupling. The more complex each
interface is, the higher will be the degree of coupling. For example, complexity of the entry
interface of a procedure depends on the number of items being passed as parameters. For
44
Srinivas Institute of Management Studies BCA V sem
example, if a field of a record is needed by a procedure, often the entire record is passed,
rather than just passing that field of the record. By passing the record we are increasing the
coupling unnecessarily. Essentially, we should keep the interface of module as simple and
small as possible.
The type of information flow along the interfaces is the third major factor affecting coupling.
There are two kinds of information that can flow along an interface: data or control, Passing
or receiving control information means that the action of the module will depend on this
control information, which makes it more difficult to understand the module and provide its
abstraction. Transfer of data information means that a module passes as input some data to
another module and gets in return some data as output. This allows a module to be treated as
a simple input output function that performs some transformation on the input data to produce
the output data. In general, interfaces with only data communication result in the lowest
degree of coupling, followed by interfaces that only transfer control data. Coupling is
considered highest if the data is hybrid, that is, some data items and some control items are
passed between modules.
4.2.2 Cohesion
With cohesion, we are interested in determining how closely the elements of a module are
related to each other. Cohesion of a module represents how tightly bound the internal
elements of the module are to one another. Cohesion and coupling are clearly related.
Usually, the greater the cohesion of each module in the system, the lower the coupling
between modules is. There are several levels of cohesion:
- Coincidental - Logical - Temporal -Procedural
- Communicational - Sequential - Functional.
Coincidental is the lowest level, and functional is the highest. Functional binding is much
stronger than the rest, while the first two are considered much weaker than others.
Coincidental cohesion occurs when there is no meaningful relationship among the elements
of a module. Coincidental cohesion can occur if an existing program is modularized by
chopping it into pieces and making different pieces modules. If a module is created to save
duplicate code by combining some part of-code that Interface occurs at many different places,
that module is likely to have coincidental cohesion. In this situation, the statements in the
module have no relationship with each other, and if one of the modules using the code needs
to be modified and this modification includes the common code, it is likely that other
modules using the code do not want the code modified. Consequently, the modification of
this "common module" may cause other modules to behave incorrectly. It is poor practice to
create a module merely to avoid duplicate code.
A module has logical cohesion if there is some logical relationship between the elements of
a module, and the elements perform functions that fall in the same logical class. A typical
example of this kind of cohesion is a module that performs all the inputs or all the outputs. In
such a situation, if we want to input or output a particular record, we have to somehow
convey this to the module. Often, this will be done by passing some kind of special status
flag, which will be used to determine that statements to execute in the module. This results in
45
Srinivas Institute of Management Studies BCA V sem
hybrid information flow between modules, which is generally the worst form of coupling
between modules. Logically cohesive modules should be avoided, if possible.
Temporal cohesion is the same as logical cohesion, except that the elements are also related
in time and are executed together. Modules that perform activities like "initialization," "clean-
up," and "termination" are usually temporally bound. Temporal cohesion is higher than
logical cohesion, because the elements are all executed together. This avoids the problem of
passing the flag, and the code is usually simpler.
A procedurally cohesive module contains elements that belong to a common procedural
unit. For example, a loop or a sequence of decision statements in a module may be combined
to form a separate module.
A module with communicational cohesion has elements that are related by a reference to the
same input or output data. That is, in a communicational bound module, the elements are
together because they operate on the same input or output data. An example of this could be a
module to "print and punch record. Communicational cohesive modules may perform more
than one function. by a reference to the same input or output data. An example of this could
be a module to "print and punch record."
When the elements are together in a module because the output of one forms the input to
another, we get sequential cohesion. If we have a sequence of elements in which the output
of one forms the input to another, sequential cohesion does not provide any guidelines on
how to combine them into modules. A sequentially bound module may contain several
functions or parts of different functions. Sequentially cohesive modules bear a close
resemblance to the problem structure.
Functional cohesion is the strongest cohesion. In a functionally bound module, all the
elements of the module are related to performing a single function. By function, we do not
mean simply mathematical functions; modules accomplishing a single goal are also included.
Functions like "compute square root" and "sort the array" are clear examples of functionally
cohesive modules.
How does one determine the cohesion level of a module? There is no mathematical formula
that can be used. We have to use our judgment for this. A useful technique for determining if
a module has functional cohesion is to write a sentence that describes fully and accurately,
the function or purpose of the module. The following tests can then be made:
1. If the sentence is a compound sentence, if it contains has more than one verb, the
module is probably performing more than one function, and it probably has sequential
or communicational cohesion.
2. If the sentence contains words relating to time, like "first," "next," "when" and "after",
the module probably has sequential or temporal cohesion.
3. If the predicate of the sentence does not contain a single specific object following the
verb (such as "edit all data") the module probably has logical cohesion.
4. Words like "initialize," and "cleanup" imply temporal cohesion.
5. Modules with functional cohesion. can always be described by a simple sentence.
46
Srinivas Institute of Management Studies BCA V sem
main()
main
{
int sum, n, N, a[MAX];
readnums(a, &N); sort(a, N); scanf(&n); a, n. sum
a, n. a
sUm = add_n(a, n); printf(sum); a, n.
}
readnums(int a[], int *N) readnums sort add_n
{---
--- x, y. x, y.
}
sort(int a[], int N)
{ switch
if (a[i] > a[t]) switch(a[i], a[t]);
} Figure 4.1: The structure of the chart
/* Add the first n numbers of a */ of the sort program
add_n(int a[], int n)
{ ---
---
}
47
Srinivas Institute of Management Studies BCA V sem
There are some situations where the designer may wish to communicate certain procedural
information explicitly, like major loops and decisions. Such information can also be in a
structure chart. A loop can be represented by a looping arrow. In Figure given below, module
A calls module C and D repeatedly. All the subordinate modules activated within a common
loop are enclosed in the same looping arrow.
Major decisions can be represented similarly. For example, if the invocation of modules C
and D in module A depends on the outcome of some decision, that is represented by a small
diamond in the box for A, with the arrows joining C and D coming out of this diamond, as
shown in Figure.
A A
B C D B C D
Modules in a system can be categorized into few classes. There are some modules that obtain
information from their subordinates and then pass it to their superiordinate. This kind of
module is an input module. Similarly, there are output modules that take information from
their superiordinate and pass it on to its subordinates. As the name suggests, the input and
output modules are typically used for input and output of data The input modules get the data
from the sources and get it ready to be processed, and the output modules take the output
produced and prepare it for proper presentation to the environment.
Then there are modules that exist solely for the sake of transforming data into some other
form. Such a module is called a transform module. Most of the computational modules
typically fall in this category. Finally, there are modules whose primary concern is managing
the flow of data to and from different subordinates. Such modules are called coordinate
modules. The structure chart representation of the different types of modules is shown in
Figure 4.3. A module can perform functions of more than one type of module.
Input
Output
Module
Module
x y
y
48
Transform
Module
Srinivas Institute of Management Studies BCA V sem
Coordinate
Module Composite
Module
y
x x
A structure chart is very useful while creating the design. That is a designer can make
effective use of structure charts to represent the models creating while he is designing.
However, it is not very useful for representing the final design, as it does not give all the
information needed about the design. For example, it does not specify the scope, structure of
data, specification of each module, etc
4.3.2. Specifications
A design document is the means by which the design is communicated; it should contain all
information relevant to future phases. A design specification should contain
1. Problem specification
2. Major data structures
3. Modules and their specifications
4. Design decisions
Module specification is the major part of system design specification. All modules in the
system should be identified when the system design is complete, and these modules should be
specified in the document. During system design only the module specification is obtained,
because the internal details of the modules arc defined later. To specify a module, the design
document must specify (a) the interface of the module (all data items, their types, and
whether they are for input and/or output), (b) the abstract behavior of the module (what the
module does) by specifying the module's functionality or its input/output behavior, and (c) all
other modules used by the module being specified-this information is quite useful in
maintaining and understanding the design.
reached. Factoring is the process of decomposing a module so that the bulk of its work is
done by its subordinates. There are four major steps in this strategy:
1. Restate the problem as a data flow diagram
2. Identify the input and output data elements
3. First-level factoring
4. Factoring of input, output, and transform branches
4.4.1. Restate the Problem as a Data Flow Diagram
To use the SDM, the first step is to construct the data flow diagram for the problem there is a
fundamental difference between the DFDs drawn during requirements analysis and during
structured design. In the requirements analysis, a DFD is drawn to model the problem
domain. The analyst has little control over the problem, and hence his task is to extract from
the problem all the information and then represent it as a DFD. During design, the designer is
dealing with the solution domain; the designer has complete freedom in creating a DFD that
will solve the problem stated in the SRS.
The general rules of drawing a DFD remain the same As an example, consider the problem of
determining the number of different words in an input file. The data flow diagram for this
problem is shown n Figure 4.4 This problem as only one input data stream, the input file,
while the desired output is the count of different words n the file. o transform the input to the
desired output, the first thing we do is form a list of all the words in the file. It is best to then
sort the list, as this will make identifying different words easier. This sorted list is then used
to count the number of different words and the output of this transform is the desired count,
which is then printed. This sequence of data transformation is what we have in the data flow
diagram.
mal mao
Count the
w. l number of
Get Sort Print
input word different
the list the
List words count
4.4.2. Identify the Most Abstract Input and Output Data Elements
Most systems have some basic transformations that perform the required operations.
However, in most cases the transformation cannot be easily applied to the actual physical
input and produce the desired physical output. Instead, the input is first converted into a form
on which the transformation can be applied with ease. Similarly, the main transformation
modules often produce outputs that have to be converted into the desired physical output. The
goal of this second step is to separate the transforms in the data flow diagram. For this
separation, once the data flow diagram is ready, the next step is to identify the highest
abstract level of input and output.
The most abstract input data elements(MAI) are those data elements in the data flow diagram
that are furthest removed from the physical inputs but it can still be considered inputs to the
50
Srinivas Institute of Management Studies BCA V sem
system. The most abstract input data elements often have little resemblance to the actual
physical data. These are often the data elements obtained after operations like error checking,
data validation, proper formatting, and conversion are complete.
Similarly, we identify the most abstract output data elements (MAO) by starting from the
outputs in the data flow diagram and traveling toward the inputs. These are the data elements
that are most removed from the actual outputs but can still be considered outgoing. The MAO
data elements may also be considered the logical output data items.
There will usually be some transforms left between the most abstract input and output data
items. These central transforms perform the basic transformation for the system, taking the
most abstract input and transforming it into the most abstract output.
Consider the data flow diagram shown in Figure 5.5. The arcs in the data flow diagram are
the most abstract input and most abstract output. The choice of the most abstract input is
obvious. We start following the input. First, the input file is converted into a word list, which
is essentially the input in a different form. The sorted word list is still basically the input, as it
is still the same list, in a different order. This appears to be the most abstract input because
the next data (i.e., count) is not just another form of the input data. The choice of the most
abstract output is even more obvious; count is the natural choice (a data that is a form of input
will not usually be a candidate for the most abstract output). Thus we have one central
transform, count-the-number-of-different-words, which has one input and one output data
item.
Main
Count No. of
different words Figure 4.5: First-level factoring
In this example, there is one input module, which returns the sorted word list to the main
module. The output module takes from the main module the value of the count. There is only
one central transform in this example, and a module is drawn for that. Note that the data
items traveling to and from this transformation module are the same as the data items going
in and out of the central transform. The main module is the overall control module, which
win form the main program or procedure in the implementation of the design. It is a
coordinate module that invokes the input modules to get the most abstract data items, passes
these to the appropriate transform modules, and delivers the results of the transform modules
to other transform modules until the most abstract data items are obtained. These are then
passed to the output modules.
52
Srinivas Institute of Management Studies BCA V sem
The factoring of he input module get-sorted-list in the first-level structure is shown in Figure
4.6. The transform producing the input returned by this module (i.e., the sort transform) is
treated as a central transform. Its input is the word list. Thus, in the first factoring we have an
input module to get the list and a transform module to sort the list. The input module can be
factored further, as the module needs to perform two functions, getting a word and then
adding it to the list. Note that the looping arrow is used to show the iteration. The factoring of
the output modules is symmetrical to the factoring of the input modules. For an output
module we look at the next transform to be applied to the output to bring it closer to the
ultimate desired output. This now becomes the central transform, and an output module is
created for each data stream. Factoring the central transform is essentially an exercise in
functional decomposition and will depend on the designers' experience and judgment. One
way to factor a transform module is to treat it as a problem in its own right and start with a
data flow diagram for it. The factoring of the central transform count-the-number-of-
different-words is shown in Figure 4.7.
Count number
of different
words
w.list count
word count
Get a word Increment count
word flag
Figure 4.7: Factoring the central transform module
Same as Previous
This was a relatively simple transform, and we did not need to draw the data flow diagram.
To determine the number of words, we have to get a word repeatedly, determine if it is the
same as the previous word (for a sorted list, this checking is sufficient to determine if the
word is different from other words), and then count the word if it is different. For each. of the
three different functions, we have a subordinate module, and we get the structure shown in
Figure 4.7.
function and can therefore be broken into many modules, each implementing a different
function. On the other hand, modules that are too small may not require any additional
identity and can be combined with other modules.
However, the decision to split a module or combine different modules should not be based on
size alone. Cohesion and coupling of modules should be the primary guiding factors. A
module should be split into separate modules only if the cohesion of the original module was
low, the resulting modules have a higher degree of cohesion, and the coupling between
modules doesn’t increase. Similarly, two or more modules should be combined only if the
resulting module has a high degree of cohesion and the coupling of the resulting module is
not greater than the coupling of the sub-modules. In general, if the module should contain
LOC between 5 and 100. Above 100 and less than 5 LOC is not desirable.
Another factor to be considered is “fan-in” and “fan-out” of modules. Fan-in of a module is
the number of arrows coming towards the module indicating the number of superiordinates.
Fan-out of a module is the number of arrows going out of that module; indicating the number
of subordinates for that module. A very-high fan-out is not desirable as it means that the
module has to control and co-ordinate too many modules. Whenever possible, fan-in should
be maximized. In general, the fan-out should not be more than 6.
Another important factor that should be considered is the correlation of the scope of effect
and scope of control. The scope of effect of a decision (in a module) is collection of all the
modules that contain any processing that is conditional that decision or whose invocation is
dependent on the outcome of the decision; The scope of control of a module is the module
itself and all its subordinates (just the immediate subordinates). The system is usually simpler
when the scope of effect of a decision is a subset of the scope of control of the module in
which decision is located.
54
Srinivas Institute of Management Studies BCA V sem
incorrect or need clarification. The member asks questions and the chief designer tries to
explain the situation. During the course of discussion, design errors if any are revealed.
It should be kept in mind that the aim of the meeting is to uncover design errors and not to try
to fix them. Fixing is done later. Also, the psychological frame of mind should be healthy and
the designer should not be put in a defensive position. The meeting ends with the list of
action items which are later acted on by the design team.
4.5.2. Automated Cross-Checking
If the design is expressed in a language designed for machine processing, most consistency
checking can be automated. For example, if a language like PDL is used, the design can be
compiled to check for consistency.
Assignment 4
Part-A
1. W hat is a design methodology?
2. Mention different type of errors that occurs in an SRS.
3. What is data abstraction? Why it is needed.
4. What is functional abstraction?
5. What is top down and bottom up design approach?
6. What is stepwise refinement?
7. What is coupling and cohesion?
8. What are the factor that influencing coupling.
9. Mention different levels of cohesion.
10. Mention different types of modules in a structure chart.
11. How iteration and decision are represented in a structure chart. Give example.
12. List the four major activities in system design methodology.
13. What are most abstract input and most abstract output?
14. What is the automated cross-checking?
Part-B
1. What is coupling? Explain the factors that affect coupling.
2. List and explain different levels of cohesion.
3. With an example, explain structure chart.
4. Explain the different types of modules used in structure chart.
5. Write a note on SDM strategy.
6. Write a note on verification in the detailed design phase.
55
Srinivas Institute of Management Studies BCA V sem
Unit-3
Chapter-5
Detailed Design
In system design we concentrate on the modules in a system and how they interact with each
other. The specifications of a module are often communicated by its name, the English phrase
with which we label the module. In previous examples, we have used words like "sort" and
"assign" to communicate the functionality of the modules. In a design document, a more
detailed specification is given by explaining in natural language what a module is supposed to
do. These non-formal methods of specification can lead to problems during coding, because,
the coder is a different person from the designer. Even if the designer and the coder are the
same person, problems can occur, as the design can take a long time, and the designer may
not remember precisely what the module is supposed to do.
The first step before the detailed design or code for a module can be developed is that the
specification of the module be given precisely. Once the module is specified, the internal
logic for the module that will implement the given specifications can be decided.
56
Srinivas Institute of Management Studies BCA V sem
example, a function that finds the square root of a number may be designed to operate only
on the real numbers. In addition, it may require that inputs are positive real numbers.
If the inputs satisfy the desired constraints, the goal of a module is to produce outputs that
satisfy some constraints that are often related to the inputs. Hence, to specify the external
behavior of a module supporting functional abstraction, one needs to specify the inputs on
which the module operates, the outputs produced by the module, and the relationship of the
outputs to the inputs.
One method for specifying modules is based on pre and post-conditions. In this method
constraints on the input of a module were specified by a logical, assertion on the input state
called pre-condition. The output was specified as a logical assertion on the output state called
post-condition. As an example, consider a module sort to be written to sort a list L of integers
in ascending order. The pre- and post-condition of this module are:
Pre-condition: non-null L
Post-condition: for all i, 1<= i <= size(L), L[i] <= L[i + 1]
The specification states that if the input state for the module sort is non-null L, the output
state should be such that the elements of L are in increasing order. These specifications are
not complete. They only state that the final state of the list L (which is the output of the
module sort) should be such that the elements are in ascending order. It does not state
anything about the implicit requirement of the sort module that the final state of the list L
should contain the same elements as the initial list. In fact, this specification can be satisfied
by a module that takes the first element of the list L and copies it on all the other elements. A
variation of this approach is to specify assertions for the input and output states, but the
assertions for the output can be stated as a relation between the final state and the initial state.
In such methods, while specifying the condition on the output, the final state of an entity E is
referred to as Eprime (the initial state is referred by E itself). Using this notation, a possible
specification of the module sort is
sort (L: list of integers)
input: non-null L
output: for all i, 1<= i <= size(L),
L'[i] ~ L'[i+l] and
L' = permutation (L)
This specification, besides the ordering requirement, states that elements of the final list are a
permutation of elements of the initial list. This specification will be complete if the module is
to be designed only to operate on non-null lists. Often the modules check if the input satisfies
the desired constraints. If the constraints are not satisfied, it is treated as an exception
condition, and some special code is executed. If we want the module to handle exceptions, we
need to specify the exceptional behavior of the modules.
57
Srinivas Institute of Management Studies BCA V sem
and completely. PDL is particularly useful when using top-down refinement techniques to
design a system or a module.
5.2.1. PDL
PDL has an overall outer syntax of a structured programming language and has a vocabulary
of a natural language (English in our case). It can be thought of as "structured English".
Because the structure of a design expressed in PDL is formal, using the formal language
constructs, some amount of automated processing can be done on such designs. As an
example, consider the problem of finding the minimum and maximum of a set of numbers in
a file and
outputting minmax (infile) these
numbers in ARRAY a PDL
as shown in DO UNTIL end of input
Figure given READ an item to a
below. ENDDO
max, min := first item of a
DO FOR each item in a
IF max < item THEN set max to item
IF min > item THEN set min to item
ENDDO
END
PDL description of the minmax program.
Notice that in the PDL program we have the entire logic of the procedure, but little about the
details of implementation in a particular language. To implement this in a language, each of
the PDL statements will have to be converted into programming language statements. With
PDL, a design can be expressed in whatever level of detail that is suitable for the problem.
One way to use PDL is to first generate a rough outline of the entire solution at a given level
of detail. When the design is agreed on at this level, more detail can be added. This allows a
successive refinement approach, and can save considerable cost by detecting the design errors
early during the design phase. It also aids design verification by phases, which helps in
developing error-free designs. The structured outer syntax of PDL also encourages the use of
structured language constructs while implementing the design. The basic constructs of PDL
are similar to those of a structured language.
PDL provides IF construct which is similar to the if-then-else construct of Pascal. Conditions
and the statements to be executed need not be stated in a formal language. For a general
selection, there is a CASE statement. Some examples of The DO construct is used to indicate
repetition. The construct is indicated by:
58
Srinivas Institute of Management Studies BCA V sem
DO iteration-criteria
one or more statements
ENDDO
The iteration criteria can be chosen to suit the problem, and unlike a formal programming
language, they need not be formally stated. Examples of valid uses are:
DO WHILE there are characters in input file
DO UNTIL the end of file is reached
A variety of data structures can be defined and used in PDL such as lists, tables, scalar, and
integers. Variations of PDL, along with some automated support, are used extensively for
communicating designs.
59
Srinivas Institute of Management Studies BCA V sem
An Example: Let us consider the problem of counting different words in a text file. Suppose
that the COUNT module is specified whose job is to determine the count of different words.
During detailed design we have to determine the logic of this module so that the
specifications are met. We will use the stepwise refinement method for this. For specification
we will use PDL, adapted to C-style syntax. A simple strategy for the first step is shown
bellow (Figure(a)). The primitive operations used in this strategy are very high-level and need
to be further refined (as shown in figure (b)).
Figure (a): Strategy for the first step in Figure (b): Refinement of the reading
stepwise refinement operation.
Specifically, there are three operations that need refinement. These are
(1) read file into the word list, whose purpose is to read all the words from the file and
create a word list,
(2) sort(wl), which sorts the word list in ascending order, and
(3) count different words from a sorted word list. So far, only one data structure is
defined: the word list. As refinement proceeds, more data structures might be needed.
In the next refinement step, we should select one of the three operations to be refined-and
further elaborate it. In this step we will refine the reading procedure. One strategy of
implementing the read module is to read words and add them to the word list. This is shown
in Figure (b). For the next refinement step we select the counting function. A strategy for
implementing this function is shown in Figure (c). Similarly, we can refine the sort function.
Once these refinements are done, we have a design that is sufficiently detailed and needs no
further refinement. For more complex problems many successive refinements might be
needed for a
single int different_words (word_list wl)
operation. {
word last, cur;
int cnt;
last = first word in wl
cnt = 1;
while not end of list {
cur = next word from wl
if (cur <> last) {
cnt = cnt + 1;
last = cur;
} 60
}
return (cnt)
}
Figure (c). Refinement of the function different_words.
Srinivas Institute of Management Studies BCA V sem
5.3. Verification
There are a few techniques available to verify that the detailed design is consistent with the
system design. The focus of verification in the detailed design phase is on showing that the
detailed design meets the specifications laid down in the system design. Validating that the
system as designed is consistent with the requirements of the system is not stressed during
detailed design. The three verification methods we consider are design walkthroughs, critical
design review and consistency checkers.
61
Srinivas Institute of Management Studies BCA V sem
Design reviews and walkthroughs are manual processes; the people involved in the review
and walkthrough determine the errors in the design. If the design is specified in PDL or some
other formally defined design language, it is possible to detect some design defects by using
consistency checkers. Consistency checkers are essentially compilers that take as input the
design specified in a design language (PDL). Clearly, they cannot produce executable code
because the inner syntax of PDL allows natural language and many activities specified in the
natural language. However, the module interface specifications (which belong to outer
syntax) are specified formally. A consistency checker can ensure that any modules invoked or
used by a given module actually exist in the design and that the interface used by the caller is
consistent with the interface definition of the called module. It can also check if the used
global data items are defined globally in the design.
Assignment 5
Part-A
1. List the desirable properties that module specifications should have.
2. What is design walkthrough?
3. What is the purpose of critical design review?
4. What is PDL? Why it is useful.
Part-B
1. Explain module specifications in detailed design.
2. Explain PDL with suitable example.
3. Write a note on Logic/Algorithm design.
4. Explain the verification method of a detailed design.
5. What are the activities that are undertaken during critical design review?
6. Write a note on i. Design walkthroughs ii. Consistency checkers.
62
Srinivas Institute of Management Studies BCA V sem
Chapter-6
Coding
The goal of the coding or programming phase is to translate the design of the system
produced during the design phase into code in a given programming language, which can be
executed by a computer and that performs the computation specified by the design. The
coding phase affects both testing and maintenance profoundly. As we saw earlier, the time
spent in coding is a small percentage of the total software cost, while testing and maintenance
consume the major percentage. Thus, it should be clear that the goal during coding should not
be to reduce the implementation cost, but the goal should be to reduce the cost of later
phases, even if it means that the cost of this phase has to increase. In other words, the goal
during this phase is not to simplify the job of the programmer. Rather, the goal should be to
simplify the job of the tester and the maintainer. .
During implementation, it should be kept in mind that, the programs should not be
constructed so that they are easy to write, but so that they are easy to read and understand.
Top-down and bottom-up implementation should not be confused with top-down and bottom-
up design. Here, the design is being implemented, and if the design is fairly detailed and
complete, its implementation can proceed in either the top-down or the bottom-up manner,
even if the design was produced in a top-down manner. Which of the two is used mostly
affects testing. All large systems must be built by assembling validated pieces together. The
case with software systems is the same. Parts of the system have to first be built and tested
before putting them together to form the system. Because parts have to be built and tested
separately, the issue of top-down versus bottom-up arises.
.
63
Srinivas Institute of Management Studies BCA V sem
basic goal, as we have tried to emphasize, is to make the logic of the program simple to
understand. The basic objective of using structured constructs is to linearize the control flow
so that the execution behavior is easier to understand. In linearized control flow, if we
understand the behavior of each of the basic constructs properly, the behavior of the program
can be considered a composition of the behaviors of the different statements. Overall, it can
be said that structured programming, in general, leads to programs that are easier to
understand than unstructured programs.
65
Srinivas Institute of Management Studies BCA V sem
jump to" later statement) is more acceptable than a backward jump. Use of gotos for exit a
loop or for invoking error handlers is quite acceptable
Information Hiding: As discussed earlier, information hiding should be supported where
possible. Only the access functions for the data structures should be made visible while
hiding the data structure behind these functions.
User-Defined Types: Modern languages allow users to define data types when such facilities
are available, they should be exploited where applicable. For example, when working with
dates, a type can be defined for the day of the week. In Pascal, this is done as follows: type
days = (Man, Tue, Wed, Thur, Fri, Sat, Sun);
Variables can then be declared of this type. Using such types makes the program much
clearer than defining codes for each day and then working with codes.
Nesting: The different control constructs, particularly the if-then-else, can be nested. If the
nesting becomes too deep, the programs become harder to understand. In case of deeply
nested if-then-elses, it is often difficult to determine if statement to which a particular else
clause is associated. If possible, deep nesting should be avoided.
ifCl then Sl
else if C2 then S2
else if C3 then S3
else if C4 then S4;
If the different conditions are disjoint (as they often are), this structure can be converted into
the following structure:
ifC1 then Sl;
if C2 then S2;
if C3 then S3;
if C4 then S4;
This sequence of statements will produce the same result as the earlier sequence (if the
conditions are disjoint), but it is much easier to understand.
Module Size: A programmer should carefully examine any routine with very few statements
(say fewer than 5) or with too many statements (say more than 50). Large modules often will
not be functionally cohesive, and too-small modules might incur unnecessary overhead.
There can be no hard-and-fast rule about module sizes the guiding principle should be
cohesion and coupling.
Module Interface: A module with a complex interface should be carefully examined. Such
modules might not be functionally cohesive and might be implementing multiple functions.
As a rule of thumb, any module whose interface has more than five parameters should be
carefully examined and broken into multiple modules with a simpler interface if possible.
Program Layout: How the program is organized and presented can have great effect on the
readability of it. Proper indentation, blank spaces, and parentheses should be used to enhance
the readability of programs.
Side Effects: When a module is invoked, it sometimes has side effects of modifying the
program state beyond the modification of parameters listed in the module interface definition,
66
Srinivas Institute of Management Studies BCA V sem
for example, modifying global variables. Such side effects should be avoided where possible,
and if a module has side effects, they should be properly documented.
Robustness: A program is robust if it does something planned even for exceptional
conditions. A program might encounter exceptional conditions in such forms as incorrect
input, the incorrect value of some variable, and overflow. A program should try to handle
such situations. In general, a program should check for validity of inputs, where possible, and
should check for possible overflow of the data 5ll1lctures. If such situations do arise, the
program should not just "crash" or "core jump"; it should produce some meaningful message
and exit gracefully.
6.2 Verification
Verification of the output of the coding phase is primarily intended for detecting errors
introduced during this phase. That is, the goal of verification of the code produced is to show
that the code is consistent with the design it is supposed to implement. It should be pointed
67
Srinivas Institute of Management Studies BCA V sem
68
Srinivas Institute of Management Studies BCA V sem
An example of the data flow anomaly is the live variable problem, in which a variable is
assigned some value but then the variable is not used in any later computation. Such an
assignment to the variable is clearly redundant. Another simple example of this is having two
assignments to a variable without using the value of the variable between the two
assignments. In this case the first assignment is redundant. For example, consider the simple
case of the code segment shown in Figure 8.2. Clearly, the first assignment statement is
useless. Perhaps the programmer meant to say y := b in the second statement, and mistyped y
as x. In that case, detecting this anomaly and directing the programmer's attention to it can
save considerable effort in testing and debugging. In addition to revealing anomalies, data
flow analysis can provide valuable information for documentation of programs. For example,
data flow analysis can provide information about which variables are modified on invoking a
procedure in the caller program and the value of the variables used in the called procedure
(this can also be used to make sure that the interface of the procedure is minimum, resulting
in lower coupling). This information can be useful during maintenance to ensure that there
are no undesirable side effects of some modifications to a procedure.
Here there is only one path in the function, and this symbolic execution is equivalent to
checking for all possible values of x, y, and z. (Note that the implied assumption is that input
values are such that the machine will be able to perform the product and no overflow will
occur.) Essentially, with only one path and an acceptable symbolic result, we can claim that
the program is correct.
Path Conditions
In symbolic execution, when dealing with conditional execution, it is not sufficient to look at
the state of the variables of the program at different statements, as a statement will only be
executed if the inputs satisfy certain conditions in which the execution of the program will
follow a path that includes the statement. To capture this concept in symbolic execution, we
require a notion of "path condition." Path condition at a statement gives the conditions the
inputs must satisfy for an execution to follow the path so that the statement will be executed.
Path condition is a Boolean expression over the symbolic inputs that never contain any
program variables. It will be represented in a symbolic execution by pc. Each symbolic
execution begins with pc initialized to true. For example, symbolic execution of an if
statement of the form if C then S1 else S2 will require two cases to be considered,
corresponding to the two possible paths; one where C evaluates to true and S1 is executed,
and the other where C evaluates to false and S2 is executed. For the first case we set the path
condition pc to
pc pc ^ C
This is the path condition for the statements in S1. For the second case we set the path
condition to pc pc^ ~ C which is the path condition for statements in S2.
On encountering the if statement, symbolic execution is said to split into two executions: one
following the then part, the other following the else part. Both these paths are independently
executed, with their respective path conditions. However, if at any if statement we can show
that pc implies C or ~C, we do not need to follow both paths, and only the relevant path need
be executed. Let us consider an example involving if statements. Figure 8.5 shows a program
to determine the maximum of three numbers. The trace of the symbolic execution:
1. function max (x, y, z: integer) : integer
2. begin
3. if (x<=y) then
4. max:=y;
5. else
6. max:=x
7. if max <z then
8. max:=z;
9. end;
the code for function max
70
Srinivas Institute of Management Studies BCA V sem
T T
3 4 7 8 9
F
6 8
T
7 8 9
The different paths followed during symbolic execution can be represented by an "execution
tree." A node in this tree represents the execution of a statement, while an arc represents the
transition from one statement to another. For each if statement, there are two arcs from the
node corresponding to the if statement, one labeled with T (true) and the other with F (false),
for the then and else paths. At each branching, the path condition is also often shown in the
tree.
6.2.4Proving Correctness
In proof of correctness, the aim is to prove a program correct. So, correctness is directly
established, unlike the other techniques in which correctness is never really established but is
implied by the absence of detection of any errors. Proofs are more valuable during program
construction, rather than after the program have been constructed. Proving while developing a
program may result in more reliable programs that can be proved more easily.
In this level, different modules are tested against the specification produced during design for
the modules. Unit testing is essentially for verification of the code produced during the code
phase. That is, the goal of this testing is to test the internal logic of the modules. Due to its
close association with coding the coding phase is frequently called ”coding and unit testing”
.The goal of unit testing is to test modules or “units”, not the entire software system.
Assignment 6
Part-A
71
Srinivas Institute of Management Studies BCA V sem
Part-B
1. Write a note on top down and bottom up approaches in coding.
2. Explain the concept of structured programming.
3. Explain the information hiding with an example.
4. Explain the various programming style.
5. Explain internal documentation.
6. Explain the symbolic execution and execution tree.
7. Explain static analysis and its uses.
8. List out the various items in the checklist while reviewing the code.
72
Srinivas Institute of Management Studies BCA V sem
Unit 4
Chapter-7
7.1 INTRODUCTION
In software development process, errors can be injected at any stages during development.
We have already discussed about various techniques for detecting and eliminating errors that
originate in that phase. However, no method is perfect and it is expected that some errors of
the earlier phases will finally reaches to the coding phase. This is because most of the
verification methods of earlier phases are manual. Hence the code developed during coding
activity is likely to have some requirement errors and design errors, in addition to errors
introduced during the coding activity.
During testing, the program to be tested is executed with a set of test cases and the output of
the program for the test cases is evaluated to determine if the program is performing as
expected. Form this it is clear that testing is used to find out errors rather than to tell the
exact nature of the error. Also, the success of the testing process clearly depends upon the
test cases used.
Testing is a complex process. In order to make the process simpler, the testing activities are
broken into smaller activities. Due to this, for a project, incremental testing is generally
performed. In incremental testing process, the system is broken into set of subsystems and
these subsystems are tested separately before integrating them to form the system for system
testing.
Definitions of testing
• The process of analyzing a software item to detect the differences between existing
and required conditions (i.e., bugs) and to evaluate the features of the software items
(IEEE 1993)
• The process of analyzing a program with the intent of finding errors.
(Myers 1979)
73
Srinivas Institute of Management Studies BCA V sem
A test oracle is a mechanism, different from the program itself that can be used to check the
correctness of the output of the program for the test cases. Conceptually, we can consider
testing a process in which the test cases are given to the test oracles and the program under
testing. The output of the two is then compared to determine if the program behaved
correctly for the test cases.
Figure 7.1 Illustrates this step.
74
Srinivas Institute of Management Studies BCA V sem
Test oracles generally use the system specifications of the program to decide what the correct
behavior of the program should be. To help the oracle to determine the correct behavior, it is
important that the behavior of the system be unambiguously specified and the specification
itself error free.
The Bottom-up approach starts from the bottom of the hierarchy. First the modules at the
lowest level, which have no subordinates, are tested. Then these modules are combined with
higher level modules for testing. At any stage of testing all the subordinate modules exist and
have been tested earlier. To perform bottom-up testing, drivers are needed to setup the
appropriate environment and invoke the module. It is the job of the driver to invoke the
module under testing with the different set of test cases.
75
Srinivas Institute of Management Studies BCA V sem
Both Top-down and Bottom-up approaches are incremental; starting with testing single
module and then adding untested modules to those that have been tested, until the entire
system is tested.
The range and type of test cases to be prepared in order to perform testing depends upon test
criterion. A test criterion is the condition that must be satisfied by a set of test cases.
The criterion becomes a basis for test selection. For example: If the criterion is the all
statements in the program be executed at least once during testing, then a set of test cases T
satisfies this criterion for a program P if the execution of P with T ensure that each statement
in P is executed at least once.
The functional testing procedure is exhaustive testing. One criterion for generating test cases
is to generate them randomly. This strategy has little chance of resulting in a set of test cases
that is close to optimal. Hence, we need some other criterion for selecting test cases. There
are no formal rules for designing test cases for functional testing. However, there are a
number of methods or heuristics that can be; used to select test cases. They are
77
Srinivas Institute of Management Studies BCA V sem
Hence, we can say that a boundary value test case is a set of input that lies on the edge or
boundary of a class of input data or that generates output that lies at the boundary of a class
of output data.
Cause-Effect Graphing
The major problem with the equivalence class portioning and boundary value analysis is that
they consider each input separately. They do not consider combinations of input.
One way to exercise combinations of different input conditions is to consider all valid
combinations of equivalence classes of input conditions.
Example
Suppose that for a bank database there are two commands allowed:
Credit acct-number transaction-amount
Debit acct-number transaction-amount
The requirements are that if the command is credit and acct-number is valid, then the account
is credited. If the command is debit, the acct-number is valid. and the transaction amount is
valid then the amount is debited. If invalid command is given or the account number is
78
Srinivas Institute of Management Studies BCA V sem
invalid, or the debit amount is not valid, a suitable error message is generated. We identify
the following causes and effects from the above requirements
Causes:
C1 Command is credit.
C2. Command is debit
C3. Account number is valid.
C4. Transaction amount is valid.
Effects:
E1. Print” invalid command”
E2. Print “invalid account number “.
E3. Print “Debit amount no valid”
E4. Debit account.
E5. Credit account.
The graph representation of Causes-Effect has shown in figure 6.2
79
Srinivas Institute of Management Studies BCA V sem
To test the structure of a program, structural testing methods are used. Several criterions
have been proposed for structural testing. These criterions are precise and based on program
structures. There are three different approaches to structural testing. They are
• Control flow based testing.
• Data flow based testing
• Mutation testing.
In this method, the control flow graph of a program is considered and coverage of various
aspects of the graph is specified as criteria. A control flow graph G of a program P has set of
nodes and edges. A node in this graph represents a block of statements that are always
executed together. An edge (I, J) from node I to node J represents a possible transfer of
control after executing he last statement of the block represented by node I to the first
statement of the block represented by node J. A node corresponding to a block whose first
statement is the start statement of P is called start node of G. Similarly, the node
corresponding to a block whose last statement is an exit statement is called an exit node.
Now let us consider control flow-based criteria. The simplest coverage criteria are statement
coverage, which requires that each statement of the program be executed at least once during
testing. This is called all node criterions. This coverage criterion is not very strong and can
leave errors undetected. For example, if there is an if statement in the program without else
part, the statement coverage criterion for this statement will be satisfied by a test case that
evaluates the condition to true. No test case is needed that ensures that the condition in the if
statement evaluates to false. This is a major problem because decisions in the programs are
potential sources of errors.
80
Srinivas Institute of Management Studies BCA V sem
Another coverage criterion is branch coverage, which requires that each edge in the control
flow graph be traversed at least once during testing. In other words, branch coverage requires
that each criterion in the program be evaluated to true and false values at least once during
testing. Testing based on branch coverage criterion is known as branch testing. Problem
with branch coverage comes if a decision has many conditions in it j(consisting of Boolean
expression with Boolean operators “and” and “or” ). In such a situation, a decision can be
evaluated to true and false without actually exercising all conditions.
It has been observed that there are many errors whose presence is not detected by branch
testing. This is because some errors are related to some combinations of branches and their
presence is revealed by an execution that follows the path that includes those branches.
Hence a more general coverage criterion which covers all the paths is required. This is called
path coverage criterion and testing based on this criterion is called path testing. But the
problem with this criterion is that programs that contain loops can have an infinite number of
possible paths. Some methods have been suggested to solve this problem. One such method
is to limit the number of paths .
In data flow-based testing, besides the control flow, information about where the variables
are defined and where the definitions are used is also used to specify the test cases. The basic
idea behind data flow-based testing is to make sure that during testing, the definitions of
variables and their subsequent use is tested. For data flow-based testing, a definition-use
graph for the program is first constructed from the control flow graph of the program. A
statement in a node in the flow graph representing a block code has variable occurrences in it.
A variable occurrence can be one of the following here types:
• Def represents the definition of the variable. Variables on the left hand side of an
assignment statement are the one getting defined.
• C- use represents computational use of a variable. Any statement that uses the value of
variables for computational purposes is said to be making use c-use of the variables. In
an assignment statement, all variables on the right hand side have a c-use occurrence.
81
Srinivas Institute of Management Studies BCA V sem
• P-use represents predicate use. These are all the occurrences of the variables in a
predicate, which is used for transfer control.
Mutation Testing
Mutation testing is another type of structural testing and does not take path-based approach.
Instead, it takes the program and creates many mutants of it by making simple changes in the
program. The goal of testing is to make sure that during the course of testing, each mutant
produces an output different from the output of the original program.
In mutation testing, first a set of mutants for a program under test P is prepared. Applying
mutation operators on he text of P does this. The set of mutation operators depends on the
language in which P is written. In general, a mutation operator makes a small unit change in
the program to produce a mutant. Examples for mutant operators are: replace an arithmetic
operator with some other arithmetic operator, change an array reference (say from I to J),
replace a constant with another constant, and replace variable with some special value. Each
application of a mutation operator results in one mutant.
Mutation testing of a program P proceeds as follows: First a set of test cases T is prepared by
the tester, and P is tested by the set of test cases in T. If P fails, then T reveals some errors
and they are corrected. If P does not fail, then it could mean that either the program P is
correct or that P is not correct. But T is not sensitive enough to detect the fault in p. To rule
out the latter possibility, the sensitivity of T is evaluated through mutation testing and more
test cases are added to T until the set is considered sensitive enough for most faults.
Testing is used to detect faults introduced during specification and design stages as well as
coding stages. Due to this, different levels of testing are used in the testing process. Each
level of testing aims to test different aspects of the system. The basic levels of testing are.
• Unit testing
82
Srinivas Institute of Management Studies BCA V sem
• Integration testing.
• System testing.
• Acceptance testing.
The relation of the faults introduced in different phases, and the different levels of testing are
shown in figure 6.3.
Unit testing
In this level, different modules are tested against the specification produced during design for
the modules. Unit testing is essentially for verification f the code produced during the code
phase. That is, the goal of this testing is to test
the internal logic of the modules. Due to its close association with coding the coding phase
is frequently called ”coding and unit testing” As the focus of this testing level is testing the
code, structural testing is best suited for this level.
Integration testing
In this level, many unit-tested modules are combined into subsystems, which are then tested.
The goal of this testing level is to see if the modules can be integrated properly. In other
83
Srinivas Institute of Management Studies BCA V sem
words the emphasis on testing the interfaces between the modules. This testing activity can
be considered testing the design
System testing
Here the entire software is tested. The reference document for this process is the
requirements document. The goal is to see if the software meets its requirements. This is
essentially validation exercise, and in many situations it is the only validation activity.
Acceptance testing.
Acceptance testing is performed using real data of the client to demonstrate that software is
working satisfactorily. Testing here focuses on the external behavior of the system. Internal
logic is not important for this testing. Hence, functional testing is performed at this level.
The above levels of testing are performed when the system is being built. We use another
type of testing during the maintenance of the software. It is known as regression testing.
Regression testing is required when modification is made on the existing system. Software is
said to be modified when we add one or mode modules to it or some of the components (or
modules) deleted from it, Clearly, the modified software needs to be tested to make sure that
it works properly.
In general, testing commences with a test plan and terminates with acceptance testing. A
Test plan is a general document for the entire project that defines the scope, approach to be
taken and the schedule of testing as will as identifies the test items for the entire testing
process. It also contains information of the personnel responsible for the different activities
of testing. The test planning can be done well before the actual testing commences and can
be done in parallel with coding and design phases.
The inputs for forming the test plan are (1) Project plan, (2) requirements document, and (3)
system design document. The project plan is needed to make sure that the test plan is
consistent with the overall plan for the project and the testing schedule matches that of the
84
Srinivas Institute of Management Studies BCA V sem
project plan. The requirements document and the design document are the basic documents
used for selecting the test units and deciding the approaches to be used during testing. A test
plan should contain the following:
• Test unit specification
• Features to be tested
• Test deliverables
• Schedule.
• Personnel Allocation
One of the most important activities of the test plan is to identify the test units A test unit is a
set of one or more modules, together with associated data, that are from single computer
program and that are object of testing. A test unit can occur at any level and can contain from
a single module to the entire system.
Features to be tested include all software features and combinations of features that should be
tested. A software feature is a software characteristic specified or implied by the
requirements or design document. These may include functionality, Performance, design
constraints, and attributes.
Testing deliverables should be specified in the test plan before the actual testing begins.
Deliverables could be a list of test cases that were used, detailed results of testing, test
summary report, log, and data about the code coverage.
The schedule specifies the amount of time and effort to be spent on different activities of
testing and testing of different units that have been identified.
Personnel allocation identifies the persons responsible for performing the different activities.
existing software and maintainers spend most of their time trying to understand the software
they have to modify. Understanding the software means that understanding not only the code
but also the related documents. During the modification of the software, the effect the change
has to be clearly understood by the maintainer. To test whether those aspects of the system
that are not supposed to be modified are operating as they were before modification,
regression testing is done. In regression testing we use old test cases to test whether new
errors have been introduced or not.
Thus, maintenance involves understanding the existing software, understanding the effect of
change, making the changes to both code and documents, testing the new parts and retesting
the old parts that were not changed. In order to make maintainer job easier, it is necessary to
prepare some supporting documents during software development. The complexity of the
maintenance task, coupled with the neglect of maintenance concerns during development,
makes maintenance the most costly activity in the life of software product.
Maintenance is a set of software engineering activities that occur after software has been
delivered to the customer and put into operation.
Maintenance activities can be divided into two types:
1. Modification-As the specifications of computer systems change, reflecting changes in
the external world, so must the systems themselves.
2. Debugging-Removal of errors that should never have been there in the first place.
• Corrective:21%
• Others(including Preventive):4%
Maintenance Costs
• Software organizations spend anywhere from 40 to 70 percent of all funds conducting
maintenance.
• Reduction in overall software quality as a result of changes that introduce latent errors
in the maintained software.
Unfortunately, with this type of maintenance the user does not see a direct change in the
operation of the system, but the software maintainer must expend resources to effect the
change. This task is estimated to consume about 25% of the total maintenance activity.
Perfective
The third widely accepted task is that of perfective maintenance. This is actually the most
common type of maintenance ecompassing enhancements both to the function and the
efficiency of the code and includes all changes, insertions, deletions modifications,
extensions, and enhancements made to a system to meet the envolving and /or expanding
needs of the user. A successful piece of software tends to be subjected to a succession of
changes resulting in an increase in its requirements. This is based on the premise that as the
software becomes useful, the users tend to experiments with new cases beyond the scope for
which it was initially developed. Expansion in requirements can take the form of
enhancement of existing system functionality or improvement in computational efficiency.
As the program continues to grow with each enhancement the system envolves from an
average-sized program of average maintainability to a very large program that offers great
resistance to modification. Perfective maintenance is by far the largest consumers of
maintenance resources estimates of around 50% are not uncommon.
The categories of maintenance above were further defined in the 1993 IEEE Standard on
Software Maintenance which goes on to define a fourth category.
Preventive
The long-term effect of corrective, adaptive and perfective change is expressed in Lehman’s
law of increasingly entropy:
As a large program is continuously changed, its complexity, which reflects deteriorating
structure, increases unless work is done to maintain or reduce it.
88
Srinivas Institute of Management Studies BCA V sem
The IEEE defined preventive maintenance as “maintenance performed for the purpose of
preventing problems before they occur”. This is the process of changing software to improve
its future maintainability or to provide a better basis for future enhancements.
The preventive change is usually initiated from within the maintenance organization within
the maintenance organization with the intention of making programs easier to understand and
hence facilitate future maintenance work. Preventive change does not usually give rise to a
substantial increase in the baseline functionality.
Preventive maintenance is rare the reason being that other pressures tend to push it to the end
of the queue. For instance, a demand may come to develop a new system that will improve
the organizations competitiveness in the market. This will likely be seen as more desirable
than spending time and money on a project that delivers no new function. Still, it is easy to
see that if one considers the probability of a software unit needing change and the time
pressures that are often present when the change is requested, it makes a lot of sense to
anticipate change and to prepare accordingly.
Assignment 6
Part-A
1. Define error, fault and failure.
2. Define testing.
3. What are test oracles?
4. Which are the basic approaches in testing?
5. What are test cases?
6. What is the aim of testing?
7. What is black box testing?
8. What is glass box testing?
9. What def, c-use, p-use represents in data flow based testing?
10. Mention the different types of maintenance activities.
11. Define software maintenance.
12. What is corrective maintenance?
13. What is adaptive maintenance?
14. What is perfective maintenance?
15. What is preventive maintenance?
Part-B
89
Srinivas Institute of Management Studies BCA V sem
90
Srinivas Institute of Management Studies BCA V sem
Chapter-8
Silk Test is a tool for automated function and regression testing of enterprise applications. It
was originally developed by Segue Software which was acquired by Borland in 2006.
Borland was acquired by Micro Focus International in 2009.
• Silk Test Classic uses the domain specific 4Test language for automation scripting. It
is an object oriented language similar to C++. It uses the concepts of classes, objects,
and inheritance.
• Silk4J allows automation in Eclipse using Java as scripting language
• Silk4Net allows the same in Visual Studio using VB or C#
91
Srinivas Institute of Management Studies BCA V sem
• Silk Test Workbench allows automation testing on a visual level (similar to former
Test Partner) as well as using VB.Net as scripting language
If you are looking for place to get help or support on any software testing tool, you've found
the only place! Simply ask our 180,000+ Members for almost anything, and you'll be
surprised at the amount of help you can get here which you cannot get anywhere else.
Looking for help on WinRunner, LoadRunner, SilkTest, Robot, QARun, eTest, TestComplete
and Webload? This is the place!
Important Notes:
• Registration is required to use this site. If you do not register, you will not be able to
view or post to any forums.
• When registering, please make sure you use a valid email address and spell it
correctly. When you register, your password is automatically emailed to you. If you
do not provide a valid email address, you will not be able to login. Also note that we
usually ban users who try to use invalid email addresses. If your password does not
reach you after you have registered and you are sure you used a correct email address,
notify the webmaster.
• Read your registration email carefully. The email includes forum rules and posting
guidelines. If you violate the forum rules, you will get banned! Also read the FAQ
Help if you have trouble logging in. Note that the username and password are case
sensitive. Also note that if you use a public email service like Yahoo or Hotmail to
make sure your account is NOT over quota. If it is, your registration email will
bounce back and you will not get your password information.
8.4Load Runner
92
Srinivas Institute of Management Studies BCA V sem
A software testing tool, HP Load Runner works by creating virtual users who take the place
of real users' operating client software, such as Internet Explorer, sending requests using the
HTTP protocol to IIS or Apache web servers. HP Load Runner can simulate thousands of
concurrent users to put the application through the rigors of real-life user loads, while
collecting information from key infrastructure components (Web servers, database servers
etc.) The results can then be analyzed in detail to explore the reasons for particular behaviour.
Architecture
The principle of JMeter is very simple. If you want to test e.g. a SOAP interface layer, all you
basically need is the URL and SOAP request. Starting with that you can build your test plan.
And this can be as fancy as you want. Using variables, counters, parameters, CSV files,
loops, logs, etc. There are almost no limits in designing your test and making it as
maintainable as possible.
93
Srinivas Institute of Management Studies BCA V sem
Assignment 8
Part-A
Part-B
94
Srinivas Institute of Management Studies BCA V sem
Software Testing Techniques Programmers attempt to build s/w from an abstract concept to a
tangible product. Engineers create a series of test cases that are intended to “demolish” the
s/w that has been built. Testing is one step in s/w process that could be viewed as destructive
rather than constructive
Testing objectives
• Testing is process of executing a program with the intent of finding an error
• A good test case is one that has a high probability of finding as an yet undiscovered error
• A successful test is one that uncovers an as yet undiscovered error
Software testability is simply how easily a computer program can be tested .Since testing is
difficult, it pays to know what can be done to streamline it
Sometimes programmers are willing to do things that will help the testing process and a
check list of possible design point features .There are certain metrics that could be used to
Measure testability in most of aspects, sometime testability is used to mean how adequately a
Particular set of test will cover the product.
97
Srinivas Institute of Management Studies BCA V sem
PART-B
Unit-I
2. a) Explain the Software problem.
b) Explain the Waterfall model. Write its advantages and disadvantages.
c) Explain the Change Control in SCM. (6+8+6)
99