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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

190 Chapter 14 ■ The basics<br />

Ada does not specify whether they are to be implemented using sharing or copying.<br />

Though beneficial to the language implementer, since the space requirements of the<br />

parameter can be used to determine whether sharing or copying should be used, this decision<br />

can be troublesome to the programmer. In the presence of aliases, call by valueresult<br />

and call by reference may return different results.<br />

14.10 ● Primitive data types<br />

Programmers are accustomed to being provided with a rudimentary set of primitive<br />

data types. These are provided built in and ready made by the programming language.<br />

They usually include:<br />

■ Boolean<br />

■ char<br />

■ integer<br />

■ real or floating point.<br />

These data types are accompanied by a supporting cast of operations (relational,<br />

arithmetic, etc.). For each type, it should be possible to clearly define the <strong>for</strong>m of the<br />

literals or constants which make up the type. For example, the constants true and<br />

false make up the set of constants <strong>for</strong> the type Boolean. Similarly, we should be able<br />

to define the operations <strong>for</strong> each type. For the type Boolean, these might include the<br />

operations =, , not, and, and or.<br />

In most languages the primitive data types are not true objects (in the sense of<br />

objects created from classes). But in Eiffel and Smalltalk, every data type is a proper<br />

object and can be treated just like any other object.<br />

For certain application domains, advanced computation facilities, such as extended<br />

precision real numbers or long integers, are essential. The ability to specify the range of<br />

integers and reals and the precision to which reals are represented reduces the dependence<br />

on the physical characteristics, such as the word size, of a particular machine. This<br />

increases the portability of programs. However, some languages (<strong>for</strong> example C and<br />

C++) leave the issue of the precision and range of numbers to the compiler writer <strong>for</strong><br />

the particular target machine. Java gets around this sloppiness by precisely defining the<br />

representation of all its built-in data types. Whatever machine a program is executed on,<br />

the expectation is that data is represented in exactly the same manner. Thus the program<br />

will produce exactly the same behavior, whatever the machine.<br />

14.11 ● Data typing<br />

A data type is a set of data objects and a set of operations applicable to all objects of<br />

that type. Almost all languages can be thought of as supporting this concept to some<br />

extent. Many languages require the programmer to define explicitly the type (e.g. integer<br />

or character) of all objects to be used in a program, and, to some extent or another,<br />

depending on the individual language, this in<strong>for</strong>mation prescribes the operations that

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

Saved successfully!

Ooh no, something went wrong!