Requirements Analysis and Specification Guide
Requirements Analysis and Specification Guide
CHAPTER
4
REQUIREMENTS ANALYSIS
AND SPECIFICATION
CHAPTER OUTLINE
®® Requirements Gathering and Analysis
®® Software Requirements Specification
(SRS)
®® Formal System Specification
®® Axiomatic Specification
®® Algebraic Specification
®® Executable Specification and 4GL
Ours is a world where people don't know what they want and
yet are willing to go through hell to get it.
—Don Marquis
172 Fundamentals of Software Engineering
A
ll plan-driven life cycle models prescribe that before
LEARNING OBJECTIVES starting to develop a software, the exact requirements
®® Requirements gathering of the customer must be understood and documented.
and analysis techniques In the past, many projects have suffered because the developers
®® Requirements started to implement something without determining whether
specification using IEEE they were building what the customers exactly wanted. Starting
830 template development work without properly understanding and
®® Representation of documenting the requirements increases the number of iterative
complex logic changes in the later life cycle phases, and thereby alarmingly
®® Formal system pushes up the development
specification costs. This also sets the ground Experienced developers
for customer dissatisfaction take considerable time
and bitter customer-developer to understand the exact
disputes and protracted legal requirements of the customer
battles. No wonder that and to meticulously document
experienced d e ve l o p e r s those. They know that
consider the requirements without a clear understanding
analysis and specification to be of the problem and proper
a very important phase of documentation of the same,
software development life cycle it is impossible to develop a
and undertake it with utmost satisfactory solution.
care.
For any type of software development project, availability of
a good quality requirements document has been acknowledged
to be a key factor in the successful completion of the project.
A good requirements document not only helps to form a clear
understanding of various features required from the software,
but also serves as the basis for various activities carried out
during later life cycle phases. When software is developed
in a contract mode for some other organisation (that is, an
outsourced project), the crucial role played by documentation
of the precise requirements cannot be overstated. Even when
an organisation develops a generic software product, the
situation is not very different since some personnel from the
organisation’s own marketing department act as the customer.
Therefore, for all types of software development projects, proper
formulation of requirements and their effective documentation
is vital. However, for very small software service projects,
the agile methods advocate incremental development of the
requirements.
What are the main activities carried out during requirements analysis and
specification phase?
Requirements analysis and specification phase mainly involves carrying out the following
two important activities:
Requirements gathering and analysis
Requirements specification
In the next section, we will discuss the requirements gathering and analysis activity
and in the subsequent section we will discuss the requirements specification activity.
want. Further, the complete requirements are rarely obtainable from any single customer
representative. Therefore, the requirements have to be systematically gathered by the
analyst from several sources in bits and pieces. These gathered requirements need to be
analysed to remove several types of problems that frequently occur in the requirements
that have been gathered piecemeal from different sources.
We can conceptually divide the requirements gathering and analysis activity into two
separate tasks:
Requirements gathering
Requirements analysis
We discuss these two tasks in the following subsections.
give his suggestions to define certain functionalities more comprehensively, make the
functionalities more general and more complete. In the following, we briefly discuss the
important ways in which an experienced analyst gathers requirements:
1. Studying existing documentation: The analyst usually studies all the available
documents regarding the system to be developed before visiting the customer site.
Customers usually provide statement of purpose (SoP) document to the analyst. Typically
these documents might discuss issues such as the context in which the software is required,
the basic purpose, the stakeholders, and the broad category of features required.
2. Interview: Typically, there are many different categories of users of a software. Each
category of users typically requires a different set of features from the software. Therefore,
it is important for the analyst to first identify the different categories of users and then
determine the requirements of each. For example, the different categories of users of a library
automation software could be the library members, the librarians, and the accountants.
The library members would like to use the software to query availability of books and
issue and return books. The librarians might like to use the software to determine books
that are overdue, create member accounts, delete member accounts, etc. The accounts
personnel might use the software to invoke functionalities concerning financial aspects
such as the total fee collected from the members, book procurement expenditures, staff
salary expenditures, etc.
To systematise this method of requirements gathering, the Delphi technique can be
followed. In this technique, the analyst consolidates the requirements as understood by
him in a document and then circulates it for the comments of the various categories of
users. Based on their feedback, he refines his document. This procedure is repeated till the
different users agree on the set of requirements.
3. Task analysis: The users usually have a black-box view of a software and consider the
software as something that provides a set of services (functionalities). A service supported
by a software is also called a task. We can therefore say that the software performs various
tasks of the users. In this context, the analyst tries to identify and understand the different
tasks to be performed by the software. For each identified task, the analyst tries to formulate
the different steps necessary to realise the required functionality in consultation with the
users. For example, consider the issue book task. The steps may be—authenticate user,
check the number of books issued to the customer and
determine if the maximum number of books that this Task analysis helps the analyst
member can borrow has been reached, check whether the to understand the nitty-gritty
book has been reserved, post the book issue details in the of various user tasks and
member’s record, and finally print out a book issue slip to represent each task as a
that can be presented by the member at the security hierarchy of subtasks.
counter to take the book out of the library premises.
4. Scenario analysis: A task can have many scenarios of operation. The different scenarios
of a task may take place when the task is invoked under different situations. For different
scenarios of a task, the behaviour of the software can be different. For example, the possible
scenarios for the book issue task of a library automation software may be:
Book is issued successfully to the member and the book issue slip is printed.
The book is reserved, and hence cannot be issued to the member.
176 Fundamentals of Software Engineering
The maximum number of books that can be issued to the member is already reached,
and no more books can be issued to the member.
For various identified tasks, the possible scenarios of execution are identified and
the details of each scenario is identified in consultation with the users. For each of the
identified scenarios, details regarding system response, the exact conditions under which
the scenario occurs, etc. are determined in consultation with the user.
5. Form analysis: Form analysis is an important and effective requirements gathering
activity that is undertaken by the analyst, when the project involves automating an
existing manual system. During the operation of a manual system, normally several
forms are required to be filled up by the stakeholders, and in turn they receive several
notifications (usually manually filled forms). In form analysis, the exiting forms and the
formats of the notifications produced are analysed to determine the data input to the
system and the data that are output from the system. For the different sets of data
input to the system, how the input data would be used by the system to produce the
corresponding output data is determined from the users.
EXAMPLE 4.1 While gathering the requirements for a process control application, the
following requirement was expressed by a certain stakeholder: When the temperature
becomes high, the heater should be switched off. Please note that words such as “high”,
“low”, “good”, “bad”, etc. are indications of ambiguous requirements as these lack
178 Fundamentals of Software Engineering
quantification and can be subjectively interpreted. If the threshold above which the
temperature can be considered to be high is not specified, then it may get interpreted
differently by different developers.
EXAMPLE 4.2 In the case study 4.1, suppose one office clerk described the following
requirement: during the final grade computation, if any student scores a sufficiently
low grade in a semester, then his parents would need to be informed. This is clearly an
ambiguous requirement as it lacks any well defined criterion as to what can be considered
as a “sufficiently low grade”.
Inconsistency: Two requirements are said to be inconsistent, if one of the requirements
contradicts the other. The following are two examples of inconsistent requirements:
EXAMPLE 4.3 Consider the following partial requirements that were collected from two
different stakeholders in a process control application development project.
The furnace should be switched-off when the temperature of the furnace rises above
500C.
When the temperature of the furnace rises above 500C, the water shower should
be switched- on and the furnace should remain on.
The requirements expressed by the two stakeholders are clearly inconsistent.
EXAMPLE 4.4 In the case study 4.1, suppose one of the clerks gave the following
requirement—a student securing fail grades in three or more subjects must repeat the
courses over an entire semester, and he cannot credit any other courses while repeating the
courses. Suppose another clerk expressed the following requirement—there is no provision
for any student to repeat a semester; the student should clear the subject by taking it as
an extra subject in any later semester.
There is a clear inconsistency between the requirements given by the two stakeholders.
Incompleteness: An incomplete set of requirements is one in which some requirements
have been overlooked. The lack of these features would be felt by the customer much later,
possibly while using the software. Often, incompleteness is caused by the inability of the
customer to visualise the system that is to be developed and to anticipate all the features
that would be required. An experienced analyst can detect most of these missing features
and suggest them to the customer for his consideration and approval for incorporation in
the requirements. The following are two examples of incomplete requirements:
EXAMPLE 4.5 Suppose for the case study 4.1, one of the clerks expressed the following—
If a student secures a grade point average (GPA) of less than 6, then the parents of the
student must be intimated about the regrettable performance through a (postal) letter as
well as through e-mail.
However, on an examination of all requirements, it was found that there is no provision
by which either the postal or e-mail address of the parents of the students can be entered
into the system. The feature that would allow entering the e-mail ids and postal addresses
of the parents of the students was missing, thereby making the requirements incomplete.
EXAMPLE 4.6 In a chemical plant automation software, suppose one of the requirements
is that if the internal temperature of the reactor exceeds 200C then an alarm bell must be
Requirements Analysis and Specification 179
Can an analyst detect all the problems existing in the gathered requirements?
Many of the inconsistencies, anomalies, and incompleteness are detected effortlessly, while
some others require a focused study of the specific requirements. A few problems in the
requirements can, however, be very subtle and escape even the most experienced eyes.
Many of these subtle anomalies and inconsistencies can be detected, if the requirements are
specified and analysed using a formal method. Once a system has been formally specified,
it can be systematically (and even automatically) analysed to remove all problems from
the specification. We will discuss the basic concepts of formal system specification in
Section 4.3. Though the use of formal techniques is not widespread, the current practice
is to formally specify only the safety-critical2 parts of a system.
2
A safety-critical system is one whose improper working can result in financial loss, loss of property,
or life.
180 Fundamentals of Software Engineering
functionality should be clearly described, and the input and output data should have been
identified precisely.
User documentation writers: The user documentation writers need to read the SRS
document to ensure that they understand the features of the product well enough to be
able to write the users’ manuals.
Project managers: The project managers refer to the SRS document to ensure that they
can estimate the cost of the project easily by referring to the SRS document and that it
contains all the information required to plan the project.
Maintenance engineers: The SRS document helps the maintenance engineers to understand
the functionalities supported by the system. A clear knowledge of the functionalities
can help them to understand the design and code. Also, a proper understanding of the
functionalities supported enables them to determine the specific modifications to the
system’s functionalities would be needed for a specific purpose.
Many software engineers in a project consider the SRS document to be a reference
document. However, it is often more appropriate to think of the SRS document as the
documentation of a contract between the development team and the customer. In fact,
the SRS document can be used to resolve any disagreements between the developers
and the customers that may arise in the future. The SRS document can even be used as
a legal document to settle disputes between the customers and the developers in a court
of law. Once the customer agrees to the SRS document, the development team proceeds
to develop the software and ensure that it conforms to all the requirements mentioned in
the SRS document.
Provides a baseline for validation and verification: The SRS document provides a
baseline against which compliance of the developed software can be checked. It is also
used by the test engineers to create the test plan.
Facilitates future extensions: The SRS document usually serves as a basis for planning
future enhancements.
Before we discuss about how to write an SRS document, we first discuss the
characteristics of a good SRS document and the pitfalls that one must consciously avoid
while writing an SRS document.
with the requirements changes, the SRS document should be easily modifiable. For this, an
SRS document should be well-structured. A well-structured document is easy to understand
and modify. Having the description of a requirement scattered across many places in
the SRS document may not be wrong—but it tends to make the requirement difficult to
understand and also any modification to the requirement would become difficult as it
would require changes to be made at large number of places in the document.
Identification of response to undesired events: The SRS document should discuss the
system responses to various undesired events and exceptional conditions that may arise.
Verifiable: All requirements of the system as documented in the SRS document should be
verifiable. This means that it should be possible to design test cases based on the description
of the functionality as to whether or not requirements have been met in an implementation.
A requirement such as “the system should be user friendly” is not verifiable. On the other
hand, the requirement—“When the name of a book is entered, the software should display
whether the book is available for issue or it has been loaned out” is verifiable. Any feature
of the required system that is not verifiable should be listed separately in the goals of the
implementation section of the SRS document.
name or on the library member’s identification (ID) number. Over-specification restricts the
freedom of the designers in arriving at a good design solution.
Forward references: One should not refer to aspects that are discussed much later in
the SRS document. Forward referencing seriously reduces readability of the specification.
Wishful thinking: This type of problems concern description of aspects which would be
difficult to implement.
Noise: The term noise refers to presence of material not directly relevant to the software
development process. For example, in the register customer function, suppose the analyst
writes that customer registration department is manned by clerks who report for work
between 8 am and 5 pm, 7 days a week. This information can be called noise as it would
hardly be of any use to the software developers and would unnecessarily clutter the SRS
document, diverting the attention from the crucial points.
Several other “sins” of SRS documents can be listed and used to guard against writing
a bad SRS document and is also used as a checklist to review an SRS document.
Non-functional requirements
The non-functional requirements are non-negotiable obligations that must be supported by
the software. The non-functional requirements capture those requirements of the customer
184 Fundamentals of Software Engineering
that cannot be expressed as functions (i.e., accepting input data and producing output
data). Non-functional requirements usually address aspects concerning external interfaces,
user interfaces, maintainability, portability, usability,
maximum number of concurrent users, timing, and The IEEE 830 standard
throughput (transactions per second, etc.). The non- recommends that out of
functional requirements can be critical in the sense that the various non-functional
any failure by the developed software to achieve some requirements, the external
minimum defined level in these requirements can be interfaces, and the design and
considered as a failure and make the software unacceptable implementation constraints
by the customer. should be documented in
In the following subsections, we discuss the different two different sections. The
categories of non-functional requirements that are remaining non-functional
described under three different sections: requirements should be
Design and implementation constraints: Design and documented later in a section
implementation constraints are an important category of and these should include the
non-functional requirements describe any items or issues performance and security
that will limit the options available to the developers. requirements.
Some of the example constraints can be—corporate or
regulatory policies that needs to be honoured; hardware limitations; interfaces with other
applications; specific technologies, tools, and databases to be used; specific communications
protocols to be used; security considerations; design conventions or programming standards
to be followed, etc. Consider an example of a constraint that can be included in this
section—Oracle DBMS needs to be used as this would facilitate easy interfacing with other
applications that are already operational in the organisation.
External interfaces required: Examples of external interfaces are—hardware, software and
communication interfaces, user interfaces, report formats, etc. To specify the user interfaces,
each interface between the software and the users must be described. The description may
include sample screen images, any GUI standards or style guides that are to be followed,
screen layout constraints, standard buttons and functions (e.g., help) that will appear on
every screen, keyboard shortcuts, error message display standards, and so on. One example
of a user interface requirement of a software can be that it should be usable by factory
shop floor workers who may not even have a high school degree. The details of the user
interface design such as screen designs, menu structure, navigation diagram, etc. should
be documented in a separate user interface specification document.
Other non-functional requirements: This section contains a description of non- functional
requirements that neither are design constraints and nor are external interface requirements.
An important example is a performance requirement such as the number of transactions
completed per unit time. Besides performance requirements, the other non-functional
requirements to be described in this section may include reliability issues, accuracy of
results, and security issues.
Goals of implementation
The ‘goals of implementation’ part of the SRS document offers some general suggestions
regarding the software to be developed. These are not binding on the developers, and they
Requirements Analysis and Specification 185
may take these suggestions into account if possible. For example, the developers may use
these suggestions while choosing among different design solutions.
The goals of implementation section might document
issues such as easier revisions to the system functionalities A goal, in contrast to the
that may be required in the future, easier support for new functional and non-functional
devices to be supported in the future, reusability issues, etc. requirements, is not checked by
These are the items which the developers might keep in their the customer for conformance
mind during development so that the developed system at the time of acceptance
may meet some aspects that are not required immediately. testing.
It is useful to remember that anything that would be tested
by the user and the acceptance of the system would depend on the outcome of this task,
is usually considered as a requirement to be fulfilled by the system and not a goal and
vice versa.
withdrawal of money from an ATM be called a useful piece of work? Printing of ATM
transaction should not be considered a high-level requirement, because the user does
not specifically request for this activity. The receipt gets printed automatically as part of
the withdraw money function. Usually, the user invokes (requests) the services of each
high-level requirement. It may therefore be possible to treat print receipt as part of the
withdraw money function rather than treating it as a high-level function. It is therefore
required that for some of the high-level functions, we might have to debate whether we
wish to consider it as a high-level function or not. However, it would become possible
to identify most of the high-level functions without much difficulty after practising the
solution to a few exercise problems.
Each high-level requirement typically involves accepting some data from the user
through a user interface, transforming it to the required response, and then displaying
the system response in proper format. For example, in a library automation software, a
high-level functional requirement might be search-book. This function involves accepting
a book name or a set of key words from the user, running a matching algorithm on the
book list, and finally outputting the matched books. The generated system response can
be in several forms, e.g., display on the terminal, a print out, some data transferred to
the other systems, etc. However, in degenerate cases, a high-level requirement may not
involve any data input to the system or production of displayable results. For example,
it may involve switch on a light, or starting a motor in an embedded application.
Output: List of the books borrowed by the user is displayed, and user is prompted to select
the books to be renewed, if the password is valid. If the password is invalid, the user is
asked to re-enter the password.
Processing: Password validation, search the books issued to the user from the borrower’s
list and display.
Next function: R.2.3 if password is valid and R.2.2 if password is invalid.
R.2.3: Renew selected books
Input: User choice for books to be renewed out of the books borrowed by him.
Output: Confirmation of the books successfully renewed and apology message for the books
that could not be renewed.
Processing: Check if anyone has reserved any of the requested books. Renew the books
selected by the user in the borrower’s list, if no one has reserved those books.
In order to properly identify the high-level requirements, a lot of common sense and
the ability to visualise various scenarios that might arise in the operation of a function
are required. Please note that when any of the aspects of a requirement, such as the state,
processing description, next function to be executed, etc. are obvious, we have omitted it.
We have to make a trade-off between cluttering the document with trivial details versus
missing out some important descriptions.
Specification of large software: If there are large number of functional requirements
(much larger than seen), should they just be written in a long numbered list of requirements?
A better way to organise the functional requirements in this case would be to split the
requirements into sections of related requirements. For example, the functional requirements
of an academic institute automation software can be split into sections such as accounts,
academics, inventory, publications, etc. When there are too many functional requirements,
these should be properly arranged into sections. For example the following can be sections
in the trade house automation software:
Customer management
Account management
Purchase management
Vendor management
Inventory management
Level of details in specification: Even for experienced analysts, a common dilemma is in
specifying too little or specifying too much. In practice, we would have to specify only the
important input/output interactions in a functionality along with the processing required
to generate the output from the input. However, if the interaction sequence is specified in
too much detail, then it becomes an unnecessary constraint on the developers and restricts
their choice in solution. On the other hand, if the interaction sequence is not sufficiently
detailed, it may lead to ambiguities and result in improper implementation.
4.2.9 Traceability
Traceability means that it would be possible to identify (trace) the specific design component
which implements a given requirement, the code part that corresponds to a given design
Requirements Analysis and Specification 191
component, and test cases that test a given requirement. Thus, any given code component
can be traced to the corresponding design component, and a design component can be
traced to a specific requirement that it implements and vice versa. Traceability analysis is
an important concept and is frequently used during software development. For example,
by doing a traceability analysis, we can tell whether all the requirements have been
satisfactorily addressed in all phases. It can also be used to assess the impact of a
requirements change. That is, traceability makes it easy to identify which parts of the
design and code would be affected, when certain requirement change occurs. It can also
be used to study the impact of a bug that is known to exist in a code part on various
requirements, etc.
To achieve traceability, it is necessary that each functional requirement should be
numbered uniquely and consistently. Proper numbering of the requirements makes it
possible for different documents to uniquely refer to specific requirements. An example
scheme of numbering the functional requirements is shown in Examples 4.7 and 4.8, where
the functional requirements have been numbered R.1, R.2, etc. and the subrequirements
for the requirement R.1 have been numbered R.1.1, R.1.2, etc.
830 standard, for each section of the document, we also briefly discuss the aspects that
should be discussed in it.
Introduction
Purpose: This section should describe where the software would be deployed and how
the software would be used.
Project scope: This section should briefly describe the overall context within which the
software is being developed. For example, the parts of a problem that are being automated
and the parts that would need to be automated during future evolution of the software.
Environmental characteristics: This section should briefly outline the environment
(hardware and other software) with which the software will interact.
Functional requirements
This section can classify the functionalities either based on the specific functionalities
invoked by different users, or the functionalities that are available in different modes, etc.,
depending what may be appropriate.
Requirements Analysis and Specification 193
1. User class 1
(a) Functional requirement 1.1
(b) Functional requirement 1.2
2. User class 2
(a) Functional requirement 2.1
(b) Functional requirement 2.2
Security requirements: This section should specify any requirements regarding security
or privacy requirements on data used or created by the software. Any user identity
authentication requirements should be described here. It should also refer to any external
policies or regulations concerning the security issues. Define any security or privacy
certifications that must be satisfied.
For software that have distinct modes of operation, in the functional requirements
section, the different modes of operation can be listed and in each mode the specific
functionalities that are available for invocation can be organised as follows.
Functional requirements
1. Operation mode 1
(a) Functional requirement 1.1
(b) Functional requirement 1.2
2. Operation mode 2
(a) Functional requirement 2.1
(b) Functional requirement 2.2
Specification of the behaviour may not be necessary for all systems. It is usually
necessary for those systems in which the system behaviour depends on the state in which
the system is, and the system transits among a set of states depending on some prespecified
conditions and events. The behaviour of a system can be specified using either the finite
state machine (FSM) formalism or any other alternate formalisms. The FSMs can used to
specify the possible states (modes) of the system and the transition among these states due
to occurrence of events.
stored using a free (public domain) data base management system. The software should
run on both Windows and UNIX machines.
Whenever the owner of the library software borrows a book from his friends, would
enter the details regarding the title of the book, and the date borrowed and the friend
from whom he borrowed it. Similarly, the return details of books would be entered. The
software should be able to display all the books borrowed from various friends upon
request by the owner.
It should be possible for anyone to query about the availability of a particular book
through a web browser from any location. The owner should be able to query the total
number of books in the personal library, and the total amount he has invested in his library.
It should also be possible for him to view the number of books borrowed and returned by
any (or all) friend(s) over any specified time.
Functional requirements
The software needs to support three categories of functionalities as described below:
1. Manage own books
1.1 Register book
Description: To register a book in the personal library, the details of a book, such as name,
year of publication, date of purchase, price and publisher are entered. This is stored in the
database and a unique serial number is generated.
Input: Book details
Output: Unique serial number
4. Manage statistics
R.4.1: Display book count
Description: The total number of books in the personal library should be displayed.
Input: User selection.
Output: Count of books.
R.4.3: Display number of transactions Description: The total numbers of books issued
and returned over a specific period by one (or all) friend(s) is displayed.
Input: Start of period and end of period.
Output: Total number of books issued and total number of books returned.
Non-functional requirements
N.1: Database: A data base management system that is available free of cost in the public
domain should be used.
N.2: Platform: Both Windows and UNIX versions of the software need to be developed.
N.3: Web-support: It should be possible to invoke the query book functionality from any
place by using a web browser.
Observation: Since there are many functional requirements, the requirements have been
organised into four sections: Manage own books, manage friends, manage borrowed books,
and manage statistics. Now each section has less than 7 functional requirements. This
would not only enhance the readability of the document, but would also help in design.
and processing sequences may exist depending on the outcome of the corresponding
condition checking. A simple text description in such cases can be difficult to comprehend
and analyse. In such situations, a decision tree or a decision table can be used to represent
the logic and the processing involved. Also, when the decision making in a functional
requirement has been represented as a decision table, it becomes easy to automatically or
at least manually design test cases for it. However, use of decision trees or tables would
be superfluous in cases where the number of alternatives are few, or the decision logic is
straightforward. In such cases, a simple text description would suffice.
There are two main techniques available to analyse and represent complex processing
logic—decision trees and decision tables. Once the decision-making logic is captured
in the form of trees or tables, the test cases to validate these logic can be automatically
obtained. It should, however, be noted that decision trees and decision tables have much
broader applicability than just specifying complex processing logic in an SRS document.
For instance, decision trees and decision tables find applications in information theory and
switching theory.
Decision tree
A decision tree gives a graphic view of the processing logic involved in decision making
and the corresponding actions taken. Decision tables specify which variables are to be
tested, and based on this what actions are to be taken depending upon the outcome of the
decision-making logic, and the order in which decision making is performed.
The edges of a decision tree represent conditions and the leaf nodes represent the
actions to be performed depending on the outcome of testing the conditions. Instead of
discussing how to draw a decision tree for a given processing logic, we shall explain
through a simple example how to represent the processing logic in the form of a decision
tree.
EXAMPLE 4.10 A library membership management software (LMS) should support the
following three options—new member, renewal, and cancel membership. When the new
member option is selected, the software should ask the member’s name, address, and phone
number. If proper information is entered, the software should create a membership record
for the new member and print a bill for the annual membership charge and the security
deposit payable. If the renewal option is chosen, the LMS should ask the member’s name
and his membership number and check whether he is a valid member. If the member details
entered are valid, then the membership expiry date in the membership record should be
updated and the annual membership charge payable by the member should be printed. If
the membership details entered are invalid, an error message should be displayed. If the
cancel membership option is selected and the name of a valid member is entered, then the
membership is cancelled, a choke for the balance amount due to the member is printed
and his membership record is deleted. The decision tree representation for this problem
is shown in Figure 4.3.
Observe from Figure 4.3 that the internal nodes represent conditions, the edges of
the tree correspond to the outcome of the corresponding conditions. The leaf nodes
represent the actions to be performed by the system. In the decision tree of Figure 4.3,
first the user selection is checked. Based on whether the selection is valid, either further
Requirements Analysis and Specification 199
condition checking is undertaken or an error message is displayed. Observe that the order
of condition checking is explicitly represented.
Decision table
A decision table shows the decision-making logic and the corresponding actions taken in
a tabular or a matrix form. The upper rows of the table specify the variables or conditions
to be evaluated and the lower rows specify the actions to be taken when an evaluation test
is satisfied. A column in the table is called a rule. A rule implies that if a certain condition
combination is true, then the corresponding action is executed. The decision table for the
LMS problem of Example 4.10 is as shown in Table 4.1.
TABLE 4.1 Decision Table for the LMS Problem
Conditions
Valid selection NO YES YES YES
New member - YES NO NO
Renewal - NO YES NO
Cancellation - NO NO YES
Actions
Display error message ×
Ask member’s name, etc. ×
Build customer record ×
Generate bill × ×
Ask membership details × ×
Update expiry date ×
Print cheque ×
Delete record ×
Readability: Decision trees are easier to read and understand when the number of
conditions are small. On the other hand, a decision table causes the analyst to look at
every possible combination of conditions which he might otherwise omit.
Explicit representation of the order of decision making: In contrast to the decision trees,
the order of decision making is abstracted out in decision tables. A situation where decision
tree is more useful is when multilevel decision making is required. Decision trees can more
intuitively represent multilevel decision making hierarchically, whereas decision tables can
only represent a single decision to select the appropriate action for execution.
Representing complex decision logic: Decision trees become very complex to understand
when the number of conditions and actions increase. It may even be to draw the tree
on a single page. When very large number of decisions are involved, the decision table
representation may be preferred.
3
Sections 4.3–4.5 can be omitted in a first level course on software engineering.
Requirements Analysis and Specification 201
stage of the system development activity to verify that the output of one stage conforms
to the output of the previous stage.
Syntactic domains
The syntactic domain of a formal specification language consists of an alphabet of symbols
and a set of formation rules to construct well-formed formulas from the alphabet. The
well-formed formulas are used to specify a system.
Semantic domains
Formal techniques can have considerably different semantic domains. Abstract data type
specification languages are used to specify algebras, theories, and programs. Programming
languages are used to specify functions from input to output values. Concurrent and
distributed system specification languages are used to specify state sequences, event
sequences, state-transition sequences, synchronisation trees, partial orders, state machines,
etc.
Satisfaction relation
Given the model of a system, it is important to determine whether an element of the
semantic domain satisfies the specifications. This satisfaction is determined by using a
homomorphism known as semantic abstraction function. The semantic abstraction function
maps the elements of the semantic domain into equivalent classes. There can be different
specifications describing different aspects of a system model, possibly using different
specification languages. Some of these specifications describe the system’s behaviour and
the others describe the system’s structure. Consequently, two broad classes of semantic
abstraction functions are defined—those that preserve a system’s behaviour and those that
preserve a system’s structure.
specification. The reason for this distinction is the fact that property-oriented approaches
specify a system behaviour not by what they say of the system but by what they do
not say of the system. Thus, property-oriented specifications permit a large number of
possible implementations. Furthermore, property-oriented approaches specify a system by
a conjunction of axioms, thereby making it easier to alter/augment specifications at a later
stage. On the other hand, model-oriented methods do not support logical conjunctions and
disjunctions, and thus even minor changes to a specification may lead to overhauling an
entire specification. Since the initial customer requirements undergo several changes as the
development proceeds, the property-oriented style is generally preferred for requirements
specification. Later in this chapter, we have discussed two property-oriented specification
techniques.
Formal specifications encourage rigour. It is often the case that the very process
of construction of a rigorous specification is more important than the formal
specification itself. The construction of a rigorous specification clarifies several
aspects of system behaviour that are not obvious in an informal specification. It is
widely acknowledged that it is cost-effective to spend more efforts at the specification
stage, otherwise, many flaws would go unnoticed only to be detected at the later
stages of software development that would lead to iterative changes to occur in the
development life cycle. According to an estimate, for large and complex systems
like distributed real-time systems 80 per cent of project costs and most of the cost
overruns result from the iterative changes required in a system development process
due to inappropriate formulation of requirements specification. Thus, the additional
effort required to construct a rigorous specification is well worth the trouble.
Formal methods usually have a well-founded mathematical basis. Thus, formal
specifications are not only more precise, but also mathematically sound and can
be used to reason about the properties of a specification and to rigorously prove
that an implementation satisfies its specifications. Informal specifications may be
useful in understanding a system and its documentation, but they cannot serve as
a basis of verification. Even carefully written specifications are prone to error, and
experience has shown that unverified specifications are comparable in reliability to
unverified programs.
Formal methods have well-defined semantics. Therefore, ambiguity in specifications
is automatically avoided when one formally specifies a system.
The mathematical basis of the formal methods makes it possible for automating the
analysis of specifications. For example, a tableau-based technique has been used
to automatically check the consistency of specifications. Also, automatic theorem
proving techniques can be used to verify that an implementation satisfies its
specifications. The possibility of automatic verification is one of the most important
advantages of formal methods.
Formal specifications can be executed to obtain immediate feedback on the features
of the specified system. This concept of executable specifications is related to rapid
prototyping. Informally, a prototype is a “toy” working model of a system that
can provide immediate feedback on the behaviour of the specified system, and is
especially useful in checking the completeness of specifications.
It is clear that formal methods provide mathematically sound frameworks within which
large, complex systems can be specified, developed and verified in a systematic rather than
in an ad hoc manner. However, formal methods suffer from several shortcomings, some
of which are as following:
Formal methods are difficult to learn and use.
The basic incompleteness results of first-order logic suggest that it is impossible to
check absolute correctness of systems using theorem proving techniques.
Formal techniques are not able to handle complex problems. This shortcoming results
from the fact that, even moderately complicated problems blow up the complexity of
formal specification and their analysis. Also, a large unstructured set of mathematical
formulas is difficult to comprehend.
204 Fundamentals of Software Engineering
It has been pointed out by several researchers that formal specifications neither
replace nor make the informal descriptions obsolete but complement them. In fact, the
comprehensibility of formal specifications is greatly enhanced when the specifications are
accompanied by an informal description. What is suggested is the use of formal techniques
as a broad guideline for the use of the informal techniques. An interesting example of
such an approach is reported by Jones in 1980 [Jones, 1980]. In this approach, the use of
a formal method identifies the necessary verification steps that need to be carried out, but
it is legitimate to apply informal reasoning in presentation of correctness arguments and
transformations. Any doubt or query relating to an informal argument is to be resolved
by formal proofs.
In the following two sections, we discuss the axiomatic and algebraic specification styles.
Both these techniques can be classified as the property-oriented specification techniques.
EXAMPLE 4.11 Specify the pre- and post-conditions of a function that takes a real
number as argument and returns half the input value if the input is less than or equal to
100, or else returns double the value.
f(x : real) : real
pre : x R
post : {(x £ 100) ∧ (f (x) = x/2)} ∨ {(x > 100) ∧ (f (x) = 2 ∗ x)}
Requirements Analysis and Specification 205
EXAMPLE 4.12 Axiomatically specify a function named search which takes an integer
array and an integer key value as its arguments and returns the index in the array where
the key value is present.
search(X : intArray, key : integer) : integer
pre : ∃i ∈ [Xfirst...Xlast], X[i] = key
post : {(X′[search(X, key)] = key) ∧ (X = X′)}
Please note that we have followed the convention that if a function changes any of its
input parameters, and if that parameter is named X, then we refer to it after the function
completes execution as X’. One practical application of the axiomatic specification is in
program documentation. Engineers developing code for a function specify the function by
noting down the pre- and post-conditions of the function in the function header. Another
application of the axiomatic specifications is in proving program properties by composing
the pre- and post-conditions of a number of functions.
EXAMPLE 4.13 Let us specify a data type point supporting the operations create, xcoord,
ycoord, isequal; where the operations have their usual meaning.
Requirements Analysis and Specification 207
Types:
defines point
uses boolean, integer
Syntax:
1. create : integer × integer → point
2. xcoord : point → integer
3. ycoord : point → integer
4. isequal : point × point → boolean
Equations:
1. xcoord(create(x, y)) = x
2. ycoord(create(x, y)) = y
3. isequal(create(x1, y1), create(x2, y2)) = ((x1 = x2)and(y1 = y2))
In this example, we have only one basic constructor (create), and three basic inspectors
(xcoord, ycoord, and isequal). Therefore, we have only 3 equations.
The rewrite rules let you determine the meaning of any sequence of calls on the point
type. Consider the following expression: isequal (create (xcoord (create(2, 3)), 5),create (ycoord
(create(2, 3)), 5)). By applying the rewrite rule 1, you can simplify the given expression as
isequal (create (2, 5), create (ycoord (create(2, 3)), 5)). By using rewrite rule 2, you can further
simplify this as isequal (create (2, 5), create (3, 5)). This is false by rewrite rule 3.
EXAMPLE 4.14 Let us specify a FIFO queue supporting the operations create, append,
remove, first, and isempty; where the operations have their usual meaning.
Types:
defines queue
uses boolean, element
208 Fundamentals of Software Engineering
Exception:
underflow, novalue
Syntax:
1. create : f → queue
2. append : queue × element → queue
3. remove : queue → queue + {underflow}
4. first : queue → element + {novalue}
5. isempty : queue → boolean
Equations:
1. isempty(create()) = true
2. isempty(append(q, e)) = false
3. first(create()) = novalue
4. first(append(q, e)) = if isempty(q) then e else first(q)
5. remove(create()) = underflow
6. remove(append(q, e)) = if isempty(q) then create() else append(remove(q), e)
In this example, we have two basic construction operators (create and append). We
have one extra construction operator (remove). We have considered remove to be an extra
construction operator because all values of the queue can be realised, even without having
the remove operator. We have two basic inspectors (first and isempty). Therefore, we
have 2 × 3 = 6 equations.
EXAMPLE 4.15 Let us specify a bounded FIFO queue having a maximum size of
MaxSize and supporting the operations create, append, remove, first, and isempty; where
the operations have their usual meaning.
Types:
defines queue
uses boolean, element, integer
Exception:
underflow, novalue, overflow
Syntax:
1. create : f → queue
2. append : queue × element → queue + {overflow}
3. size : queue → integer
4. remove : queue → queue + {underflow}
5. first : queue → element + {novalue}
6. isempty : queue → boolean
Requirements Analysis and Specification 209
Equations:
1. first(create()) = novalue
2. first(append(q,e)) = if size(q)= MaxSize then overflow else if isempty(q) then e else first(q)
3. remove(create()) = underflow
4. remove(append(q, e)) = if isempty(q) then create() else
if size(q) = MaxSize then overflow else append(remove(q), e)
5. size(create()) = 0
6. size(append(q, e)) = if size(q) = MaxSize then overflow else size(q) + 1
7. isempty(q) = if (size(q) = 0) then true else false
In this example, we have used the auxiliary function size to enable us to specify that
during appending an element, overflow might occur if the queue size exceeds MaxSize.
However, after we have introduced the auxiliary function size, we find that the operator
isempty can no longer be considered as a basic inspector because isempty can be expressed
in terms of size. Therefore, we have removed the axioms for the operator isempty used
in Example 4.15, and have instead used an axiom to express isempty in terms of size.
We have added two axioms to express size in terms of the basic construction operators
(create and append).
specifications are usually slow and inefficient, 4GLs4 (4th Generation Languages) are
examples of executable specification languages. 4GLs are successful because there is a lot
of large granularity commonality across data processing applications which have been
identified and mapped to program code. 4GLs get their power from software reuse, where
the common abstractions have been identified and parameterized. Careful experiments
have shown that rewriting 4GL programs in 3GLs results in up to 50 per cent lower memory
usage and also the program execution time can reduce up to tenfolds.
SUMMARY
Substantial time and effort must be spent in developing a good quality SRS document
before starting the design activity. Any improper specification turns out to be very
expensive adversely affects all subsequent phases of development.
The requirements analysis and specification phase consists of two important
activities—requirements gathering and analysis, and requirements specification.
The aim of requirements analysis is to clearly understand the exact user requirements
and to remove any inconsistencies, anomalies, and incompleteness in these
requirements.
During the requirements specification activity, the requirements are systematically
organised into an SRS document.
Formally specifying the requirements has many advantages. But, a major shortcoming
of the formal specification techniques is that they are hard to use. However, it
is possible that formal techniques will become more usable in future with the
development of suitable front-ends. We discussed the axiomatic and algebraic
techniques as example formal specification techniques to give an idea of some of
the issues involved in formal specification.
EXERCISES
MULTIPLE CHOICE QUESTIONS
For each of the following questions only one of the options is correct. Choose the correct
option:
1. Who among the following is a stakeholder in a software development project?
(a) A shareholder of the organisation developing the software
(b) Anyone who is interested in the software
(c) Anyone who is a source of requirements for the software
(d) Anyone who might be affected by the software
4
P
rogramming languages are generally classified into four generations. The first generation (1GL)
programming languages consist of machine language programs. The second generation (2GL)
started when the assembly language was introduced. All procedural languages are classified as
3GLs. In procedural languages, in order to solve a problem, you would have to precisely write
down “how” the required result can be obtained. This requires writing the exact procedures or
the algorithmic steps that need to be followed to arrive at the result. In contrast, using a 4GL only
the “what” parts have to be specified.
Requirements Analysis and Specification 211
TRUE OR FALSE
State whether the following statements are TRUE or FALSE. Give reasons for your answer.
1. Applications developed using 4GLs would normally be more efficient and run faster
compared to applications developed using 3GL.
212 Fundamentals of Software Engineering
REVIEW QUESTIONS
1. What is the difference between requirements analysis and specification? What are the
important activities that are carried out during requirements analysis and specification
phase? What is the final outcome of the requirements analysis and specification phase?
2. What are the goals of the requirements analysis and specification phase? How are
the requirements analysis and specification activities carried out and who carries out
these activities?
3. Discuss the important ways in which a good SRS document can be useful to various
stakeholders.
4. What is the difference between the functional and the non-functional requirements
of a system? Identify at least two functional requirements of a bank automated teller
machine (ATM) system. Also identify one non-functional requirement for an ATM
system.
5. What are the four types of non-functional requirements that have been suggested
by IEEE 830 standards document? Give one example of each of these categories of
requirements.
6. What do you understand by requirements gathering? Name and explain the different
requirements gathering techniques that are normally deployed by an analyst.
7. What are the different types of requirements problems that an analyst usually
anticipates and rectifies in the gathered requirements before starting to write the
SRS document? Give at least one example of each type of requirements problems.
8. Explain the likely consequences of starting a large project development effort without
accurately understanding and documenting the customer requirements.
9. Suppose you have been appointed as the analyst for a large software development
project. Discuss the aspects of the software product you would document in the
software requirements specification (SRS) document? What would be the organisation
of your SRS document? How would you validate your SRS document?
Requirements Analysis and Specification 213
10. Make a checklist of various types of errors that might exist in an SRS document, so
that this checklist can be used to review an SRS document.
11. Write down the important users of the SRS document for a project, the specific ways
in which they use the document, and their specific expectations from the document,
if any.
12. What do you understand by the problems of over specification, forward reference,
and noise in an SRS document? Explain each of these with suitable examples.
13. What is the difference between functional and non-functional requirements? Give one
example of each type of requirement for a library automation software.
14. List five desirable characteristics of a good software requirements specification (SRS)
document.
15. Suppose you are trying to gather the requirements for a software that needs to be
developed to automate the book-keeping activities of a supermarket. Identify the
main tasks that you would undertake as the analyst to satisfactorily gather the
requirements.
16. How are the abstraction and decomposition principles used in the development of a
good software requirements specification?
17. Suppose the analyst of a large product development effort has prepared the SRS
document in the form of a narrative essay of the system to be developed. Based on
this document, the product development activity gets underway. Explain the problems
that such a requirements specification document may create while developing the
software.
18. Discuss the relative advantages of formal and informal requirements specifications.
19. Why is the SRS document also known as the black-box specification of a system?
20. Who are the different category of users of the SRS document? In what ways is the
SRS document useful to them?
21. Give an example of an inconsistent functional requirement. Explain why you think
that the requirement is inconsistent.
22. What do you understand by traceability in the context of software requirements
specification? How is traceability achieved? Identify at least two important benefits
of having traceability among development artifacts.
23. (a) What are the important differences between a model-oriented specification method
and a property-oriented specification method?
(b) Compare the relative advantages of property-oriented specification methods over
model-oriented specification methods.
(c) Name at least one representative popular property-oriented specification technique,
and one representative model-oriented specification technique.
24. Consider the following requirement for a software to be developed for controlling
a chemical plant. The chemical plant has a number of emergency conditions. When
any of the emergency conditions occurs, some prespecified actions should be taken.
The different emergency conditions and the corresponding actions that need to be
taken are as follows:
214 Fundamentals of Software Engineering
(a) If the temperature of the chemical plant exceeds T1°C, then the water shower
should be turned ON and the heater should be turned OFF.
(b) If the temperature of the chemical tank falls below T2°C, then the heater should
be turned ON and the water shower should be turned OFF.
(c) If the pressure of the chemical plant is above P1, then the valve v1 should be
OPENED.
(d) If the chemical concentration of the tank rises above M , and the temperature of
the tank is more than T3°C, then the water shower should be turned ON.
(e) If the pressure rises above P3 and the temperature rises above T1°C, then the
water shower should be turned ON, valves v1 and v2 are OPENED and the alarm
bells sounded.
Write the requirements of this chemical plant software in the form of a decision
table.
25. Draw a decision tree to represent the processing logic of the chemical plant controller
described in question 24.
26. Represent the decision making involved in the operation of the following wash-
machine by means of a decision table:
The machine waits for the start switch to be pressed. After the user presses the
start switch, the machine fills the wash tub with either hot or cold water depending
upon the setting of the HotWash switch. The water filling continues until the high
level is sensed. The machine starts the agitation motor and continues agitating the
wash tub until either the preset timer expires or the user presses the stop switch.
After the agitation stops, the machine waits for the user to press the startDrying
switch. After the user presses the startDrying switch, the machine starts the hot air
blower and continues blowing hot air into the drying chamber until either the user
presses the stop switch or the preset timer expires.
27. Represent the processing logic of the following problem in the form of a decision
table: A Library Membership Automation System needs to support three functions:
add new-member, renew-membership, cancel-membership. If the user requests
for any function other than these three, then an error message is flashed. When
an add new-member request is made, a new member record is created and a bill
for the annual membership fee for the new member is generated. If a membership
renewal request is made, then the expiry date of the concerned membership record is
updated and a bill towards the annual membership fee is generated. If a membership
cancellation request is made, then the concerned membership record is deleted and
a cheque for the balance amount due to the member is printed.
28. What do you understand by pre- and post-conditions of a function? Write the pre-
and post-conditions to axiomatically specify the following functions:
(a) A function takes two floating point numbers representing the sides of a rectangle
as input and returns the area of the corresponding rectangle as output.
(b) A function accepts three integers in the range of –100 and +100 and determines
the largest of the three integers.
(c) A function takes an array of integers as input and finds the minimum value.
Requirements Analysis and Specification 215
(d) A function named square-array creates a 10 element array where each all elements
of the array, the value of any array element is square of its index.
(e) A function sort takes an integer array as its argument and sorts the input array
in ascending order.
29. Using the algebraic specification method, formally specify a string supporting the
following operations:
append: append a given string to another string
add: add a character to a string
create: create a new null string
isequal: checks whether two strings are equal or not
isempty: checks whether the string is null
30. Using the algebraic specification method, formally specify an array of generic type
elem. Assume that array supports the following operations:
create: takes the array bounds as parameters and initializes the values of the array
to undefined.
assign: creates a new array, where a particular element has been assigned a value.
eval: reveals the value of a specified element.
first: returns the first bound of the array.
last: returns the last bound of the array.
31. What do you understand by an executable specification language? How is it different
from a traditional procedural programming language? Give an example of an
executable specification language.
32. What is a fourth generation programming technique? What are its advantages and
disadvantages vis-a-vis a third generation technique?
33. What are auxiliary functions in algebraic specifications? Why are these needed?
34. What do you understand by incremental development of algebraic specifications?
What is the advantage of incremental development of algebraic specifications?
35. (a)
Algebraically specify an abstract data type that stores a set of elements and
supports the following operations. Assume that the ADT element has already
been specified and you can use it:
new: creates a null set.
add: takes a set and an element and returns the set with the additional elements
stored.
size: takes a set as argument and returns the number of elements in the set.
remove: takes a set and an element as its argument and returns the set with
the element removed.
contains: takes a set and an element as its argument and returns the Boolean
value true if the element belongs to the set and returns false if the element
does not belong to the set.
equals: takes two sets as arguments and returns true if they contain identical
elements and returns false otherwise.
216 Fundamentals of Software Engineering
(b) Using the specification you have developed for the ADT set, reduce the following
expression by applying the rewrite rules: equals (add(5, (add(6, new()), add(6,
(add(5, new()))). Show the details of every reduction.
36. Algebraically specify a data type Point, that supports the following operations:
create, xcoord, ycoord, move, movex, movey. The informal meanings of
these operations are the following—create takes two integers as its arguments and
creates an instance of point type that has the two integers as its x and y coordinate
values respectively, xcoord and ycoord return the x and y-coordinates of a given
point, move takes a point and two integer values as its argument and sets the x and
y-coordinates of point to the specified values, movex takes a point and an integer
value as its argument and sets the x-coordinate of the point to the given integer
value. Similarly, movey takes a point and an integer value and sets the y-coordinate
of point to the given integer value.
Reduce the following expression, clearly showing each step and mentioning the
reduction rule used.
xcoord(movex(create(20,100), ycoord(create(10,50)))
37. Write a formal algebraic specification of the sort symbol-table whose operations are
informally defined as follows:
create: bring a symbol table into existence.
enter: enter a symbol table and its type into the table.
lookup: return the type associated with a name in the table.
delete: remove a name, type pair from the table, given a name as a parameter.
replace: replace the type associated with a given name with the type specified as
its parameter.
The enter operation fails if the name is already present in the table. The lookup,
delete, and replace operations fail if the name is not available in the table.
38. Algebraically specify the data type queue which supports the following operations:
create: creates an empty queue.
append: takes a queue and an item as its arguments and returns a queue with the
item added at the end of the queue.
remove: takes a queue as its argument and returns a queue with the first element
of the original queue removed.
inspect: takes a queue as its argument and returns the value of the first item in
the queue.
isempty: takes a queue as its argument and returns true if the queue contains no
elements, and returns false if it contains one or more elements.
You can assume that the data type item has previously been specified and that you
can reuse this specification.
39. Define the finite termination and unique termination properties of algebraic
specifications. Why is it necessary for an algebraic specification to satisfy these
properties?
40. If the prototyping model is being used in a development effort, is it necessary to
develop a requirements specification document?
Requirements Analysis and Specification 217
41. Express the decision making involved in the following withdraw cash function of a
bank ATM using a decision table.
To withdraw cash, first a valid customer identification is required. For this, the
customer is prompted to insert his ATM card in the card checking machine. If his
card is found to be invalid, the card is ejected out along with an appropriate message
displayed. If the card is verified to be a valid card, the customer is prompted to type
his password. If the password is invalid, an error message is shown and the customer
is prompted to enter his password again. If the customer enters incorrect password
consecutively for three times, then his card is seized and he is asked to contact the
bank manager. On the other hand, if the customer enters his password correctly,
then he is considered to have validly identified himself and is prompted to enter the
amount he needs to withdraw. If he enters an amount that is not a multiple of `100, he
is prompted to enter the amount again. After he enters an amount that is a multiple
of `100, the cash is dispensed if sufficient amount is available in his account and his
card is ejected; otherwise his card is ejected out without any cash being dispensed
along with a message display regarding insufficient fund position in his account.
42. Identify the functional and non-functional requirements in the following problem
description and document them.
A cosmopolitan clock software is to be developed that displays up to 6 clocks with the
names of the city and their local times. The clocks should be aesthetically designed.
The software should allow the user to change name of any city and change the time
readings of any clock by typing c (for configure) on any clock. The user should also be
able to toggle between a digital clock and an analog clock display by typing either d
(for digital) or a (for analog) on a clock display. After the stand-alone implementation
works, a web-version should be developed that can be downloaded on a browser as
an applet and run. The clock should use only the idle cycles on the computer it runs.
43. What do you understand by inconsistencies, anomalies, and incompletenesses in an
SRS document? Identify the inconsistencies, anomalies, and incompletenesses in the
following requirements of an academic activity automation software of an educational
institute:
“The semester performance of each student is computed as the average academic
performance for the semester. The guardians of all students having poor performance
record in the semester are mailed a letter informing about the poor performance of the
ward and intimating that repetition of poor performance in the subsequent semester
can lead to expulsion. The extracurricular activities of a student are also graded and
taken into consideration for determination of the semester performance.”
44. Identify any inconsistencies, anomalies, and incompleteness that are present in the
following requirements that were gathered by interviewing the clerks of the CSE
department for developing an academic automation software (AAS): “The CGPA of
each student is computed as the average performance for the semester. The parents
of all students having poor performance are mailed a letter informing about the poor
performance of their ward and with a request to convey a warning to the student
that the poor performance should not be repeated.”
218 Fundamentals of Software Engineering
45. Represent the decision making involved in the following functional requirement of
a library automation system: Issue Item: An item when submitted at the counter
along with the library identity card, first it is determined if the member has exceeded
his quota. If he has exceeded his quota, then no items can be issued to him. If the
requested item is a journal, then it is issued for two days only. If it is a book, then
it is checked whether it is a reference book. Reference books cannot be issued out. If
it is not a reference book, it is determined if anyone has reserved it. Reserved books
cannot be issued out. If the book issue request of the member meets all the mentioned
criteria, then the book is issued to the member for one month, appropriate entry is
made in the member’s account and an issue slip is printed.
46. Suppose you wish to develop a word processing software that would have features
similar to Microsoft Word. Develop the SRS document for this word processing
software.
47. Identify at least three important reasons as to why the customer requirements may
change after the requirements phase is complete and the SRS document has been
signed off.
48. Suppose you are entrusted with the work of gathering the requirements for the hostel
automation software that you have undertaken for an academic institute. Briefly
discuss how you would carry out the requirements gathering and analysis activities.
Software Design 219
CHAPTER
5
SOFTWARE DESIGN
CHAPTER OUTLINE
®® Overview of the Design Process
®® How to Characterise a Good Software
Design?
®® Cohesion and Coupling
®® Layered Arrangement of Modules
®® Approaches to Software Design
D
uring the software design phase, the design document
LEARNING OBJECTIVES is produced, based on the customer requirements as
®® High-level versus detailed documented in the SRS document.
design This view of a design
®® Characteristics of a good process has been shown The activities carried out
design schematically in Figure 5.1. As during the design phase (called
®® Determination of the levels shown in Figure 5.1, the design as design process) transform the
of cohesion and coupling process starts using the SRS SRS document into the design
of a module document and completes with document.
®® Procedural versus object- the production of the design
oriented design document. The design document produced at the end of the
design phase should be implementable using a programming
language in the subsequent (coding) phase.
Warnier-Orr [1977, 1981] diagram are available to document a software design, we confine
our attention in this text to structure charts and UML diagrams only.
Once the high-level design is complete, detailed design
is undertaken. During detailed design each
The outcome of the detailed design stage is usually module is examined carefully
documented in the form of a module specification (MSPEC) to design its data structures
document. After the high-level design is complete, the and the algorithms.
problem would have been decomposed into small modules,
and the data structures and algorithms to be used described using MSPEC and can be easily
grasped by programmers for initiating coding. In this text, we do not discuss MSPECs and
confine our attention to high-level design only.
The design model is obtained from the analysis model through transformations over a
series of steps. In contrast to the analysis model, the design model reflects several decisions
taken regarding the exact way system is to be implemented. The design model should be
detailed enough to be easily implementable using a programming language.
design would make the matter worse. Unless a design solution is easily understandable,
it could lead to an implementation having a large number of defects and at the same time
tremendously pushing up the development costs. Therefore, a good design solution should
be simple and easily understandable. A design that is easy to understand is also easy to
develop and maintain. A complex design would lead to severely increased life cycle costs.
Unless a design is easily understandable, it would require tremendous effort to implement,
test, debug, and maintain it. We had already pointed out in Chapter 2 that about 60 per
cent of the total effort in the life cycle of a typical product is spent on maintenance. If the
software is not easy to understand, not only would it lead to increased development costs,
the effort required to maintain the product would also increase manifold. Besides, a design
solution that is difficult to understand would lead to a program that is full of bugs and is
unreliable. Recollect that we had already discussed in Chapter 1 that understandability of a
design solution can be enhanced through clever applications of the principles of abstraction
and decomposition.
Based on this classification, we would be able to easily judge the cohesion and coupling
existing in a design solution. From a knowledge of the cohesion and coupling in a design,
we can form our own opinion about the modularity of the design solution. We shall define
the concepts of cohesion and coupling and the various classes of cohesion and coupling
in Section 5.3. Let us now discuss the other important characteristic of a good design
solution—layered design.
226 Fundamentals of Software Engineering
Layered design
A layered design is one in which when the call relations among different modules are
represented graphically, it would result in a tree-like diagram with clear layering. In a
layered design solution, the modules are arranged in a hierarchy of layers. A module can
only invoke functions of the modules in the layer immediately below it. The higher layer
modules can be considered to be similar to managers that
invoke (order) the lower layer modules to get certain tasks
A layered design can make
done. A layered design can be considered to be implementing
the design solution easily
control abstraction, since a module at a lower layer is
understandable, since to
unaware of (about how to call) the higher layer modules.
understand the working of a
When a failure is detected while executing a module,
module, one would at best
it is obvious that the modules below it can possibly be the
have to understand how
source of the error. This greatly simplifies debugging since
the immediately lower layer
one would need to concentrate only on a few modules
modules work without having
to detect the error. We shall elaborate these concepts
to worry about the functioning
governing layered design of modules in Section 5.4.
of the upper layer modules.
Functional independence
By the term functional independence, we mean that a module performs a single task and
needs very little interaction with other modules.
Functional independence is a key to any good design
A module that is highly cohesive
primarily due to the following advantages it offers:
and also has low coupling with
Error isolation: Whenever an error exists in a module, other modules is said to be
functional independence reduces the chances of the error functionally independent of the
propagating to the other modules. The reason behind this is other modules.
that if a module is functionally independent, its interaction
with other modules is low. Therefore, an error existing in the module is very unlikely to
affect the functioning of other modules.
Further, once a failure is detected, error isolation makes it very easy to locate the
error. On the other hand, when a module is not functionally independent, once a failure
is detected in a functionality provided by the module, the error can be potentially in any
of the large number of modules and propagated to the functioning of the module.
Scope of reuse: Reuse of a module for the development of other applications becomes
easier. The reasons for this is as follows. A functionally independent module performs some
well-defined and precise task and the interfaces of the module with other modules are
very few and simple. A functionally independent module can therefore be easily taken out
and reused in a different program. On the other hand, if a module interacts with several
other modules or the functions of a module perform very different tasks, then it would be
difficult to reuse it. This is especially so, if the module accesses the data (or code) internal
to other modules.
Understandability: When modules are functionally independent, complexity of the design
is greatly reduced. This is because of the fact that different modules can be understood in
isolation, since the modules are independent of each other. We have already pointed out
in Section 5.2 that understandability is a major advantage of a modular design. Besides the
three we have listed here, there are many other advantages of a modular design as well.
We shall not list those here, and leave it as an assignment to the reader to identify them.
Logical cohesion: A module is said to be logically cohesive, if all elements of the module
perform similar operations, such as error handling, data input, data output, etc. As an
example of logical cohesion, consider a module that contains a set of print functions to
generate various types of output reports such as grade sheets, salary slips, annual reports,
etc.
Temporal cohesion: When a module contains functions that are related by the fact that
these functions are executed in the same time span, then the module is said to possess
temporal cohesion. As an example, consider the following situation. When a computer is
booted, several functions need to be performed. These include initialisation of memory and
devices, loading the operating system, etc. When a single module performs all these tasks,
then the module can be said to exhibit temporal cohesion. Other examples of modules
having temporal cohesion are the following. Similarly, a module would exhibit temporal
cohesion, if it comprises functions for performing initialisation, or start-up, or shut-down
of some process.
Procedural cohesion: A module is said to possess procedural cohesion, if the set of
functions of the module are executed one after the other, though these functions may
work towards entirely different purposes and operate on very different data. Consider
the activities associated with order processing in a trading house. The functions login(),
place-order(), check-order(), print-bill(), place-order-on-vendor(), update-
inventory(), and logout() all do different thing and operate on different data. However,
Software Design 229
they are normally executed one after the other during typical order processing by a sales
clerk.
Communicational cohesion: A module is said to have communicational cohesion, if all
functions of the module refer to or update the same data structure. As an example of
procedural cohesion, consider a module named student in which the different functions
in the module such as admitStudent, enterMarks, printGradeSheet, etc. access and
manipulate data stored in an array named studentRecords defined within the module.
Sequential cohesion: A module is said to possess sequential cohesion, if the different
functions of the module execute in a sequence, and the output from one function is input
to the next in the sequence. As an example consider the following situation. In an on-line
store consider that after a customer requests for some item, it is first determined if the item
is in stock. In this case, if the functions create-order(), check-item-availability(),
place-order-on-vendor() are placed in a single module, then the module would exhibit
sequential cohesion. Observe that the function create-order() creates an order that is
processed by the function check-item-availability() (whether the items are available
in the required quantities in the inventory) is input to place-order-on-vendor().
Functional cohesion: A module is said to possess functional cohesion, if different functions
of the module co-operate to complete a single task. For example, a module containing all
the functions required to manage employees’ pay-roll displays functional cohesion. In this
case, all the functions of the module (e.g., computeOvertime(), computeWorkHours(),
computeDeductions(), etc.) work together to generate the payslips of the employees.
Another example of a module possessing functional cohesion has been shown in
Figure 5.4(b). In this example, the functions issue-book(), return-book(), query-book(),
and find-borrower(), together manage all activities concerned with book lending. When a
module possesses functional cohesion, then we should be able to describe what the module
does using only one simple sentence. For example, for the module of Figure 5.4(a), we can
describe the overall responsibility of the module by saying “It manages the book lending
procedure of the library.”
A simple way to determine the cohesiveness of any given module is as follows. First
examine what do the functions of the module perform. Then, try to write down a sentence
to describe the overall work performed by the module. If you need a compound sentence
to describe the functionality of the module, then it has sequential or communicational
cohesion. If you need words such as “first”, “next”, “after”, “then”, etc., then it possesses
sequential or temporal cohesion. If it needs words such as “initialise”, “setup”, “shut
down”, etc., to define its functionality, then it has temporal cohesion.
We can now make the following observation. A cohesive module is one in which the
functions interact among themselves heavily to achieve a single goal. As a result, if any
of these functions is removed to a different module, the coupling would increase as the
functions would now interact across two different modules.
interchange large amounts of data, then they are highly interdependent or coupled. We
can alternately state this concept as follows.
The interface complexity is determined based on the number of parameters and the
complexity of the parameters that are interchanged while one module invokes the functions
of the other module.
Let us now classify the different types of coupling that can exist between two modules.
Between any two interacting modules, any of the following five different types of coupling
can exist. These different types of coupling, in increasing order of their severities have also
been shown in Figure 5.5.
Data coupling: Two modules are data coupled, if they communicate using an elementary
data item that is passed as a parameter between the two, e.g. an integer, a float, a character,
etc. This data item should be problem related and not used for control purposes.
Stamp coupling: Two modules are stamp coupled, if they communicate using a composite
data item such as a record in PASCAL or a structure in C.
Control coupling: Control coupling exists between two modules, if data from one module
is used to direct the order of instruction execution in another. An example of control
coupling is a flag set in one module and tested in another module.
Common coupling: Two modules are common coupled, if they share some global data
items.
Content coupling: Content coupling exists between two modules, if they share code. That
is, a jump from one module into the code of another module can occur. Modern high-level
programming languages such as C do not support such jumps across modules.
The different types of coupling are shown schematically in Figure 5.5. The degree
of coupling increases from data coupling to content coupling. High coupling among
modules not only makes a design solution difficult to understand and maintain, but it
also increases development effort and also makes it very difficult to get these modules
developed independently by different team members.
However, other notations such as Warnier-Orr [1977, 1981] or Jackson diagrams [1975] may
also be used. Since, Warnier-Orr and Jackson’s notations are not widely used nowadays,
we shall discuss only structure charts in this text.
In a layered design solution, the modules are arranged into several layers based on
their call relationships. A module is allowed to call only
the modules that are at a lower layer. That is, a module An important characteristic
should not call a module that is either at a higher layer or feature of a good design
even in the same layer. Figure 5.6(a) shows a layered solution is layering of the
design, whereas Figure 5.6(b) shows a design that is not modules. A layered design
layered. Observe that the design solution shown in achieves control abstraction
Figure 5.6(b), is actually not layered since all the modules and is easier to understand
can be considered to be in the same layer. In the following, and debug.
we state the significance of a layered design and
subsequently we explain it.
In a layered design, the top-most module in the hierarchy can be considered as
a manager that only invokes the services of the lower level module to discharge its
responsibility. The modules at the intermediate layers offer services to their higher layer by
invoking the services of the lower layer modules and also by doing some work themselves
to a limited extent. The modules at the lowest layer are the worker modules. These do not
invoke services of any module and entirely carry out their responsibilities by themselves.
Understanding a layered design is easier since to understand one module, one would
have to at best consider the modules at the lower layers (that is, the modules whose
services it invokes). Besides, in a layered design errors are isolated, since an error in one
module can affect only the higher layer modules. As a result, in case of any failure of
a module, only the modules at the lower levels need to be investigated for the possible
error. Thus, debugging time reduces significantly in a layered design. On the other hand,
if the different modules call each other arbitrarily, then this situation would correspond
to modules arranged in a single layer. Locating an error would be both difficult and time
consuming. This is because, once a failure is observed, the cause of failure (i.e. error) can
potentially be in any module, and all modules would have to be investigated for the error.
In the following, we discuss some important concepts and terminologies associated with
a layered design:
Superordinate and subordinate modules: In a control hierarchy, a module that controls
another module is said to be superordinate to it. Conversely, a module controlled by another
module is said to be subordinate to the controller.
Visibility: A module B is said to be visible to another module A, if A directly calls B.
Thus, only the immediately lower layer modules are said to be visible to a module.
Control abstraction: In a layered design, a module should only invoke the functions of
the modules that are in the layer immediately below it. In other words, the modules at the
higher layers, should not be visible (that is, abstracted out) to the modules at the lower
layers. This is referred to as control abstraction.
Depth and width: Depth and width of a control hierarchy provide an indication of
the number of layers and the overall span of control respectively. For the design of
Figure 5.6(a), the depth is 3 and width is also 3.
232 Fundamentals of Software Engineering
Fan-out: Fan-out is a measure of the number of modules that are directly controlled by
a given module. In Figure 5.6(a), the fan-out of the module M1 is 3. A design in which
the modules have very high fan-out numbers is not a good design. The reason for this is
that a very high fan-out is an indication that the module lacks cohesion. A module having
a large fan-out (greater than 7) is likely to implement several different functions and not
just a single cohesive function.
Fan-in: Fan-in indicates the number of modules that directly invoke a given module. High
fan-in represents code reuse and is in general, desirable in a good design. In Figure 5.6(a),
the fan-in of the module M1 is 0, that of M2 is 1, and that of M5 is 2.
Each of these subfunctions may be split into more detailed subfunctions and so on.
Centralised system state: The system state can be defined as the values of certain data
items that determine the response of the system to a user action or external event. For
example, the set of books (i.e. whether borrowed by
different users or available for issue) determines the state The system state is centralised
of a library automation system. Such data in procedural and shared among different
programs usually have global scope and are shared by functions.
many modules.
For example, in the library management system, several functions such as the following
share data such as member-records for reference and updation:
create-new-member
delete-member
update-member-record
now discuss the important concepts behind an ADT. There are, in fact, three important
concepts associated with an ADT—data abstraction, data structure, data type. We discuss
these in the following subsection:
Data abstraction: The principle of data abstraction implies that how data is exactly stored
is abstracted away. This means that any entity external to the object (that is, an instance
of an ADT) would have no knowledge about how data is exactly stored, organised, and
manipulated inside the object. The entities external to the object can access the data internal
to an object only by calling certain well-defined methods supported by the object. Consider
an ADT such as a stack. The data of a stack object may internally be stored in an array, a
linearly linked list, or a bidirectional linked list. The external entities have no knowledge
of this and can access data of a stack object only through the supported operations such
as push and pop.
Data structure: A data structure is constructed from a collection of primitive data items.
Just as a civil engineer builds a large civil engineering structure using primitive building
materials such as bricks, iron rods, and cement; a programmer can construct a data
structure as an organised collection of primitive data items such as integer, floating point
numbers, characters, etc.
Data type: A type is a programming language terminology that refers to anything that
can be instantiated. For example, int, float, char, etc., are the basic data types supported
by C programming language. Thus, we can say that ADTs are user defined data types.
In object-orientation, classes are ADTs. But, what is the advantage of developing an
application using ADTs? Let us examine the three main advantages of using ADTs in
programs:
The data of objects are encapsulated within the methods. The encapsulation principle
is also known as data hiding. The encapsulation principle requires that data can be
accessed and manipulated only through the methods supported by the object and
not directly. This localises the errors. The reason for this is as follows. No program
element is allowed to change a data, except through invocation of one of the methods.
So, any error can easily be traced to the code segment changing the value. That is,
the method that changes a data item, making it erroneous can be easily identified.
An ADT-based design displays high cohesion and low coupling. Therefore, object-
oriented designs are highly modular.
Since the principle of abstraction is used, it makes the design solution easily
understandable and helps to manage complexity.
Similar objects constitute a class. In other words, each object is a member of some
class. Classes may inherit features from a super class. Conceptually, objects communicate
by message passing. Objects have their own internal data. Thus an object may exist in
different states depending the values of the internal data. In different states, an object may
behave differently. We shall elaborate these concepts in Chapter 7 and subsequently we
discuss an object-oriented design methodology in Chapter 8.
Unlike function-oriented design methods in OOD, the basic abstraction is not the
services available to the users of the system such as issue-book, display-book-
details, find-issued-books, etc., but real-world entities such as member, book,
book-register, etc. For example in OOD, an employee pay-roll software is not
developed by designing functions such as update-employee-record, get-employee-
address, etc., but by designing objects such as employees, departments, etc.
In OOD, state information exists in the form of data distributed among several
objects of the system. In contrast, in a procedural design, the state information
is available in a centralised shared data store. For example, while developing an
employee pay-roll system, the employee data such as the names of the employees,
their code numbers, basic salaries, etc., are usually implemented as global data in a
traditional programming system; whereas in an object-oriented design, these data are
distributed among different employee objects of the system. Objects communicate by
message passing. Therefore, one object may discover the state information of another
object by sending a message to it. Of course, somewhere or other the real-world
functions must be implemented.
Function-oriented techniques group functions together if, as a group, they constitute
a higher level function. On the other hand, object-oriented techniques group functions
together on the basis of the data they operate on.
To illustrate the differences between the object-oriented and the function-oriented
design approaches, let us consider an example—that of an automated fire-alarm system
for a large building.
We can now compare the function-oriented and the object-oriented approaches based on
the two examples discussed above, and easily observe the following main differences:
In a function-oriented program, the system state (data) is centralised and several
functions access and modify this central data. In case of an object-oriented program,
the state information (data) is distributed among various objects.
In the object-oriented design, data is private in different objects and these are not
available to the other objects for direct access and modification.
The basic unit of designing an object-oriented program is objects, whereas it is
functions and modules in procedural designing. Objects appear as nouns in the
problem description; whereas functions appear as verbs.
At this point, we must emphasise that it is not necessary that an object-oriented design
be implemented by using an object-oriented language only. However, an object-oriented
language such as C++ and Java support the definition of all the basic mechanisms of class,
inheritance, objects, methods, etc. and also support all key object-oriented concepts that
we have just discussed. Thus, an object-oriented language facilitates the implementation of
an OOD. However, an OOD can as well be implemented using a conventional procedural
languages—though it may require more effort to implement an OOD using a procedural
language as compared to the effort required for implementing the same design using an
object-oriented language. In fact, the older C++ compilers were essentially pre-processors
that translated C++ code into C code.
Even though object-oriented and function-oriented techniques are remarkably different
approaches to software design, yet one does not replace the other; but they complement
each other in some sense. For example, usually one applies the top-down function oriented
techniques to design the internal methods of a class, once the classes are identified. In this
case, though outwardly the system appears to have been developed in an object-oriented
fashion, but inside each class there may be a small hierarchy of functions designed in a
top-down manner.
Software Design 237
SUMMARY
A software design is typically carried out through two stages—high-level design,
and detailed design. During high-level design, the important components (modules)
of the system and their interactions are identified. During detailed design, the
algorithms and data structures are identified.
We discussed that there is no unique design solution to any problem and one needs
to choose the best solution among a set of candidate solutions. To be able to achieve
this, we identified the factors based on which a superior design can be distinguished
from a inferior design.
We discussed that understandability of a design is a major criterion determining
the goodness of a design. We characterised the understandability of design in
terms of satisfactory usage of decomposition and abstraction principles. Later, we
characterised these in terms of cohesion, coupling, layering, control abstraction,
fan-in, fan-out, etc.
We identified two fundamentally different approaches to software design—function-
oriented design and object-oriented design. We discussed the essential philosophy
governing these two approaches and argued that these two approaches to software
design are not really competing approaches but complementary approaches.
EXERCISES
TRUE OR FALSE
State whether the following statements are TRUE or FALSE. Give reasons for your answer.
1. The essence of any good function-oriented design technique is to map the functions
performing similar activities into a module.
2. Traditional procedural design is carried out top-down whereas object-oriented design
is normally carried out bottom-up.
3. Common coupling is the worst type of coupling between two modules.
4. Temporal cohesion is the worst type of cohesion that a module can have.
5. The extent to which two modules depend on each other determines the cohesion of
the two modules.
REVIEW QUESTIONS
1. Do you agree with the following assertion? A design solution that is difficult to under-
stand would lead to increased development and maintenance cost. Give reasonings
for your answer.
2. What do you mean by the terms cohesion and coupling in the context of software
design? How are these concepts useful in arriving at a good design of a system?
3. What do you mean by a modular design? How can you determine whether a given
design is modular or not?
4. Enumerate the different types of cohesion that a module in a design might exhibit.
Give examples of each.
5. Enumerate the different types of coupling that might exist between two modules.
Give examples of each.
6. Is it true that whenever you increase the cohesion of your design, coupling in the
design would automatically decrease? Justify your answer by using suitable examples.
7. What according to you are the characteristics of a good software design?
8. What do you understand by the term functional independence in the context of
software design? What are the advantages of functional independence? How can
functional independence in a software design be achieved?
9. Explain how the principles of abstraction and decomposition are used to arrive at a
good design.
10. What do you understand by information hiding in the context of software design?
Explain why a design approach based on the information hiding principle is likely
to lead to a reusable and maintainable design. Illustrate your answer with a suitable
example.
11. In the context of software development, distinguish between analysis and design with
respect to intention, methodology, and the documentation technique used.
12. Compare relative advantages of the object-oriented and function-oriented approaches
to software design.
Software Design 239
CHAPTER
6
FUNCTION-ORIENTED
SOFTWARE DESIGN
CHAPTER OUTLINE
®® Overview of SA/SD Methodology
®® Structured Analysis
®® Developing the DFD Model of a
System
®® Structured Design
®® Detailed Design
®® Design Review
F
unction-oriented design techniques were proposed nearly
LEARNING OBJECTIVES four decades ago. These techniques are at the present time
®® Basic concepts in still very popular and are currently being used in many
structured analysis and software development projects. These techniques, to start with,
structured design view a system as a black-box that provides a set of services to
®® Development of the DFD the users of the software. These services provided by a software
model of a system (e.g., issue book, serach book, etc., for a Library
®® Transformation of DFD Automation Software to its
model into a structure users are also known as the The term top-down decomposi-
chart model high-level functions supported tion is often used to denote the
by the software. During the successive decomposition of a
design process, these high- set of high-level functions into
level functions are successively more detailed functions.
decomposed into more detailed
functions.
After top-down decomposition has been carried out, the
different identified functions are mapped to modules and a
module structure is created. This module structure would
possess all the characteristics of a good design identified in
the last chapter.
In this text, we shall not focus on any specific design
methodology. Instead, we shall discuss a methodology that has
the essential features of several important function-oriented
design methodologies. Such an approach shall enable us to
easily assimilate any specific design methodology in the future
whenever the need arises. Learning a specific methodology
may become necessary for you later, since different software
development houses follow different methodologies. After all,
the different procedural design techniques can be considered as
sister techniques that have only minor differences with respect
to the methodology and notations. We shall call the design
technique discussed in this text as structured analysis/structured
design (SA/SD) methodology. This technique draws heavily from
the design methodologies proposed by the following authors:
DeMarco and Yourdon [1978]
Constantine and Yourdon [1979]
Gane and Sarson [1979]
Hatley and Pirbhai [1987]
The SA/SD technique can be used to perform the high-
level design of a software. The details of SA/SD technique are
discussed further.
As shown in Figure 6.1, the structured analysis activity transforms the SRS document
into a graphic model called the DFD model. During structured analysis, functional
decomposition of the system is achieved. That is, each function that the system needs to
perform is analysed and hierarchically decomposed into more detailed functions. On the
other hand, during structured design, all functions identified during structured analysis are
mapped to a module structure. This module structure is also called the high-level design or
the software architecture for the given problem. This is represented using a structure chart.
The high-level design stage is normally followed by a detailed design stage. During
the detailed design stage, the algorithms and data structures for the individual modules
are designed. The detailed design can directly be
implemented as a working system using a conventional It is important to understand
programming language. that the purpose of struc-
The results of structured analysis can therefore, be tured analysis is to capture
easily understood by the user. In fact, the different functions the detailed structure of the
and data in structured analysis are named using the user’s system as perceived by the
terminology. The user can therefore even review the results user, whereas the purpose of
of the structured analysis to ensure that it captures all his structured design is to define
requirements. the structure of the solution
In the following section, we first discuss how to that is suitable for implemen-
carry out structured analysis to construct the DFD model. tation in some programming
Subsequently, we discuss how the DFD model can be language.
transformed into structured design.
Function-Oriented Software Design 243
Function symbol: A function is represented using a circle. This symbol is called a process
or a bubble. Bubbles are annotated with the names of the corresponding functions (see
Figure 6.3).
External entity symbol: An external entity such as a librarian, a library member, etc.
is represented by a rectangle. The external entities are essentially those physical entities
external to the software system which interact with the system by inputting data to the
system or by consuming the data produced by the system. In addition to the human users,
the external entity symbols can be used to represent external hardware and software such
as another application software that would interact with the software being modelled.
Data flow symbol: A directed arc (or an arrow) is used as a data flow symbol. A data
flow symbol represents the data flow occurring between two processes or between an
external entity and a process in the direction of the data flow arrow. Data flow symbols
are usually annotated with the corresponding data names. For example the DFD in
Figure 6.3(a) shows three data flows—the data item number flowing from the process read-
number to validate-number, data-item flowing into read-number, and valid-number
flowing out of validate-number.
Data store symbol: A data store is represented using two parallel lines. It represents a
logical file. That is, a data store symbol can represent either a data structure or a physical
file on disk. Each data store is connected to a process by means of a data flow symbol. The
direction of the data flow arrow shows whether data is being read from or written into
a data store. An arrow flowing in or out of a data store implicitly represents the entire
Function-Oriented Software Design 245
data of the data store and hence arrows connecting to a data store need not be annotated
with the name of the corresponding data items. As an example of a data store, number is
a data store in Figure 6.3(b).
Output symbol: The output symbol is as shown in Figure 6.2. The output symbol is used
when a hard copy is produced.
The notations that we are following in this text are closer to the Yourdon’s notations
than to the other notations. You may sometimes find notations in other books that are
slightly different than those discussed here. For example, the data store may look like a
box with one end open. That is because, they may be following notations such as those
of Gane and Sarson [1979].
the DFD model of a system typically consists of several DFDs, viz., level 0 DFD, level 1
DFD, level 2 DFDs, etc., as shown in Figure 6.4 discussed in new subsection. However, a
single data dictionary should capture all the data appearing in all the DFDs constituting
the DFD model of a system.
For example, a data dictionary entry may represent that the data grossPay consists of
the components regularPay and overtimePay.
grossPay = regularPay + overtimePay
For the smallest units of data items, the data dictionary simply lists their name and their
type. Composite data items are expressed in terms of the component data items using
certain operators. The operators using which a composite data item can be expressed in
terms of its component data items are discussed subsequently.
The dictionary plays a very important role in any software development process,
especially for the following reasons:
A data dictionary provides a standard terminology for all relevant data for use by
the developers working in a project. A consistent vocabulary for data items is very
important, since in large projects different developers of the project have a tendency
to use different terms to refer to the same data, which unnecessarily causes confusion.
The data dictionary helps the developers to determine the definition of different data
structures in terms of their component elements while implementing the design.
The data dictionary helps to perform impact analysis. That is, it is possible to
determine the effect of some data on various processing activities and vice versa.
Such impact analysis is especially useful when one wants to check the impact of
changing an input value type, or a bug in some functionality, etc.
For large systems, the data dictionary can become extremely complex and voluminous.
Even moderate-sized projects can have thousands of entries in the data dictionary. It
becomes extremely difficult to maintain a voluminous dictionary manually. Computer-aided
software engineering (CASE) tools come handy to overcome this problem. Most CASE tools
usually capture the data items appearing in a DFD as the DFD is drawn, and automatically
generate the data dictionary. As a result, the designers do not have to spend almost any
effort in creating the data dictionary. These CASE tools also support some query language
facility to query about the definition and usage of data items. For example, queries may
be formulated to determine which data item affects which processes, or a process affects
which data items, or the definition and usage of specific data items, etc. Query handling is
facilitated by storing the data dictionary in a relational database management system (RDBMS).
Data definition
Composite data items can be defined in terms of primitive data items using the following
data definition operators.
+ : denotes composition of two data items, e.g. a+b represents data a and b.
[,,] : represents selection, i.e. any one of the data items listed inside the square bracket
can occur. For example, [a,b] represents either a occurs or b occurs.
() : the contents inside the bracket represent optional data which may or may not
appear.
Function-Oriented Software Design 247
FIGURE 6.4 DFD model of a system consists of a hierarchy of DFDs and a single data
dictionary.
the data items they would be receiving from the system. The various external entities
with which the system interacts and the data flow occurring between the system and the
external entities are represented. The data input to the system and the data output from the
system are represented as incoming and outgoing arrows. These data flow arrows should
be annotated with the corresponding data names.
To develop the context diagram of the system, we have to analyse the SRS document
to identify the different types of users who would be using the system and the kinds of
data they would be inputting to the system and the data they would be receiving from
the system. Here, the term users of the system also includes any external systems which
supply data to or receive data from the system.
Function-Oriented Software Design 249
Decomposition
Each bubble in the DFD represents a function performed by the system. The bubbles are
decomposed into subfunctions at the successive levels of the DFD model. Decomposition
of a bubble is also known as factoring or exploding a bubble. Each bubble at any level of
DFD is usually decomposed to anything three to seven bubbles. A few bubbles at any level
make that level superfluous. For example, if a bubble is decomposed to just one bubble or
two bubbles, then this decomposition becomes trivial and redundant. On the other hand,
too many bubbles (i.e. more than seven bubbles) at any level of a DFD makes the DFD
model hard to understand. Decomposition of a bubble should be carried on until a level
is reached at which the function of the bubble can be described using a simple algorithm.
We can now describe how to go about developing the DFD model of a system more
systematically.
1. Construction of context diagram: Examine the SRS document to determine:
Different high-level functions that the system needs to perform.
Data input to every high-level function.
Data output from every high-level function.
Interactions (data flow) among the identified high-level functions.
Represent these aspects of the high-level functions in a diagrammatic form. This would
form the top-level data flow diagram (DFD), usually called the DFD 0.
2. Construction of level 1 diagram: Examine the high-level functions described in
the SRS document. If there are three to seven high-level requirements in the SRS
document, then represent each of the high-level function in the form of a bubble.
If there are more than seven bubbles, then some of them have to be combined. If
there are less than three bubbles, then some of these have to be split.
3. Construction of lower-level diagrams: Decompose each high-level function into
its constituent subfunctions through the following set of activities:
250 Fundamentals of Software Engineering
Numbering of bubbles
It is necessary to number the different bubbles occurring in the DFD. These numbers help
in uniquely identifying any bubble in the DFD from its bubble number. The bubble at the
context level is usually assigned the number 0 to indicate that it is the 0 level DFD. Bubbles
at level 1 are numbered, 0.1, 0.2, 0.3, etc. When a bubble numbered x is decomposed, its
children bubble are numbered x.1, x.2, x.3, etc. In this numbering scheme, by looking at
the number of a bubble we can unambiguously determine its level, its ancestors, and its
successors.
Balancing DFDs
The DFD model of a system usually consists of many DFDs that are organised in a hierarchy.
In this context, a DFD is required to be balanced with respect to the corresponding bubble
of the parent DFD.
We illustrate the concept of balancing a DFD in
The data that flow into or out
Figure 6.5. In the level 1 DFD, data items d1 and d3 flow
of a bubble must match the
out of the bubble 0.1 and the data item d2 flows into the
data flow at the next level of
bubble 0.1 (shown by the dotted circle). In the next level,
DFD. This is known as balanc-
bubble 0.1 is decomposed into three DFDs (0.1.1, 0.1.2,
ing a DFD.
0.1.3). The decomposition is balanced, as d1 and d3 flow
out of the level 2 diagram and d2 flows in. Please note that
dangling arrows (d1, d2, d3) represent the data flows into or out of a diagram.
Many beginners create DFD models in which external entities appearing at all levels
of DFDs. All external entities interacting with the system should be represented only
in the context diagram. The external entities should not appear in the DFDs at any
other level.
252 Fundamentals of Software Engineering
It is a common oversight to have either too few or too many bubbles in a DFD. Only
three to seven bubbles per diagram should be allowed. This also means that each
bubble in a DFD should be decomposed three to seven bubbles in the next level.
Many beginners leave the DFDs at the different
levels of a DFD model unbalanced. It is important to realise that
A common mistake committed by many beginners a DFD represents only data
while developing a DFD model is attempting to flow, and it does not represent
represent control information in a DFD. any control information.
The following are some illustrative mistakes of trying
to represent control aspects such as:
ILLUSTRATION 1 A book can be searched in the library catalog by inputting its name.
If the book is available in the library, then the details of the book are displayed. If the
book is not listed in the catalog, then an error message is generated. While developing
the DFD model for this simple problem, many beginners commit the mistake of drawing
an arrow (as shown in Figure 6.6) to indicate that the error function is invoked after the
search book. But, this is a control information and should not be shown on the DFD.
ILLUSTRATION 2 Another type of error occurs when one tries to represent when
or in what order difierent functions (processes) are invoked. A DFD similarly should not
represent the conditions under which different functions are invoked.
ILLUSTRATION 3 If a bubble A invokes either the bubble B or the bubble C
depending upon some conditions, we need only to represent the data that flows between
bubbles A and B or bubbles A and C and not the conditions depending on which the
two modules are invoked.
A data flow arrow should not connect two data stores or even a data store with an
external entity. Thus, data cannot flow from a data store to another data store or
to an external entity without any intervening processing. As a result, a data store
should be connected only to bubbles through data flow arrows.
Function-Oriented Software Design 253
All the functionalities of the system must be captured by the DFD model. No
function of the system specified in the SRS document of the system should be
overlooked.
Only those functions of the system specified in the SRS document should be
represented. That is, the designer should not assume functionality of the system
not specified by the SRS document and then try to represent them in the DFD.
Incomplete data dictionary and data dictionary showing incorrect composition of
data items are other frequently committed mistakes.
The data and function names must be intuitive. Some students and even practicing
developers use meaningless symbolic data names such as a,b,c, etc. Such names
hinder understanding the DFD model.
Novices usually clutter their DFDs with too many data flow arrow. It becomes
difficult to understand a DFD if any bubble is associated with more than seven
data flows. When there are too many data flowing in or out of a DFD, it is better
to combine these data items into a high-level data item. Figure 6.7 shows an
example concerning how a DFD can be simplified by combining several data
flows into a single high-level data flow.
EXAMPLE 6.1 (RMS Calculating Software) A software system called RMS calculating
software would read three integral numbers from the user in the range of –1000 and
+1000 and would determine the root mean square (RMS) of the three input numbers and
display it.
254 Fundamentals of Software Engineering
In this example, the context diagram is simple to draw. The system accepts
three integers from the user and returns the result to him. This has been shown in
Figure 6.8(a). To draw the level 1 DFD, from a cursory analysis of the problem description,
we can see that there are four basic functions that the system needs to perform—accept
the input numbers from the user, validate the numbers, calculate the root mean square of
the input numbers and, then display the result. After representing these four functions in
Figure 6.8(b), we observe that the calculation of root mean square essentially consists of
the functions—calculate the squares of the input numbers, calculate the mean, and finally
calculate the root. This decomposition is shown in the level 2 DFD in Figure 6.8(c).
FIGURE 6.8 Context diagram, level 1, and level 2 DFDs for Example 6.1.
Function-Oriented Software Design 255
Example 6.1 is an almost trivial example and is only meant to illustrate the basic
methodology. Now, let us perform the structured analysis for a more complex problem.
EXAMPLE 6.3 (Supermarket Prize Scheme) A super market needs to develop a soft-
ware that would help it to automate a scheme that it plans to introduce to encourage
regular customers. In this scheme, a customer would have first register by supplying his/
her residence address, telephone number, and the driving license number. Each customer
who registers for this scheme is assigned a unique customer number (CN) by the computer.
A customer can present his CN to the checkout staff when he makes any purchase. In this
case, the value of his purchase is credited against his CN. At the end of each year, the
supermarket intends to award surprise gifts to 10 customers who make the highest total
purchase over the year. Also, it intends to award a 22 caret gold coin to every customer
whose purchase exceeded `10,000. The entries against the CN are reset on the last day of
every year after the prize winners’ lists are generated.
The context diagram for the supermarket prize scheme problem of Example 6.3 is
shown in Figure 6.10. The level 1 DFD in Figure 6.11. The level 2 DFD in Figure 6.12.
256 Fundamentals of Software Engineering
FIGURE 6.9 Context diagram and level 1 DFDs for Example 6.2.
surprise-gift-winner-list: {address+CN}*
gold-coin-winner-list: {address+CN}*
gen-winner-command: command
total-sales: {CN+integer}*
Observations: The following observations can be made from the Example 6.3.
1. The fact that the customer is issued a manually prepared customer identity card
or that the customer hands over the identity card each time he makes a purchase
has not been shown in the DFD. This is because these are item transfers occurring
outside the computer.
2. The data generate-winner-list in a way represents control information (that
is, command to the software) and no real data. We have included it in the DFD
because it simplifies the structured design process as we shall realize after we
practise solving a few problems. We could have also as well done without the
generate-winner-list data, but this could have a bit complicated the design.
3. Observe in Figure 6.11 that we have two separate stores for the customer data and
sales data. Should we have combined them into a single data store? The answer
is—No, we should not. If we had combined them into a single data store, the
structured design that would be carried out based on this model would become
complicated. Customer data and sales data have very different characteristics. For
example, customer data once created, does not change. On the other hand, the
sales data changes frequently and also the sales data is reset at the end of a year,
whereas the customer data is not.
258 Fundamentals of Software Engineering
being manually carried out, then normally there would registers corresponding to
accepted orders, pending orders, vendor list, etc.
3. We can observe that DFDs enable a software developer to develop the data domain
and functional domain model of the system at the same time. As the DFD is
refined into greater levels of detail, the analyst performs an implicit functional
decomposition. At the same time, the DFD refinement automatically results in
refinement of corresponding data items.
4. The data that are maintained in physical registers in manual processing, become
data stores in the DFD representation. Therefore, to determine which data should
be represented as a data store, it is useful to try to imagine whether a set of data
items would be maintained in a register in a manual system.
EXAMPLE 6.5 (Personal Library Software) Structured analysis for the personal library
software is shown in Figure 6.15, Figure 6.16 and Figure 6.17.
Control specifications represents the behaviour of the system in two different ways:
It contains a state transition diagram (STD). The STD is a sequential specification of
behaviour.
It contains a program activation table (PAT). The PAT is a combinatorial specification
of behaviour. PAT represents invocation sequence of bubbles in a DFD.
However, it is possible for two higher-level modules to invoke the same lower-level module.
An example of a properly layered design and another of a poorly layered design are shown
in Figure 6.18.
Transform analysis
Transform analysis identifies the primary functional components (modules) and the input
and output data for these components. The first step in transform analysis is to divide the
DFD into three types of parts:
Input.
Processing.
Output.
The input portion in the DFD includes processes that transform input data from
physical (e.g., character from terminal) to logical form (e.g., internal tables, lists, etc.). Each
input portion is called an afferent branch.
The output portion of a DFD transforms output data from logical form to physical
form. Each output portion is called an efferent branch. The remaining portion of a DFD is
called central transform.
In the next step of transform analysis, the structure chart is derived by drawing one
functional component each for the central transform, the afferent and efferent branches.
These are drawn below a root module, which would invoke these modules.
Identifying the input and output parts requires experience and skill. One possible
approach is to trace the input data until a bubble is found whose output data cannot be
deduced from its inputs alone. Processes which validate input are not central transforms.
Processes which sort input or filter data from it are central tansforms. The first level of
structure chart is produced by representing each input and output unit as a box and each
central transform as a single box.
In the third step of transform analysis, the structure chart is refined by adding
subfunctions required by each of the high-level functional components. Many levels of
functional components may be added. This process of breaking functional components into
subcomponents is called factoring. Factoring includes adding read and write modules, error-
handling modules, initialisation and termination process, identifying consumer modules
etc. The factoring process is continued until all bubbles in the DFD are represented in the
structure chart.
268 Fundamentals of Software Engineering
PROBLEM 6.1 Draw the structure chart for the RMS software of Example 6.1.
Solution: By observing the level 1 DFD of Figure 6.8, we can identify validate-input as
the afferent branch and write-output as the efferent branch. The remaining (i.e., compute-
rms) as the central transform. By applying the step 2 and step 3 of transform analysis, we
get the structure chart shown in Figure 6.19.
PROBLEM 6.2 Draw the structure chart for the tic-tac-toe software of Example 6.2.
Solution: The structure chart for the Tic-tac-toe software is shown in Figure 6.20. Observe
that the check-game-status bubble, though produces some outputs, is not really responsible
for converting logical data to physical data. On the other hand, it carries out the processing
involving checking game status. That is the main reason, why we have considered it as a
central transform and not as an efferent type of module.
Transaction analysis
Transaction analysis is an alternative to transform analysis and is useful while designing
transaction processing programs. A transaction allows the user to perform some specific
type of work by using the software. For example, ‘issue book’, ‘return book’, ‘query book’,
etc., are transactions.
As in transform analysis, first all data entering into the DFD need to be identified. In
a transaction-driven system, different data items may pass through different computation
paths through the DFD. This is in contrast to a transform centered system where each
data item entering the DFD goes through the same processing steps. Each different way
in which input data is processed is a transaction. A simple way to identify a transaction
is the following. Check the input data. The number of bubbles on which the input data to
the DFD are incident defines the number of transactions. However, some transactions may
not require any input data. These transactions can be identified based on the experience
gained from solving a large number of examples.
For each identified transaction, trace the input data to the output. All the traversed
bubbles belong to the transaction. These bubbles should be mapped to the same module
on the structure chart. In the structure chart, draw a root module and below this module
draw each identified transaction as a module. Every transaction carries a tag identifying
its type. Transaction analysis uses this tag to divide the system into transaction modules
and a transaction-center module.
PROBLEM 6.3 Draw the structure chart for the Supermarket Prize Scheme software of
Example 6.3.
Solution: The structure chart for the Supermarket Prize Scheme software is shown in
Figure 6.21.
PROBLEM 6.4 Draw the structure chart for the trade-house automation system (TAS)
software of Example 6.4.
Solution: The structure chart for the trade-house automation system (TAS) software of
Example 6.4 is shown in Figure 6.22.
By observing the level 1 DFD of Figure 6.14, we can see that the data input to the
diagram are handled by different bubbles and therefore transaction analysis is applicable to
this DFD. Input data to this DFD are handled in three different ways (accept-order, accept-
indent-request, and handle-query), we have three different transactions corresponding to
these as shown in Figure 6.22.
Word of caution
We should view transform and transaction analyses as guidelines, rather than rules. We
should apply these guidelines in the context of the problem and handle the pathogenic
cases carefully.
PROBLEM 6.5 Draw the structure chart for the personal library software of Example 6.5.
Solution: The structure chart for the personal library software is shown in Figure 6.23.
SUMMARY
In this chapter, we discussed a sample function-oriented software design methodology
called structured analysis/structured design (SA/SD) which incorporates features of
some important design methodologies.
Methodologies like SA/SD give us a recipe for developing a good design according
to the different goodness criteria we had discussed in Chapter 5.
272 Fundamentals of Software Engineering
EXERCISES