Showing posts with label Program Development. Show all posts
Showing posts with label Program Development. Show all posts

Wednesday, March 19, 2014

DEVELOPING A PROGRAM

 The computer has emerged as the most useful machine in recent times. It can perform a
variety of tasks like receiving data, processing it, and producing useful results. However, being a
machine, the computer cannot perform on its own. A computer needs to be instructed to perform
even a simple task like adding two numbers. Computers work on a set of instructions called
computer program, which clearly specify the ways to carry out a task. An analogy of this may be
thought of as the instructions given by the manager or team leader to its team. The team
members follow those instructions and accordingly perform their duties. Similarly, a computer
also takes instructions, in the form of computer programs, and carries out the requested task.
Now the questions arises how human beings instruct computers. We, as human beings,
use natural languages such as English, Spanish, or French to communicate. Similarly, a user
communicates with the computer in a language understood by it. Note that human beings cannot
interact directly with the computer using natural languages because thus far we have not
developed such computers that can comprehend natural languages. Rather the instructions,
provided in the form of computer programs, are developed using computer or programming
 languages. This chapter will provide some of the most prominent concepts related to computer
programming and languages.

A program consists of a series of instructions that a computer processes to perform the
required operation. In addition, it also includes some fixed data, required to perform the
instructions, and the process of defining those instructions and data. Thus, in order to design a
program, a programmer must determine three basic rudiments:
  • The instructions to be performed.
  • The order in which those instructions are to be performed. 
  • The data required to perform those instructions.
To perform a task using a program, a programmer has to consider various inputs of the
program along with the process, which is required to convert the input into desired output.
Suppose we want to calculate the sum of two numbers, A and B, and store the sum in C, here A
and B are the inputs addition is the process, and C is the output of the program.
Development of a Program:
A program is a seat of instructions that instructs a computer how toperform a specific task. It is written in a high level language that can be implemented on a number of different processors. A collection of  programs can be compared to a recipe book, where each recipe can be assumed as a program. Every recipe has a list of ingredients (fixed data) and a list of instructions detailing exactly what to do with those ingredients. When you follow a recipe, you are actually executing a program.

Program Development Cycle (Steps In Developing a Program)

Before starting the process of writing a program (coding), the programmer has to
determine the problem that needs to be solved. There are different approaches to problem
solving. Most require breaking the problem into a series of smaller steps, independent of the
programming languages. One common technique is to use the program development cycle, with
the number of steps the may vary according to the person who has formalized the development.
Often the process runs in a loop, for example, as the current process is completed, new demands
appear and the development process commences again. Development cycle of a program
includes the following phases:
a) Analyse/Define the problem:
Firstly, the problem is analyzed precisely and completely. Based on understanding, the
developer knows about the scope within which the problem needs to be developed.
b) Task Analysis:
After analyzing the problem, the developer needs to develop various solutions to solve
the given problem. From these solutions, the optimum solution (by experimenting with all the
solutions) is chosen, which can solve the problem comfortably and economically.
c) Developing Algorithm:
After selecting the appropriate solution, algorithm is developed to depict the basic logic
of the selected solution. An algorithm depicts the solution in logical steps (sequence of
instructions). Further, algorithm is represented by flowcharts and pseudo codes. These tools
make program logic clear and they eventually help in coding.
d) Testing the Algorithm for Accuracy:
Before converting the algorithms into actual code, it should be checked for accuracy. The
main purpose of checking algorithm is to identify major logical errors at an early stage, because
logical errors are often difficult to detect and correct at later stages. The testing also ensures that
the algorithm is a “true” one and it should work for both normal as well as unusual data.
e) Coding:
After meeting all the design considerations, the actual coding of the program takes place
in the chosen programming language. Depending upon application domain and available
resources, a program can be written by using computer languages of different levels such as
machine, assemble or high-level languages.
f) Test and Debug the Program:
It is common for the initial program code to contain errors. A program compiler and
programmer-designed test data machine tests the code for syntax errors. The results obtained an
compared with results calculated manually from this test data. Depending upon the complexity
of the program, several rounds of testing may be required.
g) Documentation:
Once the program is free from all the errors, it is the duty of the program developers to
ensure that the program is supported by suitable documentation. These documents should be
supplied to the program users. Documenting a program enables the user to operate the program
correctly. It also enables other persons to understand the program clearly so that it may, if
necessary, be modified, or corrected by someone other than the original programmer.
h) Implementation:
After performing all the above-mentioned steps, the program is installed on the end user’s
machine. In this stage, users are also provided with all the essential documents so that they can
understand how the program works. The implementation can be viewed as the final testing
because only after using the program, the user can point out the drawbacks, if any to the
developers. Based on the feedback, the programmers can modify or enhance the program.
i) Maintenance and Enhancement:
After the program is implemented, it should be properly maintained taking care of the
changing requirements of its users and system. The program should be regularly enhanced by
adding additional capabilities. This phase is also concerned with detecting and fixing the errors,
which were missed in testing phase. Since this step generates user feedback, the programming
cycle continues as the program modified or reconstructed to meet the changing needs.

