Program Design and Implementation

Program Design and Implementation

Program Design

TOP-DOWN DESIGN

Usually a top-down method is used for designing and writing a program. in top-down design

the main function of a program is expressed as simply as possible. This function is then split

up into more detailed separate procedures. These are then further split and so on. The process

finishes when the program has been split down to the level of the separate statements of the computer language being used.

The process of dividing parts of a program into gradually more detailed parts is called

stepwise refinement.

Simple example of stepwise refinement

Program function: input three numbers and print out their average.

First level of refinement:

(a) Input three numbers

(b) Calculate total and average

(c) Print numbers and their average

Second level of refinement:

In this simple example the next level would be separate program statements.

A program for the above example is written below in the language Pascal. Note that in Pascal:

1 Statements end with a semi-colon.

2 All variables used in a program have to be declared first in a V AR statement.

3 The first level of refinement is shown at the end of the program, after the final BEGIN

statement.

If you are not familiar with Pascal you may find COMAL easier to understand. The same

program has been written in COMAL

PROGRAM Average_Three_Numbers;

(*input three numbers and printout their average*)

VAR

Num1, Num2,Num3, Total, Average: REAL;

PROCEDURE input_Three_Numbers;

BEGIN

WRITELN (The Average of Three Numbers’);

WRITELN;

WRITE (‘Please type your first number ‘); READ (Num1);

WRITE (‘Please type your Second number ‘); READ (Num2);

WRITE (‘Please type your third number ‘); READ (Num3);

END;

