Module1_Part2
Module1_Part2
The style of writing programs and the set of capabilities and limitations that a particular
programming language has depends on the programming paradigm it supports.
Programs written using monolithic programming languages consist of global data and sequential
code. The global data can be accessed and modified from any part of the program.
The object-oriented paradigm is task-based and data-based. In this paradigm, all the
relevant data and tasks are grouped together in entities known as objects. It treats
data as a critical element in the program development and restricts its flow freely
around the system.
The striking features of OOP include the following:
Output of one phase provides the input for its subsequent phase.
Requirements Analysis
•In this phase, users’ expectations are gathered to know why the
program/software has to be built.
•The solution of the program is then specified for each module in the form of
algorithms, flowcharts, or pseudocodes.
Implementation
•Designed algorithms are converted into program code using any of the high level
languages.
•The choice of language depends on the type of program like whether it is a system or
an application program.
•While constructing the code, the development team checks whether the software is
compatible with the available hardware and other software components that were
mentioned in the Requirements Specification Document created in the first phase.
© Oxford University Press 2016. All rights reserved.
Design and Implementation of Efficient
Programs
Testing
•All the modules are tested together to ensure that the overall system works well as a
whole product.
•Although individual pieces of codes are already tested by the programmers in the
implementation phase, there is always a chance for bugs to creep in the program when the
individual modules are integrated to form the overall program structure.
•Software is tested using a large number of varied inputs also known as test data to ensure
that the software is working as expected by the users’ requirements that were identified in
the requirements analysis phase.
•Software Training and Support is a crucial phase which makes the end users familiar with
how to use the software.
•Moreover, people are often resistant to change and avoid venturing into an unfamiliar
area, so as a part of the deployment phase, it has become very crucial to have training
classes for the users of the software.
© Oxford University Press 2016. All rights reserved.
Design and Implementation of Efficient
Programs
Maintenance
•Maintenance and enhancements are ongoing activities which are done to cope with
newly discovered problems or new requirements.
•Such activities may take a long time to complete as the requirement may call for
addition of new code that does not fit the original design or an extra piece of code
required to fix an unforeseen problem.
•As a general rule, if the cost of the maintenance phase exceeds 25% of the prior-
phases cost then it clearly indicates that the overall quality of at least one prior phase is
poor. In such cases, it is better to re-build the software (or some modules) before
maintenance cost is out of control.
11
© Oxford University Press 2016. All rights reserved.
Algorithms
• An algorithm provides a blueprint for writing a program to solve a particular
problem.
• It is considered to be an effective procedure for solving a problem in a finite
number of steps.
• A well-defined algorithm always provides an answer, and is guaranteed to
terminate.
• Algorithms are mainly used to achieve software re-use.
• A good algorithm must have the following characteristics
Be precise
Be unambiguous
Not even a single instruction must be repeated infinitely
After the algorithm gets terminated, the desired result must be
obtained © Oxford University Press 2016. All rights reserved.
Control Structures used in Algorithms
Sequence
Sequence means that each step of the algorithm is executed in the specified order.
Decision
Decision statements are used when the outcome of the process depends on some
condition. For example, if x=y, then print “EQUAL”. Hence, the general form of the if
construct can be given as
if condition then process
Repetition
Repetition, which involves executing one or more steps for a number of times, can be
implemented using constructs such as while, do-while, and for loops. These loops
execute one or more steps until some condition is true.
Run-time Errors occur when the program is being run executed. Such errors
occur when the program performs some illegal operation like
Run-time errors may terminate program execution, so the code must be written
in such a way that it handles all sorts of unexpected errors rather terminating it
unexpectedly. This ability to continue operation of a program despite of run-
time errors is called robustness.
Semantic Errors Semantic errors are those errors which may comply with rules
of the programming language but are not meaningful to the compiler. For
example, if we write, a * b = c; it does not seem correct. Rather, if written like c
= a * b would have been more meaningful.
Such errors are not detected by the compiler, and programmers must check their code
line by line or use a debugger to locate and rectify the errors.
Logical errors occur due to incorrect statements. For example, if you meant to perform c
= a + b; and by mistake you typed c = a * b; then though this statement is syntactically
correct it is logically wrong.
Linker Errors occur when the linker is not able to find the function definition for a given
prototype. For example, if you write clrscr(); but do not include conio.h then a linker error
will be shown.
© Oxford University Press 2016. All rights reserved.
Testing Approaches
Testing is an activity that is performed to verify correct behavior of a program. It
is specifically carried out with an intent to find errors.
Integration Tests are a logical extension of unit tests. In this test, two units that
have already been tested are combined into a component and the interface
between them is tested. This process is repeated until all the modules are tested
together. The main focus of integration testing is to identify errors that occur
when the units are combined.
System testing checks the entire system. For example, if our program code
consists of three modules then each of the module is tested individually using
unit tests and then system test is applied to test this entire system as one
system.
• It is done to locate errors in the program code. Once located, errors are then isolated
and fixed to produce an error-free code. Different approaches applied for debugging a
code includes:
Brute-Force Method: In this technique, a printout of CPU registers and relevant memory
locations is taken, studied, and documented. It is the least efficient way of debugging a
program and is generally done when all the other methods fail.
Backtracking Method: works by locating the first symptom of error and then trace
backward across the entire source code until the real cause of error is detected.
However, the main drawback of this approach is that with increase in number of source
code lines, the possible backward paths become too large to manage.
Cause Elimination: lists all possible causes of an error is developed. Then relevant tests
are carried out to eliminate each of them. If some tests indicate that a particular cause
may be responsible for an error then the data are refined to isolate the error.