Lecture 2
Program Development Life Cycle
Dr. Rasha Montaser
Dr. Shaimaa Elmorsy
The Program Development Life Cycle
• Creating new programs is called program
development.
• The process associated with creating successful
applications programs is called the program
development life cycle (PDLC).
The Program Development
Life Cycle (PDLC)
• Program Development
(application software
development)
– The process of
creating application
programs
• Program Development
Life Cycle (PDLC)
– The five phases of
program development
Program Analysis
1- Problem Analysis
• During problem analysis, a systems analyst and programmer
review specifications and talk with users to fully understand
what the software should do.
• Documentation consists of:
• Program specifications,
• Timetable,
• Which language will be used,
• How the program will be tested,
• What documentation is required.
2-Program design
Program Design:
Program Design Tools
Program design tools are planning tools.
1. Program flowcharts
2. Pseudocode
Program Design:
Program Design Tools
• Program flowcharts
‒ use geometric symbols and familiar relational
operators to provide a graphic display of the
sequence of steps involved in a program.
‒ The steps in a flowchart follow each other in the
same logical sequence as their corresponding
program statements will follow in a program.
‒ Different symbols are used to represent different
actions, such as start/stop, decision,
input/output, processing, and looping symbols.
Program Design: Control Structures
Sequence
A sequence control structure is simply a series of
procedures that follow one another.
Statement Statement Statement ...
Program Design: Control Structures
Selection
The selection (if-then-else) control structure involves a
choice: if a certain condition is true, then follow one
procedure; else, if false, follow another.
When more than two possible choices exist, the case
control structure can be used instead.
Statement1
Condition ...
Statement
Statement2
Program Design: Control Structures
Iteration
Loop is an operation that repeats until a certain
condition is met.
A looping (iteration) control structure can take two
forms.
With the do-while structure, the loop is executed as
long as a condition is true; with the do-until structure, the
loop continues until a certain condition becomes true.
False
...
Condition
Statement
Sequence Structure
• A series of actions are performed in sequence
after each other
Example
• Draw a flowchart that asks the user to enter the
length of the square side and then calculate the area.
Example
• Draw a flowchart that asks the user to enter the
length of the square side and then calculate the area.
Start
read the
side length
Area=Length2
Stop
Example
• Draw a flowchart that reads two numbers and print
their summation.
Example
• Draw a flowchart that reads two numbers and print
their summation.
Decision Structure
• The flowchart segment and code below show how a decision
structure in a flowchart is expressed in C++ as an if/else
statement.
Flowchart C++ Code
NO YES if (x < y)
x < y? a = x * 2;
else
Calculate a Calculate a a = x + y;
as x plus y. as x times 2.
Example
• Draw a flowchart which ask the user to enter a
number and then print if the number is negative or
positive (assume it will print positive for 0)
Decision Structure
• The flowchart segment below shows a decision
structure with only one action to perform. It is
expressed as an if statement in C++ code.
Flowchart
C++ Code
NO YES
if (x < y)
x < y?
a = x * 2;
Calculate a
as x times 2.
Example
• Draw a flowchart which ask the user to enter a
number and then print it’s absolute value.
Example
• Draw a flow chart which asks the user to enter a
number and then print if the number is within or
outside a given limit [5,20]
Combining Structures
• This flowchart segment shows two decision
structures combined.
NO YES
x > min?
Display “x is NO YES
outside the limits.”
x < max?
Display “x is Display “x is
outside the limits.” within limits.”
Repetition Structure
• The flowchart segment below shows a repetition
structure expressed in C++ as a while loop.
C++ Code
Flowchart
while (x < y)
x++;
YES
x < y? Add 1 to x
Example
• Draw a flowchart which asks the user to enter 20 number and
then print their average
Controlling a Repetition Structure
• The action performed by a repetition structure
must eventually cause the loop to terminate.
Otherwise, an infinite loop is created.
• In this flowchart segment, x is never changed.
Once the loop starts, it will never end.
• QUESTION: How can this
flowchart be modified so YES
it is no longer an infinite x < 10? Display x
loop?
30
Controlling a Repetition Structure
• ANSWER: By adding an action within the repetition
that changes the value of x.
YES
x < 10? Display x Add 1 to x
31
Connectors
•The “A” connector
A
indicates that the second START
flowchart segment begins
where the first segment
ends.
END
A
32
Examples
Example: Average of 10 Numbers –
iteration with a while loop
Begin
i = 0
sum = 0
while i < 10
input x
sum = sum + x
Increment i
avg = sum / 10.0
print avg
End
Examples
Example: Average of 10
Numbers – iteration with a while
loop
Begin
i = 0
sum = 0
while i < 10
input x
sum = sum + x
Increment i
avg = sum / 10.0
print avg
End
Program Design:
Program Design Tools
Pseudocode
uses English-like statements in place of the
graphic symbols of the flowchart.
Unlike a flowchart, pseudocode is easy to
modify and can be embedded into a program
as comments.
No standard set of rules exists for writing
pseudocode, although a number of
conventions have been developed.
Pseudocode
Write a pseudocode algorithm that computes the area
of the circle
Problem: Calculate and display the area of the circle
Discussion: Uses mathematical knowledge, that is area =
r2
Output: area of the circle
Input: radius of the circle
Processing: Find the area of the circle;
area = 3.14 * radius * radius
pseudocode algorithm
• Input: radius
• Output: area
• Process: area= pi*r*r
• Type: sequence
Start
input radius
area=pi*radius*radius
output area
end
Class Average Algorithm
• Write a Pseudocode algorithm that Calculate the grade average
for a class (100 student)
• Problem: Calculate the grade average for a class
• Discussion: The average grade equals the sum of all grades
divided by the number of students
• Output: Average grade
• Input: Student grades
• Processing: Find the sum of the grades; count the
number of students; calculate average
Write a Pseudocode algorithm that Calculate
the grade average for a class (100 student)
Pseudocode
Initialize Counter and Sum to 0
Do While there are more grades
Get the next Grade
Add the Grade to the Sum
Increment the Counter
Loop
Compute Average = Sum / Counter
Display Average
Pseudocode
Write a pseudocode algorithm that display passed if student
grade is greater than or equal to 60 and display failed if
student grade is less than 60
Input: grade
Output: pass/fail Start
Process: input grade
if grade >=60 pass if grade >=60
else fail print pass
Type: dec. else
print fail
end
Coding
3- PDLC- Program Coding
• Coding: actual process of creating the program in a programming
language.
• Programming language must be chosen.
• Coding standards should be adhered to.
• Make use of reusable code and data dictionaries.
• Translate coded programs into executable code.
Program Coding
• The coded program is referred to as source code.
to be executed, the program is converted by the
computer to object code using a special program.
• A compiler translates the entire program into machine
language before executing it. The program then doesn’t
need to be recompiled until it is modified.
• An interpreter translates program statements one at a
time. Interpreters are helpful during the debugging
stage, but are slower during execution of the finished
program.
• An assembler converts assembly-language statements
into machine language.
4- Debugging and testing
4- PDLC- Program Debugging and
Testing
• Debugging: process of making sure a program is free
of errors or bugs.
• Preliminary bugging often finds syntax or logic errors.
• Testing can consist of alpha or beta testing.
Program Debugging and Testing
• Preliminary debugging begins after the program has been
entered into the computer system. Rarely is a program error-
free the first time it runs. Two common types of errors are
syntax errors and logic errors.
– A syntax error: occurs when the programmer has not
followed the syntax rules of the language.
– A logic error, or execution-time error: results when the
command syntax is correct but the program is producing
incorrect results due to incorrect equation or design.
– A run time error: occurs at running time of a program as
e.g. dividing by zero or access not found file.
Example of Syntax error
Example of logic error
Example of runtime error
Program Debugging and Testing
• At some point in the preliminary debugging process, the
program will appear to be correct. At this point, the
programmer, or preferably someone else, will run the
original program with extensive test data.
• Good test data will subject the program to all the
conditions it might conceivably encounter when finally
implemented.
• Most companies run on-site alpha tests to test programs;
companies in the business of selling software also
commonly run beta tests by distributing preliminary
versions of the program to outside users.
5- Program Maintenance
• Program maintenance: process of updating software so that it
continues to be useful.
• A costly process, but can be used to extend the life of a program.
• Documentation consists of amended program package reflecting
what problems occurred and what program changes were made.
What Is a Programming Language?
A programming language is a set of
rules used to write instructions to the
computer.
Categories of Programming Languages
• Machine and assembly languages are called low-level
languages, because programmers who code in them
must write instructions at the finest level of detail, the
base level of the hardware.
• Although virtually no one writes machine-language
programs anymore, all programs must be translated by a
language translator into machine language before they
are executed.
• Assembly languages are fast and consume little storage
when compared with higher-level languages, but take
longer to write and maintain.
Categories of Programming Languages
High-level languages differ from their low-level
predecessors in that they require less coding detail and
make programs easier to write.
Programs written in a high-level language (BASIC,
COBOL,
Pascal, C, Java, or Python, etc.) need to be translated
into machine language before they can be
executed. They use a translator which is either a
compiler or an Interpreter.
Popular Programming Languages
• FORTRAN BASIC and Visual Basic
C, C++, and C#
• COBOL
Java
• Pascal