Steps in implementing a program and key programming terms
GOOD DAY, students. This is lesson 28 in our series of lessons. In this week’s lesson, we will be looking at key programming terms from the program implementation unit.
PREVIOUS KNOWLEDGE
You should be exposed to different programming languages and the translation process of a code from source code to object code.
STEPS IN IMPLEMENTING A PROGRAM
1. Creation of a source code – This is the code written in a low- or high-level language. 2. Compiling the program – This is used for converting a program into a machine-code or lower-level form in which the program can be executed. The converting process further involves the translating of the source code via a link (on some computer systems, this step may not be visible to the user). Linking – This is combining various pieces of code and data together to form a single, executable object code that can be loaded in memory. Linking can be done at compile time, at loadtime, and also at run-time. 3. Executing/running of the program – This is the process by which a computer performs the instructions of a computer program.
4. Maintaining the program. PERFORMING CHECKS ON PROGRAMS TO TEST THE ACCURACY OF PROGRAM TERMINOLOGIES
■ – A software bug may be defined as a coding error that causes an unexpected defect, fault, flaw or imperfection in a computer program. See example below.
Example of an error in a program line used to find the sum of two numbers in Pascal. Sum = num1 + num2; An assignment symbol is used in Pascal, which is ‘:=’ for assignment statements; so the equal sign ( ‘=’) would be seen as an error.
Error in program line
When you are taught a particular program in class and, by extension, when you are creating the program for your SBA, after you compile your program, you will discover that you have a few errors. Below are the typical errors you may encounter when coding.
TYPES OF ERRORS
■ Run-time errors – Run-time errors occur when a syntactically correct program statement cannot execute successfully. A common example is attempting to divide by zero (0) or entering a string value into a declared integer or real variable. ■ Syntax errors – These are errors reported by the compiler/interpreter when the rules of the language are not obeyed. (An example of this was shown for the explanation of a bug.) ■ Logical errors – These errors occur when the expected results of a program are not met.
EXAMPLE
If you had intended for the program to add two numbers (sum := num1 + num2;) but instead, you used the wrong relational operator (sum := num1 * num2;). Using the test data 7 and 2. The computer would return the value 14 rather than 9, which you had intended for the program to execute. You are required to carry out testing operations on your program. Let us examine the meaning of some of those terms associated with this process. ■ Testing – This is the process of checking a program for errors. This involves running and compiling the program, where a feedback will be provided by the translator. ■ Test data – This is data which is used to test a program for errors/special data created by a programmer. We had used test data to test the algorithm used when we looked at trace tables. Test data could be integer values, such as 10, 5, 100, or real numbers, such as 1.5, 8.5, etc, depending on the input data required. ■ Debugging – This is the process of testing, locating and correcting mistakes/errors by running the program. When you create the program for your SBA, you will definitely have to do this. DEBUGGING TECHNIQUES ■ Dry run – This is the process whereby a program is checked to ensure that it does what it was designed for. ■ Structured walk-through – This is a manual trace of the logics of a program using test data; for example, using trace tables.
■ Desk checking – This involves executing the program manually by using values for variables and recording what takes place after each instruction is executed.
■ Program listing – This is a printout or soft copy of the source program instructions as a reference while working and coding the program.