You’ve probably used software, perhaps for a word processor or spreadsheet, to solve problems. Maybe now you’re curious to learn how programmers write software. A program that is a set of step-by-step instructions that directs the computer to perform the tasks you want to do and produce the results you want. There are at least three good reasons to learn programming:
Programming helps you understand computers. A computer is just a tool. If you learn how to write simple programs, you will gain more knowledge about how computers work.
Writing a few simple programs will increase your confidence. Many people find great personal satisfaction in creating a series of instructions that solve problems.
Learning to program allows you to quickly find out whether you love programming and whether you have the analytical change of mind programmers need. Even if you decide that programming isn’t for you, understanding the process will definitely increase your appreciation of what modern programmers and computers can do.
A set of rules that provides a way to tell a computer what operations to perform is called a programming language. However, there is not only one programming language; There are many. In this chapter you will learn about controlling your computer through the programming process. You may even find that you might want to become a programmer.
An important point before we continue: You will not be a programmer after you finish reading this chapter or even after you finish reading the last chapter. Programming proficiency requires practice and training beyond the scope of this book. However, you will find out how programmers develop solutions to various problems.
What Programmers Do
In general, the programmer’s job is to turn the problem solution into instructions for the computer. That is, the programmer prepares instructions from a computer program and executes those instructions on the computer, tests the program to see if it is working properly, and makes corrections to the program. Programmers also write reports about programs. All of these activities are performed for the purpose of helping users make ends meet, such as paying employees, invoicing customers, or getting students into college. The programming activities just described can be done, perhaps, as solo activities, but programmers usually interact with a variety of people. For example, if a program is part of a system of several programs, programmers coordinate with other programmers to ensure that these programs are compatible with each other. If you are a programmer, you may also have coordination meetings with users, managers, systems analysts, and with colleagues evaluating your work – just as you would evaluate their work.
Let’s move on to the programming process.
- Programming Process
- Developing a program involves steps that are similar to problem solving tasks. There are five main ingredients in the programming process:
- Defining the problem
- Planning the solution
- Coding the program
- Testing the program
- Documenting the program
Let’s discuss each of these in turn.
Defining the Problem
Suppose, as a programmer, you were contacted because your service was needed. You meet users from client organizations to analyze problems, or you meet with systems analysts who describe projects. In particular, the task of defining the problem consists of identifying what you know (the data provided by the input), and what you want to get (the results). Finally, you come up with a written agreement that, among other things, determines the type of input, processing, and output required. This is not a simple process.
Plan for a Solution
Figure 1: Flow Chart Symbols and Flow Chart For Letters
Two common ways to plan a solution to a problem are to draw a flowchart and write pseudocodes, or perhaps both. Basically, a flowchart is a pictorial representation of a step-by-step solution to a problem. It consists of arrows representing the direction the program is taking and boxes and other symbols representing actions. This is a map of what your program will do and how to do it. The American National Standards Institute (ANSI) has developed a standard set of flow chart symbols. Figure 1 shows symbols and how they can be used in a simple flowchart of a common everyday action – preparing a letter for delivery.
Pseudocode is a non-standard language like English that allows you to express your solution with more precision than you can in plain English but with less precision than is required when using a formal programming language. Pseudocode allows you to focus on program logic without having to worry about the exact syntax of a particular programming language. However, pseudocodes cannot be run on the computer. We will illustrate this later in this chapter, when we focus on language examples.
As a programmer, your next step is to code – that is, to express your solution in a programming language. You’ll translate the logic from a flowchart or pseudocode – or some other tool – into a programming language. As we have noted, a programming language is a set of rules that provides a way of instructing the computer what operations to perform. There are many programming languages: BASIC, COBOL, Pascal, FORTRAN, and C are some examples. You may find yourself working with one or more of these. We will discuss the various types of languages in detail later in this chapter. Although programming languages operate in a grammatical manner, much like English, they are much more precise.
To run your program, You have to follow exactly the rules-syntax-language you use. Of course, using the language correctly does not guarantee that your program will work, just as speaking grammatically correct English means that you know what you are talking about. The bottom line is that using correct language is an obligatory first step. Then your code program should be locked, perhaps using a terminal or personal computer, in a form that the computer can understand.
One more note here: Programmers usually use text editors, which are similar to word processing programs, to create files that contain the program. However, as a beginner, you may want to write your code on paper first.
Testing the Program
Some experts insist that a well-designed program can be written right the first time. In fact, they asserted that there is a mathematical way to prove that a program is correct. However, the imperfections of the world are still with us, so most programmers are used to the idea that a program they just wrote might have some errors. This is a bit disappointing at first, as programmers tend to be precise, careful, detail-oriented people who take pride in their work. However, there are still plenty of opportunities for introducing errors into the program, and you, like those who have done it before you, will probably come across some of them. Finally, after coding the program, you should be prepared to test it on your computer.
Check the table. This phase, similar to proofreading, is sometimes avoided by programmers who are looking for shortcuts and are eager to run programs on their computer after they have been written. However, with a careful desk check you may find some mistakes and it might save you time in the long run. In a table check, you can simply sit down and mentally explore, or examine, the program logic to try to ensure that it is error-free and enforceable. Many organizations take this phase a step further with guidance, a process in which a group of your fellow programmers reviews your program and offers collegial advice.
Translating. A translator is a program that (1) checks the syntax of your program to make sure the programming language is being used correctly, gives you all syntax error messages, which are called diagnostics, and (2) then translates your program into a form that a computer can understand. A byproduct of this process is that translators tell you if you have used a programming language incorrectly. This type of error is called a syntax error.
The translator generates descriptive error messages. For example, if in FORTRAN you typed incorrectly N = 2 * (I + J)) – which has two closing brackets instead of one – you will get a message that says, “PARENTS ARE NOT COMPATIBLE”. (Different translators may give different wordings for error messages. ) The program is most often translated by the compiler. The compiler translates your entire program at one time. Translation involves your native program, called a source module, which the compiler converts into an object module. Pre-written programs from the system library can be added during the link / load phase, which results in a load module. The load module can then be run by the computer.
Debugging. A term widely used in programming, debugging means detecting, finding, and fixing bugs (errors), usually by running a program. This bug is a logic error, such as telling the computer to repeat an operation but not telling how to stop repeating. In this phase you run the program using the test data you created. You must plan the test data carefully to ensure you are testing every part of the program.
Documenting the Program
Documenting is an ongoing and necessary process, although, like most programmers, you may be excited to pursue a more engaging, computer-centric activity. Documentation is a detailed written description of the programming cycle and specific facts about the program. Typical program documentation materials include the origin and nature of the problem, a brief narrative description of the program, logical tools such as flowcharts and pseudocode, data-record descriptions, program lists, and test results. Comments within the program itself are also considered an important part of the documentation.
Many programmers document as they code. In a broader sense, program documentation can become part of the documentation for the whole system. The wise programmer continues to document the program during design, development, and testing. Documentation is needed to supplement human memory and to help organize program planning.
In addition, documentation is essential for communicating with other people who have an interest in the program, especially other programmers who may be part of the programming team. And, because of the high turnover in the computer industry, written documentation is required so that those who come after you can make the necessary modifications in the program or track down any errors you missed.
Programming as a Career
There is a shortage of qualified personnel in the computer field. Before you join their ranks, consider the advantages of the computer field and what it takes to succeed in it. Fun in the Field
Although many people make career changes to the computer field, only a few choose to leave it. In fact, surveys of computer professionals, especially programmers, consistently report high levels of job satisfaction. There are several reasons for this satisfaction. One of them is the least routine job-challenge in the computer industry. The other is security, as established computer professionals can usually find jobs. And the job is profitable – you may not be rich, but you have to be comfortable. The computer industry has historically been a lucrative place for women and minorities. And, finally, this industry has endless appeal because it is always changing.
What it takes
You will of course need several credentials, most often a two or four year degree in computer information systems or computer science. Requirements and salaries vary by organization and region, so we won’t cover them here. Also, the people most likely to get a job and move up the career ladder are people with excellent communication skills, both oral and written. This is also a quality that potential employers can observe in an interview. Promotion is sometimes associated with an advanced degree (MBA or MS in computer science).
Open the door
The overall prospects for the computer field are promising. The Bureau of Labor Statistics demonstrated, throughout 2010, a 72 percent increase in programmers and a 69 percent increase in use of current systems, and we will discuss the most popular ones later in this chapter. However, before we move on to a specific language, we need to discuss the language level.