You are on page 1of 8

Homework 4

CAP 314

Principles of Software Engineering

SUBMITTED TO-
Deepak Sir

SUBMITTED BY-
SACHIN RAJ
B34
D3901
PART A

Q.1. Apply a "stepwise refinement approach" to develop three


different levels of procedural abstraction for one or more of
the following programs:
a. Develop a check writer that, given a numeric dollar amount,
will print the amount
in words normally required on a check.
b. Iteratively solve for the roots of a transcendental equation.
c. Develop a simple round-robin scheduling algorithm for an
operating system.
Ans-

Refinement 1:
write dollar amount in words
Refinement 2:
procedure write_amount;
validate amount is within bounds;
parse to determine each dollar unit;
generate alpha representation;
end write_amount
Refinement 3:
procedure write_amount;
do while checks remain to be printed
if dollar amount > upper amount bound
then print "amount too large error
message;
else set process flag true;
endif;
determine maximum significant digit;
do while (process flag true and
significant digits remain)
set for corresponded alpha phrase;
divide to determine whole number
value;
concatenate partial alpha string;
reduce significant digit count by
one;
enddo
print alpha string;
enddo
end write_amount
Q.2. Discuss the relationship between the concept of
information hiding as an attribute of effective modularity and
the concept of module independence.
Ans-
Information hiding can be related to both coupling and
cohesion concepts. By limiting the availability of information to
only those modules that have absolute need, coupling between
modules is inherently reduced. In general, isolation of
information predicates isolation of function; therefore,
cohesion of individual modules can also be
improved.
Information hiding as an attribute of effective modularity
Information Hiding implies that effective modularity can be
achieved by defining a set of independent modules that
communicate with one another only that information necessary
to achieve software function. Abstraction helps to define the
procedural (or informational) entities that make up the
software.
The use of information hiding as a design criterion for modular
systems provides the greatest benefits when modifications are
required during testing and later, during software maintenance.
concept of module independence
The concept of Module independence is a direct outgrowth of
modularity and the concepts of abstraction and information
hiding.
Functional independence is achieved by developing modules with
single-minded function and an aversion to excessive
interaction with other modules.
Independent modules are easier to maintain (and test) because
secondary effects caused by design or code modification are
limited, error propagation is reduced, and reusable modules are
possible.
Q.3. Develop two additional design principles that “reduce
the user’s memory load.”
Ans-
If the user desires, display shortcut command sequences on
the screen at all times. Provide the facilities for "hints" when a
WebApp requires passwordinput.
Other Also Can Be Possible
• Reduce demand on short-term memory. Provide visual cues
that enable a user to recognize past actions, rather than
having to recall them.
It means we have provide easy interface to customer
that will help to customer easily.and we also need to
provide simple functionality(simple module coding,array)etc.
• Establish meaningful defaults. A user should be able to
specify individual preferences; however, a reset option
should be available to enable the redefinition of original
default values.
Define shortcuts that are intuitive.
If i am creating a software then we must need to use
shortcuts keys,that helps to customer remember. This is the
best way to “reduce the user’s memory load.”
PART B

Q.4. All modern programming languages implement the


structured programming constructs. Provide examples from
three programming languages.
Ans-
C language structured programming constructs
C is an imperative (procedural) systems implementation
language. It was designed to be compiled using a relatively
straightforward compiler, to provide low-level access to
memory, to provide language constructs that map efficiently to
machine instructions, and to require minimal run-time support.
C was therefore useful for many applications that had formerly
been coded in assembly language.
Java structured programming constructs
Java applications are typically compiled to bytecode (class file)
that can run on any Java Virtual Machine (JVM) regardless of
computer architecture. Java is a general-purpose, concurrent,
class-based, object-oriented language that is specifically
designed to have as few implementation dependencies as
possible. It is intended to let application developers "write
once, run anywhere". Java is currently one of the most popular
programming languages in use, and is widely used from
application software to web applications.
Pascal structured programming constructs
Pascal, in its original form, is a purely procedural language and
includes the traditional array of ALGOL-like control structures
with reserved words such as if, then, else, while, for, and so on.
However, Pascal also has many data structuring facilities and
other abstractions which were not included in the original
ALGOL 60, like type definitions, records, pointers,
enumerations, and sets.
Q.5. A program reads three integer values. The three values
are interpreted as representing the lengths of the sides of a
triangle. The program prints a message that states whether
the triangle is scalene, isosceles, or equilateral. Develop a set
of test cases that you feel will adequately test this program.
Ans-
In a valid triangle, no side may have a length of zero or less,
and each side must be shorter than the sum of all sides divided
by 2.
Equilateral triangle: all sides are of equal length.
Isosceles triangle: two sides are of equal length.
Scalene triangle: all sides are of unequal length.
Q.6. If you could select only three test case design methods
to apply during unit testing, what would they be and why?
Ans-
If only three test case design methods could be selected
during unit test they would be:
1. Basis path testing—it's critically important to ensure that
all statements in the program have been exercised.
2. Equivalence partitioning—an effective blackbox test at the
module level.
3. Boundary value analysis—"bugs lurk in corners and
congregate at boundaries.”
Naturally, good arguments can be made for other combinations
of test case design techniques.