User Menu

Login



Share with

Programming Methodoly PDF Print E-mail

Programming Methodology

Introduction

Computerized information systems are developed to provide computer solutions to the user problems. If all the requirements of the user are served by the computerised solution, the user is satisfied enough. Thus, the software should be designed effectively so as to meet its objective of user satisfaction. A systematic approach in software design should be adopted to develop an acceptable and efficient solution.

General Concept

Developing a good program is a skill and writing a good program is a quality habit. This good habit can be developed by consciously following the guidelines being covered under this section.

i).Meaningful names for identifiers-:

Identifiers identify different parts of a C++ program. Therefore, identifiers should have meaningful names. Following guidelines should be followed while dealing with identifiers:

1.Assign meaningful names for all identifiers viz. Variables functions and procedures, etc.

2.Do not use similar looking names e.g., manage, manager.

3.Always assign names to scalar constants when it helps in clarity and readability.

ii).Ensure clarity of expressions -:

Expressions carry out the specified action(s). Thus they must be clearly understood by the users. 

iii).Use comments and indentation :-

Comments play a very important role as they provide internal documentation of a program. An indentation makes the statements clear and readable.

In C++ comments are given either by // or /* ....*/ brackets.

Always insert prologues, the comments in the beginning of a program that summarises the purpose of the program. Example prologues are given below:

Insert explanatory comments.

Always indent statements.

Insert Blanks Lines and Blank Spaces.

The blank spaces may beaded before operators like +, -, *, / and %, =, >, <, >=, <=, <> etc. and characters like /*, */, //, comma etc, to improve preventability and readability.

ROBUSTNESS

The ability of a program to recover following an error and to continue operating within its environment is known as Robustness.

Guard Code-: The code which can handle exceptional data errors and operational errors is called guard code.

CHARACTERISTICS OF A GOOD PROGRAM-:

A program written in a good style is easily understandable to a reader.

Effective and Efficient-: should produce correct result and should be faster, taking into account memory constrains.

User Friendly-: should interact with the user by understandable messages.

Self documenting code-: use of meaningful names to identifiers and appropriate use of comments and indentation.

Reliable-: must be able to handle unexpected situations like input of wrong data or no data input.

Portable-:

Should be able to execute on different platforms.

STAGES OF PROGRAM DEVELOPMENT-:

•Crack the problem :Involves understanding the problem, identifying minimum number of inputs, step-by-step solution.

•Problem is cracked and an algorithm is formulated.

•Code the Algorithm: algorithm is translated into a program (source code) using a programming language. This process is called coding.

•Compile the program: compilation is the process to convert the source code into the object code (code in machine language).

•Execute the program.

TYPES OF ERRORS

There are broadly three types of errors:

1.Compile Time

2.Run-time

3.Logical

Compile Time Errors

-Errors that occurs during compile time

-There are two types of compile time errors:

1. Syntax errors:

* When rules of a programming language are misused. i.e. when grammatical rules of C++ is violated.

* (Syntax refers to formal rules governing the construction of valid statement in a language.)

//Incorrect

#include<iostream.h>

#include<conio.h>

void main()

(

int number,

char name,

getch();

)

//Correct

#include<iostream.h>

#include<conio.h>

void main()

{

int number;

char name;

getch();

}

2.Semantic errors:

* When statements are not meaningful.

* A*B = Z is incorrect since an expression cannot come on the left side of an assignment statement.

3.Run-Time Errors:

- Errors that occurs during the execution of the program.

- E.g. Infinite loop, wrong input given e.g. divide error, opening a file which does not exist.

 

Logical Errors:

Incorrect implementations of an algorithm are logical errors.

Result in incorrect results, even though no errors at the time of compilation or run-time.

1.Use of a variable before initialisation, wrong parameters passed in function.

2.If we are making a c++ program to find the sum of two numbers and in the place of "+" we write "-".This will cause a logical error.

scroll back to top