ALGORITHM

Algorithms are one of the most basic tools that are used to develop the problem solving
logic. An algorithm is defined as a sequence of clear instructions that, when provided with a set
of input values produces an output and then terminates. To be an algorithm, the steps must be
unambiguous and after a finite number of steps, the solution of the problem is achieved.
However, algorithms can have steps that repeat (iterate0 or require decisions (logic and
comparison) until the task is completed.
Different algorithms may accomplish the same task, with a different set of instructions, in
more or less the same time, space, and efforts. For example, two different recipes for preparing
tea, one ‘add the sugar’ while ‘boiling the water’ and the other ‘after boiling the water’ produce the
same result. However, performing an algorithm correctly does not guarantee a solution, if the
algorithm is flawed or not appropriate to the context. For example, preparing the tea algorithm will
fail if there are no tea leaves present; even if all the motions of preparing the tea are performed as if
the tea leaves were there. We use algorithms in our daily life. For example, to determine the
largest number out of three numbers A, B, and C, the following algorithm may be used.
Step 1 : Start
Step 2 : Read three numbers say A,B,C
Step 3 : Find the larger number between A and B and store it in
MAX_AB.
Step 4 : Find the larger number between MAX_AB and C and store it
in MAX.
Step 5 : Display MAX
Step 6 : Stop

The above-mentioned algorithm terminates after six steps. This explains the feature of finiteness. Once the solution is properly designed, the only job left is to code that logic into a Algorithm Properties.
Properties of Algorithm are:
  • There must be no ambiguity in any instruction.
  • There should not be an uncertainty about which instruction is to be executed next.
  • The description of the algorithm must be finite. An algorithm cannot be open-ended.
  • The execution of the algorithm should conclude after a finite number of steps.
  • The algorithm must be general enough to deal with any contingency.

FLOWCHART

A flowchart is a pictorial representation of an algorithm in which the steps are drawn in
the form of different shapes of boxes and the logical flow is indicated by interconnecting arrows.
The boxes represent operations and the arrows represent the sequence in which the operations are
implemented. The primary purpose of the flowchart is to help the programmer in understanding
the logic of the program. Therefore, it is always not necessary to include all the required steps in
detail. Flowcharts outline the general procedure. Since they provide an alternative, visual way
of representing the information flow in a program, program developers often find them very
valuable.
Flow charts can be compared within the blueprint of a building. Just as an architect
draws a blueprint before starting the construction of a building, a programmer draws a flowchart
before writing a computer program. As in the case of the drawing of a blueprint, the flowchart is
drawn according to defined rules and using standard flowchart symbols prescribed by American
National Standard institute (ANSI). Some standard symbols that are frequently required for
flowcharts are shown:

Benefits of Flowcharts



A flowchart helps to clarify how things are currently working and how they could be
improved. It also assists in finding the key elements of a process by drawing clear lines between
the end of one process and the start of next one.
a) Makes Logic Clear:
The main advantage of using a flowchart is to plan a task is that it provides a pictorial
representation of the task, which makes the logic easier to follow. The symbols are connected in
such a way that they show the movement (flow) of information through the system visible. Even
less experienced personnel can trace the actions represented by a flowchart, that is, flowcharts
are ideal for visualizing fundamental control structures employed in computer programming.
b) Communication:
Being a graphical representation of a problem-solving logic, flowcharts are better way of
communicating the logic of a system to all concerned. The diagrammatical representation of
logic is easier to communicate to all the interested parties as compared to actual program code as
the user may not be aware of all the programming techniques and jargons.
c) Effective Analysis:
With the help of a flowchart, the problem can be analysed in an effective way. This is
because the analyzing duties of the programmers can be delegated to other persons, who may or
may not know the programming techniques, as they have a broad idea about the logic. Being
outsiders, they often tend to test and analyse the logic in an unbiased manner.
d) Useful in Coding:
The flowcharts act as a guide or blueprint during the analysis and program development
phase. Once the flowcharts are ready, the programmers can plan the coding process effectively
as they know where to begin and where to end, making sure that no steps are omitted. As a
result, error free programs are developed in high-level languages and that too at a faster rate.
e) Proper Testing and Debugging:
By nature, a flowchart helps in detecting the errors in a program, as the developers
known exactly what the logic should do. Developers can test various data for a process so that
the program can handle every contingency.
f) Appropriate Documentation:
Flowcharts serve as a good program documentation tool. Since normally they programs
are developed for novice users, they can take the help of the program documentation to know
what the program actually does and how to use the program.

Flowcharting: Examples

1. Draw a flowchart to find the sum of first 50 natural numbers.

2. Draw a flowchart to find the largest of three numbers A, B, and C.

3. Draw a flowchart for computing factorial N (N!)
Where N! = 1 ´ 2 ´ 3 ´ …… N.