1
PROGRAMMING
CONCEPTS
Chapter 3
Introduction
2


Computers are only as good as their hardware ,
their softwere and the people using them
The programmer have three recourses needed to
optimize for effectiveness :



computer memory
computer time
programmer time
Introduction
3




Old days programmers worked alone small
memories and slow.
Programs hard to mountain and read
Over the years computers and programming
methods changed
The instructions must be understand by the computer
(syntax)
Communicating with the computer
4





you have to learn its system of communication or
language .
The meaning of an instruction is essentially the same
in many computer language or application.
Syntax refers to the rules governing the computer
operating system , the application, and the
languages.
An errors is called a bug .
A process called debugging .
Communicating with the computer
5


many bugs are result of syntax errors but some
are logic errors .
All syntax errors must be corrected before you
execute and test your program .
Organizing the Problem
6


Certain organizational tools will help you learn to
solve problems on the computer .
The tools include the:
 Problem
Analysis Chart (PAC)
 Structure/Interactivity Charts
 Input Processing Output (IPO) Chart
 Algorithms.
 Flowcharts
Organizing the problem
7


1.
2.
3.
4.
To analyze a problem and set up the most efficient
solution, a programmer organizes the solution by
using all or some of these tools.
If not use these tools :
the solution takes longer to program .
the final program is less efficient .
lacks readability .
increases programmer frustration.
Analyzing the problem
8



1.
2.
3.
Understand the Problem
Analyze the Requirements of the Problem
A good way to analyze a problem is to separate
it into four parts, problem analysis chart( PAC) :
The given data.(constant and variables)
The required results.(the out put)
The processing that is required in the problem
.(equations and expressions)
4.
A list of solution alternatives .
Problem Analysis Chart (PAC)
9
PAC Payroll Example
10
Calculate the gross pay of an employee. The formula
to be used is
GrossPay=Hours*PayRate
Develop PAC for a solution to this problem?
PAC Payroll Example
11
Interactivity (Structure) Chart
12




Divide processing into subtasks called modules
Then connect these modules together to show the
interaction of processing between modules.
Each modules should contain the tasks to
accomplish one function.
There will be one module that controls the flow to
most of other modules called the Control or main
module .
Interactivity (Structure) Chart
13





Use the top down method.
Divide the problem into subtasks .
Illustrate them in the order in which they will be
processed from the top to the bottom of the chart.
The module that encompasses the complete solution
becomes what is called the control module because
it controls the processing of all the data .
The subtasks of this module are then located below
it in the structure chart .
The Interactivity Chart
14
The Interactivity Chart
15




Indicates duplicate modules by darkening the upper
left-hand corner of each module.
The darkened circles indicate that the module is
part of a set of modules that are processed many
time – those in loop .
The diamond on the vertical line above the box
indicates which modules are involved in a decision .
Annotation may be placed beside the circle or
diamond to indicate the condition
16
The Interactivity Chart for the Payroll
Problem
17
Developing Input Processing Output
(IPO) Chart

IPO chart shows:
 What
data item are input
 What processing takes place on that data
 What information will be the end result, the output
 Where in the solution the processing takes place.
The IPO Chart for the Payroll Problem
18
 The
module references are show which will perform
each step in the processing
Writing the Algorithm
19



The next step of organizing a solution is to develop
sets of instructions for the computer, called
algorithms.
The programmer writes a separate set of instructions
for each module in the structure chart .
The number of instruction is determined by the way
the programmer chooses to solve the problem .
20
The Form of an Algorithm
The Control module uses an End since this is the end of the processing
. The other modules use Exit because the processing continues .
•
Drawing the Flowchart
21




Graphic representations of the algorithms.
The algorithms and flowcharts are the final steps in
organizing a solution.
A flowcharts shows the flow of the processing from
the beginning to the end of a solution.
Each block in a flowchart represents one instruction
from an algorithm.
Drawing the Flowchart
22






Flowlines indicate the direction of the data flow.
Most block have one or more entrances
Most block have only one exit .
Since ,in most cases , data can flow to only one other
block .
Exception a block representing a decision instruction
A loop enables the computer to perform a task
repeatedly during the processing of solution .
Flowchart Symbols
23
24
Flowchart Symbols
25
The algorithms and Flowcharts
for the Payroll Problem
26
The algorithms and Flowcharts
for the Payroll Problem
27
28
Order of
Execution of
Instructions
Algorithm and Flowchart Form
29
Documentation
30


Internal documentation consists of remarks written
with the instructions to explain what is being done in
the program .
External documentation is made up of the manuals
or help menus written about the solution .
Internal Documentation
31


proper internal documentation ensures that the new
programmer will be able to learn about the
program in the least amount of time .
Include such things as :
 People
who worked on the program
 Variable usage
 Note about the development of the program
External Documentation
32



For the user of the program .
Allow the end user to find the answers to questions .
Should include :
 Tutorials
.
 Input definition .
 Usage instruction.
 Installation instruction .
 Command explanations .

Include any thing that allow the user to learn to use
the program in the least amount of time .
Testing the solution
33


Test the a solution to make sure it meet the
requirements of the user ,and to check for errors in
logic or in the setup of the expressions and equations .
To test the solution :
 Select
the data
 A set of value for the input data
 Works them through every step in the solution .
 If
a bug is detected the solution has to be modified to
correct it.
Coding the solution
34



After determining that the solution is correct
Select the appropriate language
Code the program
Download

The IPO Chart for the Payroll Problem