UNIT 3. PROGRAMMING ERRORS
STARTER
1. Think over and answer the following questions:
· Have you experienced writing a computer program?
· What programming languages did you use?
· What languages do you prefer to work with? Why?
· Did you make any errors when writing a program?
· What types of programming errors do you know?
· Which of them are the most common in programming?
· Can you define the following errors in PHP and Java?
$States = array ("Alabama", "Alaska", "Arizona", "Arkansas", "California"); echo "The first record in the States array is " . $States[1]; | int a = "hello"; | ||
$x = 1 echo $x; |
2. Discuss your ideas with the partner.
READING
1. Work in pairs. One of you will read the Texts 1 and 3, the other – Texts 2 and 4, and complete the table below.
Type of error | |
Definition | |
Example | |
Ways to avoid or deal with this kind of error |
When a program is written, it should necessarily be tested, as it might contain errors. Actually, there is no perfect 100% error free program. So, a software developer has to be aware of types of programming errors and ways to detect and rectify them.
Programming errors, more commonly known as 'Bugs' in computing lingo, can be divided into some groups.
Text 1 | System errors affect the computer or its peripherals. For example, you run a program that needs access to a printer. If there is no printer present, the computer will produce a system error message. A sensible way of avoiding system errors is to write code to check that peripherals are present before any data is sent to it. In this case, the computer would warn you by a simple message on the screen, like 'printer is not ready or available'. |
Text 2 | Every computer language has a specific syntax, in which code needs to be written. Any misuse of it leads to syntax errors that make the compilation of the program to fail and may cause its termination after showing the list of errors and the line number where the errors have occurred. However, in some cases the line number may not exactly point out the correct place of the error. In some other cases, a single syntax error can result in a long list of errors. Correction of one or two errors in the program may remove all of them. Syntax errors can be easily corrected during the compilation phase. |
Text 3 | Logic errors are related to the logic of the program and are much more difficult to detect than syntax errors. They contain syntactically and semantically correct code, but do not execute the way the programmer has intended. The program containing logic errors will run, but it won't work properly. In the following C statement: if(a==b) printf(“Equaln”); When a and b are float types values, they rarely become equal due to truncation errors. The printf call may not be executed at all. A statement like while (a!=b) might create an infinite loop. It’s possible to rectify logic errors in simple programs by 'hand-testing' them or doing a 'dry run' which means working through each line of the program on paper to make sure it does what it is expected to do. This should be done long before a programmer types in the code. |
Text 4 | Runtime errors occur during the execution of the program. These errors are not detected by the compiler, because the code is syntactically correct. A program with runtime errors will run, but produce erroneous results or may cause termination of the program. Detection and removal of them is a difficult task. An example of a run-time error is a statement that causes division by zero. In the following statement, the syntax is correct, but the statement may cause a division by zero error if the variable Second_number is assigned a value of 0: Ratio := First_number / Second_number; To determine the cause of a run-time error, a programmer needs the exact description of the sequence of events that led to the error. However, if the circumstances that led to the error are more complicated, and it is not possible to determine the exact location of the error, the debugger can be used. |
2. Exchange the information with your partner to complete two similar tables.
3. In the texts above find the words and word combinations that mean the following:
· a piece of equipment that is connected to a computer and used with it;
· words or expressions used only by a particular group of people, or at a particular period of time;
· to correct something that is wrong;
· to make someone conscious of a possible problem or danger;
· the rules that describe how words and phrases are used in a computer language;
· the act of ending something, or the end of something;
· to happen;
· to indicate;
· to make a computer use a program or carry out an instruction;
· something that you do as a practice for an important event;
· a set of related things that are arranged in a particular order.
4. Decide if the following sentences are true or false. Correct the false sentences. Use the phrases from Appendix 3.
· No one program (it doesn’t matter how perfect it is) executes correctly in the first time.
· If you want to be a highly skilled programmer, you should learn as many types of programming errors as you can, and be able to identify and remove them.
· Errors that influence the computer or its peripherals are called syntax errors.
· Runtime errors happen when a program is executed.
· Programmers can rectify logic errors at an easy rate when compiling the program.
· If runtime errors exist in the program, it runs but produces erroneous results or may cause termination of the program.
· Simple programs with logic errors can be corrected by doing a 'dry run' which means working through each line of the program on paper to prove it runs in a way it should run.
· When attempting to run net share on a local computer, you may receive this message: ‘net share Logic error 5 has occurred. Access is denied'.
· It is impossible to detect runtime errors, as the code is syntactically correct.
5. Complete the list of programming errors. Try to name at least four of them, their features, and ways to detect and avoid them.
6. Answer the following questions:
· Is it possible to write a program containing no errors?
· What programming errors do you know?
· Which errors are the most difficult to detect?
· Which errors are the easiest for rectifying?
· How do you know that a system error occurs in the program?
· What errors can be called syntax errors? What should a developer do to correct them?
· Can a computer execute a program with logic errors? How can a developer correct such programs?
· How are runtime errors detected?
LANGUAGE WORK
1. Look at the following suffixes and complete the charts below. Use Appendix 7 to help you.
Nouns | -tion -ance -or -ing -er -al | |
Adjective | -able |
Verb | Nouns | Adjective |
execute | _______________ | ________________ |
detect | _______________, ________________ | ________________ |
rectify | _______________,________________ | |
avoid | _______________ | ________________ |
compile | _______________, ________________ | |
remove | _______________, ________________ | ________________ |
8. | ||||||||||||||||
5. | 6. | |||||||||||||||
1. | 7. | 9. | ||||||||||||||
2. | 10. | |||||||||||||||
3. | ||||||||||||||||
11. | ||||||||||||||||
4. | ||||||||||||||||
2. Solve the following cross-word puzzle on the programming terms. Use a specialized dictionary if necessary.
Across
1.A set of instructions that are followed in a fixed order and used for solving a mathematical problem, making a computer program, etc.
2.A machine-independent code. This code is the same whether the source code is compiled on a Windows computer, a Linux computer, an IBM computer, or a Mac.
3.A subprogram that returns a value, but cannot change its parameters or have side effects.
4.Giving multiple meanings to a symbol depending on its context.
Down
5.To make use of something by writing its name and the correct protocol.
6.To translate source code into executable object code.
7.A name used in a programming language to identify something else.
8.The ability to easily construct new data types or classes by extending existing structures, data types, or classes.
9.A set of rules that controls the ways in which data is sent between computers.
10.Freeing the program of all errors.
11.A description of a collection of objects that have similar structures and behaviors.
GRAMMAR
HELP BOX | Relative clauses | |
We use relative clauses to give additional information about something.They start with the relative pronouns who, that, which, whose, where, when. There are two types of relative clauses: defining and non-defining. 1. Defining (or restrictive) relative clauses follow the noun that they modify. They are not separated by commas. Defining relative clause cannot be left out without affecting the meaning of the sentence. ü Computers that are equipped with multiple processors that support processor power management features, such as Advanced Configuration and Power Interface (ACPI) processor performance states, require Microsoft Windows XP Service Pack 2 (SP2). | 2.When a relative clause merely gives some additional information about the noun, it is called a non-defining or non-restrictive relative clause. A non-defining relative clause is not necessary for the identification of the noun and is separated from the main clause by commas. We can easily leave out a non-defining relative clause. ü Any developer, who can do the job,must be able to learn new things on the fly. ü Smartphones, which I and my brother use, are quickly replacing traditional point-and-shoot cameras as the go-to devices for taking quick photos. | |
1. Study the HELP BOX above and Grammar guide 5, and make up your own examples of relative clauses.
2. Find relative clauses in the texts above. Define if they are restrictive or non-restrictive and explain why you have decided so.
3. Remake defining sentences from the texts into non-defining, if it is possible.
SPEAKING
1. Work in pairs. Match the following problems (1-8) and solutions (A-H).
1.add extra facilities to a computer | A.fit a bigger hard disk |
2.get more file storage space | B.add more internal memory and install more powerful video card |
3.find syntax errors | C.use a removable device |
4.improve the speed of your computer | D.use the debug command |
5.avoid system errors | E.install an expansion card |
6.transfer information between computers | F.correct the registry by removing unnecessary files, applications, and games from your computer |
7.get rid of runtime error caused by a corrupt registry | G.write code to check a peripheral is present before any data is sent |
2. Link the problems with the solutions using a model, and discuss them with your partner. Give your suggestions.
Model:
Problem: get rid of logic errors
Solution: hand-test the program
If you need to can get rid of logic errors, you can do it by hand-testing the program.
If I had to get rid of logic errors, you would do it by hand-testing the program.
3. Suggest solutions to the problems. Discuss your ideas with other students in your group.
ü Prevent unauthorized access to a network.
ü Make sure there is no spyware in your computer.
ü Avoid the risk of losing data.
4. Tell your partner the most common programming errors and problems you often come across, and ask him/her for a solution.
PROJECT WORK
Choose one type of programming errors, and make the presentation on its detecting and rectifying. You may use PowerPoint to format you presentation and Appendix 6 to help you. Report back to your group.