21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

SELF-TEST QUESTION<br />

17.9 Write pre- and post-conditions <strong>for</strong> method pop.<br />

Note that truth of assertions does not guarantee that the software is working correctly.<br />

However, if the value of an assertion is false, then there certainly is a fault in the<br />

software. Note also that violation of a precondition means that there is a fault in the<br />

user of the method; a violation of a postcondition means a fault in the method itself.<br />

There are two main ways to make use of assertions. One way is to write assertions as<br />

comments in a program, to assist in manual verification. On the other hand, as indicated<br />

by the notation used above, some programming languages (including Java) allow assertions<br />

to be written as part of the language – and their correctness is checked at runtime.<br />

If an assertion is found to be false, an exception is thrown.<br />

There is something of an argument about whether assertions should be used only<br />

during development, or whether they should also be enabled when the software is put<br />

into productive use.<br />

17.9 ● Discussion<br />

Fault tolerance in hardware has long been recognized – and accommodated. Electronic<br />

engineers have frequently incorporated redundancy, such as triple modular redundancy,<br />

within the design of circuits to provide <strong>for</strong> hardware failure. Fault tolerance in software<br />

has become more widely addressed in the design of computer systems as it has become<br />

recognized that it is almost impossible to produce correct software. Exception handling<br />

is now supported by all the mainstream software engineering languages – Ada, C++,<br />

Visual Basic, C# and Java. This means that designers can provide <strong>for</strong> failure in an organized<br />

manner, rather than in an ad hoc fashion. Particularly in safety-critical systems,<br />

either recovery blocks or n-programming is used to cope with design faults and enhance<br />

reliability.<br />

Fault tolerance does, of course, cost money. It requires extra design and programming<br />

ef<strong>for</strong>t, extra memory and extra processing time to check <strong>for</strong> and handle exceptions.<br />

Some applications need greater attention to fault tolerance than others, and<br />

safety-critical systems are more likely to merit the extra attention of fault tolerance.<br />

However, even software packages that have no safety requirements often need fault<br />

tolerance of some kind. For example, we now expect a word processor to per<strong>for</strong>m<br />

periodic and automatic saving of the current document, so that recovery can be per<strong>for</strong>med<br />

in the event of power failure or software crash. End users are increasingly<br />

demanding that the software cleans up properly after failures, rather than leave them<br />

with a mess that they cannot salvage. Thus it is likely that ever-increasing attention<br />

will be paid to improving the fault tolerance of software.

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

Saved successfully!

Ooh no, something went wrong!