Skip to main content Accessibility help
×
Hostname: page-component-7bb8b95d7b-495rp Total loading time: 0 Render date: 2024-09-23T16:12:56.689Z Has data issue: false hasContentIssue false

14 - Object Oriented Programming

Published online by Cambridge University Press:  05 July 2014

Get access

Summary

We now come to a discussion of the basic features of Ada which support what is generally known as object oriented programming or OOP. Ingredients of OOP include the ability to extend a type with new components and operations, to identify a specific type at run time and to select a particular operation depending on the specific type. A major goal is the reuse of existing reliable software without the need for recompilation.

This chapter concentrates on the fundamental ideas of type extension and polymorphism. Related topics are type parameterization (using discriminants) and genericity; these are discussed in Chapters 18 and 19 respectively. Finally, Chapter 20 considers how these various aspects of OOP all fit together especially with regard to multiple inheritance.

The reader might find it helpful to reread Sections 3.2 and 3.3 before considering this chapter in detail.

Type extension

In Section 12.3 we saw how it was possible to declare a new type as derived from an existing type and how this enabled us to use strong typing to prevent inadvertent mixing of different uses of similar types. We also saw that primitive operations were inherited by the derived type and could be overridden and, moreover, that further primitive operations could be added if the derivation were in a package specification.

We now introduce a more flexible form of derivation where it is possible to add additional components to a record type as well as additional operations.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2014

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×