by: Assoc. Prof. Zeki Bayram

originally at: Computer Engineering Department of Bogazici University

currently at: Computer Engineering Department of Eastern Mediterranean University

e-mail: zeki.bayram AT emu.edu.tr

web site: http://cmpe.emu.edu.tr/bayram

Introduction

This is an online tutorial for introducing the object-oriented features that have been newly added to the ADA language in the '95 standard. Its main difference from other online tutorials is that complete working programs are given, which the user can experiment with, as opposed to just program fragments. The material is presented at a very intoductory level, aiming to be accessible to the newcomer to ADA. Knowledge of general Object-Oriented concepts is assumed, however.

A non-exhaustive list of topics that are dealt with include (not necessarily in this order)


Highlights of ADA object-oriented features

A short comparison of terminology and concepts of ADA'95 with standard object-oriented concpts and terminology will help in getting us started. We take C++ as the standard!!

Standard Object-Oriented Terminology and Concepts

ADA'95 Terminology and Concepts

Method.  Primitive Operation. A procedure or function that is defined right after a tagged record definition in a package and takes at least one argument of the tagged record type. The position of the argument in the list of formal parameters is insignificant. 
Class Tagged Record Type
Message sending convention: object_name.method(arguments). Pointer to object passed implicitly as the first argument to the method. Message sending convention: primitive_operation(object_name, arguments)or primitive_operation(pointer_to_object, arguments).
Virtual Methods (late binding). Decided at the time the method is defined.  Dynamic Dispatching. Decided at the time of the call to the primitive operation. If the first argument to the primitive operation is a class-wide type, then what method to call depends upon the actual type of the object operated upon.. 
Class variable. Accessed as className::variableName (if public), or just variableName from within methods. Non-existent. Its equivalent is a variable defined in the private (or public) part of the class containing the tagged record definition
Class method. Accessed as className::methodName() (if public), or just methodName() from within methods. Non-existent. Its equivalent is any non-primitive operation defined in the package.
Constructor Non-existent. The Ada.Finalization package contains a procedure called intialize which is called automatically if desired (see examples for details) but this procedure takes no arguments necessary for initializing the object being created. Effectively, then, no mechanism equivalent to constructors exists for ADA (some round-about ways are possible: see the article "Extending Ada'95 to Implement Object Initialization" in the Journal of Object-Oriented Programming, May 1998 issue)
Destructor The "finalize" procedure found in the Ada.Finalization package does the job of a destructor.
Overloading the assignment operator Not available. The procedure "adjust" found in the Ada.Finalization package is meant to remedy the situation.
Having both a public and a private part of an object Not possible!
A pointer variable declared to point to objects that are instances of a class X can point to objects that are instances of any descendant of X. Class-wide types and variables - formalizes the concept described on the left

Contents

Note

Topics that will be added in due course include

Links to Other on-line sources

Ada Language Reference Manual

Ada Rationale

Ada Quality and Style: Guidelines for professional programmers

Ada Programmers FAQ.

Lovelace on-line tutorial.


***** Important Note: This tutorial is best viewed with Netscape 3.0