CMTE Lecture 4 & 5
CMTE Lecture 4 & 5
Class 4 & 5
G R K Gupta, MED
SOFTWARE DEVELOPMENT PROCESS
(Reference: Numerical Methods for Engineers by Chapra & Canale)
G.R.K.Gupta
MED
Computing Environments
1. Zero Generation Computers (pre-1951) – Manual and Mechanical
2. First Generation Computers (1951-58) – Computers with Vacuum Tubes
3. Second Generation Computers (1958-1964) – Computers with
Transistors
4. Third Generation Computers (1964-1971) – Computers with Integrated
Circuits
5. Fourth Generation Computers (1971-2010) – Computers with
Microprocessors
6. Fifth Generation Computers (2011-present) – Computers with VLSI
7. Sixth Generation Computers (Future) – Super Computers with AI
Stepwise Process for Writing a Program
1. Defining the Problem
2. Problem Formulation
3. Design of Algorithm – Developing the underlying logic of the program in
logical stepwise procedure
4. Flow Charting – Graphical representation of the algorithm
5. Pseudo Code – uses code like symbols with fundamental control structures
6. Program Composition – Writing the program in high level language
7. Debugging – deals with correcting known errors
8. Testing – with varied data to make it more reliable
9. Documentation – to make it easy to use and understand
10.Storage and Maintainance – backup and upgrading
Programming Style
9
Pseudocode
Pseudeocode is an alternative way to express an
algorithm that bridges the gap between flow chart and
computer code.
This technique used codelike statements in place of the
graphical symbols of a flowchart.
Algorithm, Flow
chart and Pseudocode
for the problem of
adding two numbers
Top-Down Design Example
15
• Selection. Splits the program’s
flow into branches based on
outcome of a logical condition.
• Repetition. A means to implement instructions repeatedly.
(IF/THEN/ELSEIF Ladder, SWITCH/CASE)
17
The Fundamental Structures
19
20
Fundamental Control Structures
Pseudocode
for counting
the average
quiz grade
High Level Languages
1.BASIC – Beginner’s All purpose Symbolic Instruction Code
- Interpreter
2.FORTRAN 77 – FORmula TRANslation
3.PASCAL
4.C
5.C++
6.MATLAB – Matrix Laboratory
7.COBOL – COmmon Business Oriented Language
24
DEBUGGING: ERROR ANALYSIS
Types of Errors:
1. Syntax Errors: during compiling phase - violates the rules of the
language such as spelling, number formation, and other conventions.
These errors will be indicated during compiling through error diagonstics
(missing parenthesis, missing semicolon, printing undefined variable etc.
2. Link or Build Errors: during the link phase – misspelled name of a
function – “unresolved external reference”
3. Run-time Errors: during program execution – “divide by zero”, “square
root of a negative number”, “floating overflow”, etc.
4. Logical errors: due to faulty programming logic – will not be indicated
in error diagnostics. “infinite loop”, “wrong formulation””etc.
Debugging
One of the following happen when an error occurs
1. An explicit diagnostic can provide you with the exact location and the
nature of the error.
2. A diagnostic may occur but the exact location of the error is unclear.
3. No diagnostics occur but the program does not operate properly.
We have to Debug in one of the following ways
1. Print out intermediate results.
2. Locate the module with error by printing the results at the entry and exit
of each module.
3. Debug independent modules before integrating them
4. Scan the code line by line doing calculation and checking the values to
identify the exact location of the error.
5. Check from the beginning…formulation of the problem itself.
Testing
One of the greatest misconceptions of the novice programmer is the
belief that, if a prog ram runs and prints out results, the job is done.
To ensure that such cases do not occur, the program must be subjected to
a battery of tests for which the correct answer is known beforehand.
Phases of Testing
1. Module Tests: The modules are run in isolation to determine that they are
executing properly.
2. Development Tests: They are implemented as the modules are integrated into
the total program package. A test is performed after each module is integrated
with a top-down approach that starts with the first module and progresses
down through the program in execution sequence.
3. Whole system tests: After the total program has been assembled, it is
subjected to a series of whole system tests by exposing them to (a) Typical
data, (b) Unusual but valid data, and (c) incorrect data to check the program’s
error handling capabilities.
4. Operational Tests: (Beta testing phase) – To test how the program runs in a
realistic setting. A standard way is to have the ultimate user to implement the
program.
Documentation
Sufficient documentation is to be included to allow the users to
immediately understand the program and how it can be
implemented. It needs
(b)External Documentation.
Internal Documentation
1. Include a module at the head of the program giving program’s title, your
name, date. This is your signature and marks the program as your work.
2. Include a second module to define each of the key variables.
3. Select the variable names that are reflective of the type of information the
variables are to store.
4. Insert spaces within statements to make them easier to read.
5. Use comment statements liberally throughout the program to add explanation
and to skip lines for the purpose of labeling, clarity, and separation of
modules.
6. In particular, use comment statements to clearly label and set off all the
modules.
7. Use indentation to clarify the program structures. In particular, to set off loops
and decisions.
External Documentation.
1. This refers to instructions in the form of output messages and
supplementary printed matter.
2. The messages occur when the program runs and are intended to make
the output attractive and user-friendly.
3. This involves effective use of spaces, blank lines, special characters
etc. to illuminate the logical sequence of structure of the program
results.
4. The program can designed to output descriptive error messages to alert
and inform the user regarding problems.
5. The making of a comprehensive user manual (user’s manual).
Storage and Maintainance
1.When you sign off the computer, your active file will be
destroyed. To retain the program for later use, you must transfer it
to a secondary storage device such as hard disk.
2.It has two other major tasks.
(a) Upgrading the program in light of experience: To gather
feedback regarding suggested improvements in design.
(b) Ensuring that the program is safely stored: A backup copy
should always be created before making major code changes.