Object-oriented Software in Ada95

Michael A. Smith

ISBN : 185032185X

Order a printed copy of this book from Amazon.


Cover Design - Object-oriented Software in Ada95
 

For your free electronic copy of this book please verify the numbers below. 

(We need to do this to make sure you're a person and not a malicious script)

Numbers

 




Sample Chapter From Object-oriented Software in Ada95
     Copyright © Michael A. Smith



1 Introduction to programming
A computer programming language is used by a programmer to express the solution to a problem in terms that the computer system can understand. The  chapter looks at how to solve a small problem using the computer programming language Ada 95.

1.1 Computer programming
Solving a problem by implementing the solution using a computer programming language is a meticulous process. In essence the problem is expressed in terms of a very stylized language in which every detail must be correct. However, this is a rewarding process both in the sense of achievement when the program is completed, and usually the eventual financial reward obtained for the effort.

Like the planet on which we live where there are many different natural languages, so the computer world also has many different programming languages. The programming language Ada 95 is just one of the many computer programming languages used today.

1.2 Programming languages
In the early days of computing circa 1950s, computer programs had to be written directly in the machine instructions of the computer. Soon assembly languages were introduced that allowed the programmer to write these instructions symbolically. An assembler program would then translate the programmer’s symbolic instructions into the real machine code instructions of the computer. For example, to calculate the cost of a quantity of apples using an assembly language the following style of symbolic instructions would be written by a programmer:

LDA AMOUNT_OF_OF_APPLES ; Load into the accumulator # pounds
MLT PRICE_PER_POUND ; Multiply by cost per pound of apples
STA COST_OF_APPLES ; Save result

Note: Each assembly language instruction corresponds to a machine code instruction.

In the period 1957—1958 the first versions of the high-level languages FORTRAN & COBOL were developed. In these high-level programming languages programmers could express many ideas in terms of the problem rather than in terms of the machine architecture. A compiler for the appropriate language would translate the programmer’s high level statements into the specific machine code instructions of the target machine. Advantages of the use of a compiler include:

-Gains in programmer productivity as the solution is expressed in terms of the problem rather than in terms of the machine.
-If written correctly, programs may be compiled into the machine instructions of many different machines. Hence, the program may be moved between machines without having to be re-written.

For example, the same calculation to calculate the cost of apples is expressed in FORTRAN as:
COST = PRICE * AMOUNT


1.3 Range of programming languages
Since the early days of computer programming languages the number and range of high level languages has multiplied greatly. However, many languages have also effectively died through lack of use. A simplistic classification of the current paradigms in programming languages is shown in the table below:

Type of language Brief characteristics of the language Example
Functional The problem is decomposed into individual
functions. To a function is passed read only data
values which the function transforms into a new
value. A function itself may also be passed as a
parameter to a function. As the input data to a
function is unchanged individual functions may be
executed simultaneously as soon as they have their
input data.
ML
Logic The problem is decomposed into rules specifying
constraints about a world view of the problem.
Prolog
Object-oriented The problem is decomposed into interacting
objects. Each object encapsulates and hides
methods that manipulate the hidden state of the
object. A message sent to an object evokes the
encapsulated method that then performs the
requested task.
Ada 95
Eiffel
Java
Smalltalk
Procedural The problem is decomposed into individual
procedures or subroutines. This decomposition is
usually done in a top down manner. In a top down
approach, once a section of the problem has been
identified as being implementable by a procedure,
it too is broken down into individual procedures.
The data however, is not usually part of this
decomposition.
C
Pascal