Information Technology Reference
In-Depth Information
numeric values with fractional parts, and a set of arithmetic operations
that were allowed to act on floating-point variables. How FORTRAN included
these data types is an example of one of the key ideas of data abstraction,
namely, information hiding . The details of the actual way a floating-point num-
ber is represented in the computer are hidden from the user and cannot be
accessed by the programmer. In addition, the programmer can only create
new operations on this type of data by using the built-in operations already
supported on floating-point variables. Because of such information hiding,
FORTRAN programs could run on many different machines, even though
floating-point variables were frequently implemented very differently on dif-
ferent machines.
Modern object-oriented (O-O) programming languages allow program-
mers to create their own abstract data types. Consider again the problem of
writing a program to manipulate a list containing the names of members
in a sports club. In an imperative programming language, the list is just
a collection of data and we need to write separate software procedures to
add, delete, and sort items in the list. In an O-O language, the list is con-
structed as an object consisting of both the list data and the collection of
procedures - called methods in O-O speak - for manipulating this data. Thus
an O-O program to sort the list would not contain a separate sorting proce-
dure but make use of the methods already built in for the list object. What
is the relationship between a class and an object? A class is a template for all
the objects with the same data type and methods. The list class applies to all
list objects with data in the form of a list and the methods to operate on the
list. As a slightly more complicated example, let us define a bank account
class. The abstract data type for a bank account consists of the name of the
client, the number of the account, and the balance of money in the account.
The class consists of bank account data of this type plus methods that define
the different operations that can be carried out on the account - withdraw-
als, deposits, transfers, and so on. Accounts belonging to different custom-
ers obviously contain different data and are called objects or instances of this
class. The methods that act on the data within an object are usually small
imperative programs.
Two other important properties of O-O languages are inheritance and encap-
sulation . The idea of inheritance is that a class can be extended to create another
class that inherits the properties of the original class. Thus the class “bank
account” could be extended to create a new class “savings bank account” that
inherits the same data structure and methods as the original class but with
additional properties and methods ( Fig. 4.6 ). Encapsulation means that there
are certain properties of an object that are not accessible to other parts of the
program. Only the object is able to access these properties.
Canadian computer scientist David Parnas ( B.4.4 ) was one of the pioneers
of information hiding. Turing Award recipient Alan Kay and his research team
at the Xerox PARC (Palo Alto Research Center) in Silicon Valley in the 1970s first
introduced the term object-oriented programming . They developed the Smalltalk
language, which was based on the idea of building programs with objects that
communicated by sending messages.
B.4.4. David Parnas is a Canadian
computer scientist who pioneered
ideas of “information hiding.” These
ideas are now an integral part of
data abstraction in object-oriented
programming.
 
Search WWH ::




Custom Search