Forgot your password?

Learn How To Program A Computer - First Programming Design Steps

By Edited Sep 20, 2016 0 0

How do you learn how to program a computer? In order to write a computer program, you must have some understanding of what it the computer should do. Remember that the computer has no thinking abilities. When people discuss computers thinking about some issue, it is really a computer programmer's program that is performing the actions. No, you must provide all instructions to the computer. If you want numbers added together, you must instruct the computer to do so with a program. If a computer program is not provided, the computer will do nothing useful. Instead, it will continually review the operating environment searching for a computer program to execute.

In order to get the computer to do something, we must provide a valid program, or software. The actual machinery of the computer is known as hardware. Hopefully we provide a useful program but that is not a requirement. A huge amount of computer time has been spent on mundane tasks such as screen savers or simplistic games. In order to provide a valid program, you should think about what it is that you need the computer to do. Computer software design is the process where a programmer specifies the tasks to eventually be executed by the computer. This design can be performed using pictures or with pseudocode. Pseudocodeis any set of procedural statements that can be understood by the software designer and the programmer. For example, a pseudocode program to perform addition can be expressed as follows:

Get some numbers
add all given numbers together
display the total sum on the computer screen
if the resulting sum is 459 then inform the user that they have won a free trip to Europe

The above is called an algorithm. It is a method that allows computer designs to be developed quickly without the cost of the labor intensive programming needed to implement the design. The steps are presented in an overview fashion at first. The program design specifies "get some numbers". This expresses a basic requirement of the program. At this stage, the design leaves a lot of flexibility to the computer programmer. Before actual programming begins, the designer would return to this statement and modify it to read "get some numbers from the user". Further detail will give the programmer highly targeted instructions. "Get some numbers from the user via the keyboard" is much more specific and should result in a program that matches the intent of the design. Eventually the design will be in detail that accurately depicts what is necessary in the computer program. A programmer can take the detailed design and implement a matching program that can be validated by a comparison to the design. Using the pseudocode algorithm from above, a valid matching Python program might be:

number = 0
user_input = -1
while user_input != "0":
user_input = input("Enter a number, or zero to quit: ")
number = number + int(user_input)

if number == 459:
print("Congratulations, you have won a free trip to Europe")

Given the algorithm, there are many different programs that could be written to implement the design. The computer programming process is quite creative so variable program results are to be expected. This is usually not a problem at all if the computer design is specific enough. Designs will start as very general steps:

get input
add numbers

They will then become more detailed and specific in order to guide the work of the programmer:

get input from the user via the keyboard until the user signifies the end
add given numbers together
display the total on the screen
if the total = 459 inform the user that they have won a trip to Europe
If the user won the trip, provide contact information allowing them to claim the trip

If any errors are detected at this stage, or if further processing steps are inserted, modification of the pseudocode is much easier than similar changes to the implemented computer program. In fact, large computer applications will have extensive work performed on their design for many months before any actual programming is started. Small applications, like those a beginner may undertake, will have comparatively little pseudocode design work. Because of the tedious steps necessary for most computer programming languages, the existence of a pseudocode design will often be quite helpful even for small programming efforts.

Pseudocode designs should largely mimic the abilities of the target computer language, especially as they become more detailed. There is little use in specifying extensive graphic object handling in the target language doesn't support this concept. In this case, the pseudocode could identify that the target language is not appropriate for the task. For our purposes, we will use Python so a general pseudocode will be fine. Python supports program loops, condition tests and basic input/output of information. The language can be extended to support very elaborate concepts. These may be covered in future articles.

The Python looping, (for the beginner to use), consists of "while" and "for" loops. "While" loops execute when a particular condition is true. For example, while numbers entered are not zero, a loop may continue. When a zero is entered, the loop stops and the computer executes the next instruction. A "for" loop executes for a specific number of instances. Here is an example of the for loop:

for i in range(10):

This loop prints 0, 1, 2, ... 9. Remember that computer sequences generally start at zero unless we take steps to change them.

Using the while and for loops, computer programs can be developed to perform the necessary tasks. You can specify a high level design for practically any task and refine it into more detail over time. Carried to the extreme, an overview algorithm might be:

get user input
perform the desired action
display results

Adding detail would create the example from above:
Get some numbers
add all given numbers together
display the total sum on the computer screen

Expanding further, we might get the following:
While the user wants to perform math
Get some input from the user, check to ensure that only numbers are given
ask for the desired operation, (addition, subtraction, division, multiplication)
perform the given operation
display the result on the computer screen
If there is a special operation to perform for certain results, perform the special operation

Using the computer software design technique of pseudocode for algorithms, the beginner can develop elaborate applications in a minimum of time. By expanding on the design, the algorithm will become closer to an actual computer program. By the time the programmer receives the design, it will have been extensively validated. The resultant computer program will produce results expected by the pseudocode design. The design and the program will represent a released version of the application. Subsequent changes to the design can again be implemented by a programmer when new versions are required.

Remember that the computer is basically a very simple machine that is capable of executing the complicated programs that we write for it. For educational purposes, we can write very simple programs that are easy to understand. Later we can add complexity as knowledge and skills improve. This makes computer programming a skill that can be learned in stages. In fact, children may be able to learn how to program a computer from an early age. How old do children have to be? While there is no clear answer to this, they should be capable of applying the discipline necessary to understand abstract issues. An 8 year old child might be totally able to program a computer. Parents should encourage such children to learn how to program a computer. Remember that programming is not just for boys. While girls are rare in the computer technology field, programming is a great skill for girls to learn as well.



Add a new comment - No HTML
You must be logged in and verified to post a comment. Please log in or sign up to comment.

Explore InfoBarrel

Auto Business & Money Entertainment Environment Health History Home & Garden InfoBarrel University Lifestyle Sports Technology Travel & Places
© Copyright 2008 - 2016 by Hinzie Media Inc. Terms of Service Privacy Policy XML Sitemap

Follow IB Technology