programming concepts chapter 3 1. introduction computers are only as good as their hardware, their...

34
PROGRAMMING CONCEPTS Chapter 3 1

Upload: kerry-gibson

Post on 01-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

PROGRAMMING CONCEPTS

Chapter 3

1

Introduction

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

2

Introduction

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)

3

Communicating with the computer4

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 computer5

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 Problem6

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

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 :1. the solution takes longer to program .2. the final program is less efficient .3. lacks readability .4. increases programmer frustration.

7

Analyzing the problem8

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) :

1. The given data.(constant and variables)

2. The required results.(the out put)

3. The processing that is required in the problem .(equations and expressions)

4. A list of solution alternatives .

9

Problem Analysis Chart (PAC)

PAC Payroll Example10

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 Example11

Interactivity (Structure) Chart12

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 Chart14

The Interactivity Chart15

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

The Interactivity Chart for the Payroll Problem

16

Developing Input Processing Output (IPO) Chart

17

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

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 .

19

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 Flowchart21

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 Flowchart22

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 Symbols25

The algorithms and Flowcharts for the Payroll Problem

26

The algorithms and Flowcharts

for the Payroll Problem27

Order of Execution of Instructions

28

Algorithm and Flowchart Form

29

Documentation30

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 Documentation31

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 Documentation32

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 solution33

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 solution34

After determining that the solution is correct

Select the appropriate language Code the program