PROCEDURE (Calculate-total-and-Average;

BEGIN

Total :=Num1+Num2+Num3;

Average:=total/3

End;

PROCEDURE (print-numbers-and-Average ;

BEGIN

WRITELN (The Numbers are: -‘ ,Numl,Num2,Num3);

WRITELN (‘Their average is : -‘ .Average);

END;

BEGIN

Input_ Three_Numbers:

Celculate_ Totalcand_Average:

Print_Numbers_and_Average;

END.

STEPS IN PRODUCING A PROGRAM

If it is decided that the solution of a problem requires a new program then the main steps

followed are:

1 Program design.

2 Program writing.

3 Testing and debugging.

4 Documentation, implementation and maintenance.

Program design

1 Function definition

The general system design is used to decide precisely what the program is to do. This design

may be in the form of system flowcharts. In any case it is necessary to define:

(a) The data requirements of the program-inputs, outputs and files.

(b) The processing function-what the program is to do with the data.

2 First level of refinement

(a) The data to be used is defined in detail. This includes arrays .

(b) The main operations of the program are defined-possibly using a structure diagram or an outline program flowchart .

Program writing

1Each operation is worked out in detail. If necessary this may be done using detailed

program flowcharts or structure diagrams.

2 The program is then coded. To code a program means to write it out in a suitable language.

3 The program is entered into a computer. (This may be done as the program is coded.)

Testing and debugging

1 If a compiler is used, errors are first eliminated which prevent the program from being

compiled .

2 Any further errors are eliminated which prevent the program from running.

3 The program is run with test data.

Test data is data which has been carefully chosen to tryout every feature of a program (or flowchart) to make sure that it carries out its intended function. It is important to make sure that:

(a) The test data provides a check on every possible situation.

(b) The correct results of running the program with the test data have been worked out

manually beforehand.

4 The programmer uses various debugging aids to correct the program until the expected output is produced when the test data is used .

Note: For a complex program it is very difficult to test every possible situation. Professional

programmers concentrate on designing and writing programs methodically so that they do not have errors.

1 The time saved in debugging is well worth the extra work in the early stages.

2 Programs with a lot of errors which need patching up are not as easy to read and to maintain

as those which are well written to start with. Examination candidates writing project programs would do well to note this.

Documentation, implementation and maintenance

1 Before a program can be made available for use it is necessary to produce documentation for users and programmers .

2 The new system of which the program forms part then has to be implemented and maintained .

Leave a comment

Your email address will not be published. Required fields are marked *

Program Design and Implementation

Program Design and Implementation

Program Design

TOP-DOWN DESIGN

Usually a top-down method is used for designing and writing a program. in top-down design

the main function of a program is expressed as simply as possible. This function is then split

up into more detailed separate procedures. These are then further split and so on. The process

finishes when the program has been split down to the level of the separate statements of the computer language being used.

The process of dividing parts of a program into gradually more detailed parts is called

stepwise refinement.

Simple example of stepwise refinement

Program function: input three numbers and print out their average.

First level of refinement:

(a) Input three numbers

(b) Calculate total and average

(c) Print numbers and their average

Second level of refinement:

In this simple example the next level would be separate program statements.

A program for the above example is written below in the language Pascal. Note that in Pascal:

1 Statements end with a semi-colon.

2 All variables used in a program have to be declared first in a V AR statement.

3 The first level of refinement is shown at the end of the program, after the final BEGIN

statement.

If you are not familiar with Pascal you may find COMAL easier to understand. The same

program has been written in COMAL

PROGRAM Average_Three_Numbers;

(*input three numbers and printout their average*)

VAR

Num1, Num2,Num3, Total, Average: REAL;

PROCEDURE input_Three_Numbers;

BEGIN

WRITELN (The Average of Three Numbers’);

WRITELN;

WRITE (‘Please type your first number ‘); READ (Num1);

WRITE (‘Please type your Second number ‘); READ (Num2);

WRITE (‘Please type your third number ‘); READ (Num3);

END;

PROCEDURE (Calculate-total-and-Average;

BEGIN

Total :=Num1+Num2+Num3;

Average:=total/3

End;

PROCEDURE (print-numbers-and-Average ;

BEGIN

WRITELN (The Numbers are: -‘ ,Numl,Num2,Num3);

WRITELN (‘Their average is : -‘ .Average);

END;

BEGIN

Input_ Three_Numbers:

Celculate_ Totalcand_Average:

Print_Numbers_and_Average;

END.

STEPS IN PRODUCING A PROGRAM

If it is decided that the solution of a problem requires a new program then the main steps

followed are:

1 Program design.

2 Program writing.

3 Testing and debugging.

4 Documentation, implementation and maintenance.

Program design

1 Function definition

The general system design is used to decide precisely what the program is to do. This design

may be in the form of system flowcharts. In any case it is necessary to define:

(a) The data requirements of the program-inputs, outputs and files.

(b) The processing function-what the program is to do with the data.

2 First level of refinement

(a) The data to be used is defined in detail. This includes arrays .

(b) The main operations of the program are defined-possibly using a structure diagram or an outline program flowchart .

Program writing

1Each operation is worked out in detail. If necessary this may be done using detailed

program flowcharts or structure diagrams.

2 The program is then coded. To code a program means to write it out in a suitable language.

3 The program is entered into a computer. (This may be done as the program is coded.)

Testing and debugging

1 If a compiler is used, errors are first eliminated which prevent the program from being

compiled .

2 Any further errors are eliminated which prevent the program from running.

3 The program is run with test data.

Test data is data which has been carefully chosen to tryout every feature of a program (or flowchart) to make sure that it carries out its intended function. It is important to make sure that:

(a) The test data provides a check on every possible situation.

(b) The correct results of running the program with the test data have been worked out

manually beforehand.

4 The programmer uses various debugging aids to correct the program until the expected output is produced when the test data is used .

Note: For a complex program it is very difficult to test every possible situation. Professional

programmers concentrate on designing and writing programs methodically so that they do not have errors.

1 The time saved in debugging is well worth the extra work in the early stages.

2 Programs with a lot of errors which need patching up are not as easy to read and to maintain

as those which are well written to start with. Examination candidates writing project programs would do well to note this.

Documentation, implementation and maintenance

1 Before a program can be made available for use it is necessary to produce documentation for users and programmers .

2 The new system of which the program forms part then has to be implemented and maintained .

Leave a comment

Your email address will not be published. Required fields are marked *