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.

14.3 Design principles 177<br />

Cobol and PL/1 are examples of languages which are large and unwieldy. For<br />

example, Cobol currently contains about 300 reserved words. Not surprisingly, it is a<br />

common programming error mistakenly to choose a reserved word as a user-defined<br />

identifier. What are the problems of large languages? Because they contain so many<br />

features, some are seldom used and, consequently, rarely fully understood. Also, since<br />

language features must not only be understood independently, but also in terms of their<br />

interaction with each other, the larger the number of features, the more complex it will<br />

be and the harder to understand their interactions. Although smaller, simpler languages<br />

are clearly desirable, the software engineer of the near future will often have to wrestle<br />

with existing large, complex languages. For example, to meet the requirements laid<br />

down by its sponsors, the US Department of Defense, the programming language Ada<br />

is a large and complex language requiring a 300-page reference manual to describe it.<br />

The clarity of a language is also an important factor. In recent years, there has been<br />

a marked and welcome trend to design languages <strong>for</strong> the programmers who program<br />

in them rather than <strong>for</strong> the machines the programs are to run on. Many older languages<br />

incorporate features that reflect the instruction sets of the computers they were originally<br />

designed to be executed on. As one example, consider the Fortran arithmetic if<br />

statement, which has the following <strong>for</strong>m:<br />

if (expression) label1,label2,label3<br />

This statement evaluates expression and then branches to one of the statements<br />

labeled label1, label2, or label3 depending on whether the result is positive, zero,<br />

or negative. The reason <strong>for</strong> the existence of this peculiar statement is that early IBM<br />

machines had a machine instruction which compared the value of a register to a value<br />

in memory and branched to one of three locations. The language designers of the<br />

1960s were motivated to prove that high-level languages could generate efficient code.<br />

Although we will be <strong>for</strong>ever grateful to them <strong>for</strong> succeeding in proving this point, they<br />

introduced features into languages, such as Cobol and Fortran, which are clumsy and<br />

error-prone from the programmer’s viewpoint. Moreover, even though the languages<br />

have subsequently been enhanced with features reflecting modern programming ideas,<br />

the original features still remain.<br />

A programming language is the tool that programmers use to communicate their<br />

intentions. It should there<strong>for</strong>e be a language which accords with what people find natural,<br />

unambiguous and meaningful – in other words, clear. Perhaps language designers<br />

are not the best judges of the clarity of a new language feature. A better approach to<br />

testing a language feature may be to set up controlled experiments in which subjects are<br />

asked to answer questions about fragments of program code. This experimental psychology<br />

approach is gaining some acceptance and some results are discussed in the section<br />

on control abstractions.<br />

A programmer can only write reliable programs if he or she understands precisely<br />

what every language construct does. The quality of the language definition and supporting<br />

documentation are critical. Ambiguity or vagueness in the language definition<br />

erodes a programmer’s confidence in the language. It should not be necessary to have<br />

to write and run a program fragment to confirm the semantics of some language feature.

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

Saved successfully!

Ooh no, something went wrong!