Steps of programming


Download 18.12 Kb.
Sana19.04.2023
Hajmi18.12 Kb.
#1365941
Bog'liq
Steps of programming 1


Steps of programming
All programming involves creating something that solves a problem. The problems can range from something of great scientific or national importance, through to something as trivial as relieving personal boredom!
This section describes one approach to solving such problems - think of it as a rough guide to the things you should do when entering the land of programming.
In broad terms, those things are:

  1. Identify the Problem

  2. Design a Solution

  3. Write the Program

  4. Check the Solution

Of these, only the third step is usually called "programming", but as you'll see later, it's probably the least important stage of the process.
Identify the Problem
In fact, this stage should really be called identifying the solution because what you're really trying to do is to tie down exactly what it is that you're trying achieve.
There are two stages to identifying a solution:

  • Requirements

  • Specification

Requirements
The first step is to examine the problem carefully to try to identify what qualifies as a solution. A single problem may have many different solutions, but they will all have something in common. So here you're trying to work out exactly what your program will be required to do.

For example, if we were asked to write a calculator program, we could choose many different ways for the user to enter calculations - from entering equations, pressing buttons or even writing them on the screen - but if the software can't add up correctly then it won't have solved the problem. Therefore our first few requirements must be that:

  • the user can enter sums (we don't care how they do this)

  • and that the program will then evaluate those sums correctly
    and display the result for the user.

We also have to decide what sort of sums our calculator will be required to evaluate. Again, we have a fair amount of choice - we could be ambitious and ask it to solve simultaneous equations or complex expressions, however since this is our first program we should probably make the requirements more simple. So the third requirement is that:

  • The calculator must be able to evaluate sums made up of two whole numbers (integer operands) and one addition (+), subtraction (-), multiplication (*) or division (/) sign (operator).

Note that computer scientists traditionally use * instead of x and / instead of � to indicate multiplication and division respectively.
Thus our calculator must be able to deal with sums like 1 + 1, 10 - 6, 43 * 5 and 42 / 7. However it won't have to handle 67.345 + 6¼, the cube root of PI or 152.

Specification
The second step is to then look at the list of requirements and to decide exactly what your solution should do to fulfil them. As we mentioned above, there are usually many different solutions to a single problem; here, your aim is to decide on which of those solutions you want. Therefore, you're trying to specify, in a fairly accurate manner, just what it is your final program will do.

For example, for the calculator, we've already decided that the program must allow us to enter simple sums and then must evaluate them correctly and display an answer. We must now tie down exactly what this means.
Therefore, we have to decide which method of entering sums to use. We could specify any one of a number of methods, but for now, we'll choose a simple method. We should also specify what other behaviour we're expecting the program to have:

  • When the program runs it will display a welcome message, followed by some simple instructions.

  • The program will then display a prompt sign ([number]>) and the user can then type the first number of their sum at the keyboard followed by the RETURN (<-') key.

  • The program will display a second prompt sign ([+-/*]>) and the user can then enter the operator that they wish to use, followed by RETURN.

  • A third prompt sign will be displayed ([number]>) and the user will then enter the second number, again followed by RETURN.

  • The calculator program will then display the mathematically correct answer to the sum on the screen and end.

By the time you have worked out your specification, you should have a very clear idea of what your final program will do: your goal.
Download 18.12 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling