Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach

web.firat.edu.tr
from web.firat.edu.tr More from this publisher
21.08.2013 Views

Summary Faults in computer systems are caused by hardware failure, software bugs and user error. Software fault tolerance is concerned with: ■ detecting faults ■ assessing damage ■ repairing the damage ■ continuing. Exercises 255 Of these, faults can be detected by both hardware and software. One hardware mechanism for fault detection is protection mechanisms, which have two roles: 1. they limit the spread of damage, thus easing the job of fault tolerance 2. they help find the cause of faults. Faults can be classified in two categories – anticipated and unanticipated. Recovery mechanisms are of two types: ■ backward – the system returns to an earlier, safe state ■ forward – the system continues onwards from the error. Anticipated faults can be dealt with by means of forward error recovery. Exception handlers are a convenient programming language facility for coping with these faults. Unanticipated faults – such as software design faults – can be handled using either of: ■ recovery blocks, a backward error recovery mechanism ■ n-programming, a forward error recovery mechanism. Assertions are a way of stating assumptions that should be valid when software executes. Automatic checking of assertions can assist debugging. • Exercises 17.1 For each of the computer systems detailed in Appendix A, list the faults that can arise, categorizing them into user errors, hardware faults and software faults. Decide whether each of the faults is anticipated or unanticipated. Suggest how the faults could be dealt with. 17.2 Explain the following terms, giving an example of each to illustrate your answer: fault tolerance, software fault tolerance, reliability, robustness, graceful degradation.

256 Chapter 17 ■ Software robustness 17.3 Consider a programming language with which you are familiar. In what ways can you deliberately (or inadvertently) write a program that will: 1. crash 2. access main memory in an undisciplined way 3. access a file protected from you. What damage is caused by these actions? How much damage is possible? Assuming you didn’t already know it, is it easy to diagnose the cause of the problem? Contemplate that if it is possible deliberately to penetrate a system, then it is certainly possible to do it by accident, thus jeopardizing the reliability and security of the system. 17.4 “Compile-time checking is better than run-time checking.” Discuss. 17.5 Compare and contrast exception handling with assertions. 17.6 The Java system throws an IndexOutOfBoundsException exception if a program attempts to access elements of an array that lie outside the valid range of subscripts. Write a method that calculates the total weekly rainfall, given an array of floating point numbers (values of the rainfall for each of seven days of the week) as its single parameter. The method should throw an exception of the same type if an array is too short. Write code to catch the exception. 17.7 Outline the structure of recovery block software to cope with the following situation. A fly-by-wire aircraft is controlled by software. A normal algorithm calculates the optimal speed and the appropriate control surface and engine settings. A safety module checks that the calculated values are within safe limits. If they are not, it invokes an alternative module that calculates some safe values for the settings. If, again, this module fails to suggest safe values, the pilots are alerted and the aircraft reverts to manual control. 17.8 Compare and contrast the recovery block scheme with the n-programming scheme for fault tolerance. Include in your review an assessment of the development times and performance overheads associated with each scheme. 17.9 Searching a table for a desired object is a simple example of a situation in which it can be tempting to use a goto to escape from an unusual situation. Write a piece of program to search a table three ways: 1. using goto 2. using exceptions 3. avoiding both of these. Compare and contrast the three solutions.

256 Chapter 17 ■ <strong>Software</strong> robustness<br />

17.3 Consider a programming language with which you are familiar. In what ways can you<br />

deliberately (or inadvertently) write a program that will:<br />

1. crash<br />

2. access main memory in an undisciplined way<br />

3. access a file protected from you.<br />

What damage is caused by these actions? How much damage is possible?<br />

Assuming you didn’t already know it, is it easy to diagnose the cause of the problem?<br />

Contemplate that if it is possible deliberately to penetrate a system, then it is<br />

certainly possible to do it by accident, thus jeopardizing the reliability and security<br />

of the system.<br />

17.4 “Compile-time checking is better than run-time checking.” Discuss.<br />

17.5 Compare and contrast exception handling with assertions.<br />

17.6 The Java system throws an IndexOutOfBoundsException exception if a program<br />

attempts to access elements of an array that lie outside the valid range of<br />

subscripts. Write a method that calculates the total weekly rainfall, given an array<br />

of floating point numbers (values of the rainfall <strong>for</strong> each of seven days of the<br />

week) as its single parameter. The method should throw an exception of the same<br />

type if an array is too short. Write code to catch the exception.<br />

17.7 Outline the structure of recovery block software to cope with the following situation.<br />

A fly-by-wire aircraft is controlled by software. A normal algorithm calculates the optimal<br />

speed and the appropriate control surface and engine settings. A safety module<br />

checks that the calculated values are within safe limits. If they are not, it invokes an<br />

alternative module that calculates some safe values <strong>for</strong> the settings. If, again, this<br />

module fails to suggest safe values, the pilots are alerted and the aircraft reverts to<br />

manual control.<br />

17.8 Compare and contrast the recovery block scheme with the n-programming scheme<br />

<strong>for</strong> fault tolerance. Include in your review an assessment of the development times<br />

and per<strong>for</strong>mance overheads associated with each scheme.<br />

17.9 Searching a table <strong>for</strong> a desired object is a simple example of a situation in which it<br />

can be tempting to use a goto to escape from an unusual situation. Write a piece<br />

of program to search a table three ways:<br />

1. using goto<br />

2. using exceptions<br />

3. avoiding both of these.<br />

Compare and contrast the three solutions.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!