Published online by Cambridge University Press: 29 May 2025
19.1 A programming language
A central issue in object-oriented programming is how objects are described. Broadly, object-oriented languages fall into two groups. One comprises the object-based languages, such as Emerald and Self. In a program of an object-based language, one finds phrases that express individual objects, and objects are created by performing operations on existing objects. The other, larger, group comprises the class-based languages. Among its members are Simula, Smalltalk, C++, and Java. A program of a class-based language contains definitions of classes, which serve as blueprints for objects that share a common structure and behaviour. The language we will consider is class-based. The ideas and techniques illustrated can also be applied to object-based languages, however.
A key idea in object-oriented design and programming is encapsulation: each object has private data that are not directly accessible to other objects. These are typically simple data, such as integers, and references to objects. An object a can interact with an object b only if a has a reference to b. An interaction typically consists in a asking b to carry out one of its repertoire of actions - that is, in a invoking one of b7s methods - and b returning the result of the invocation, in due course. The arguments and results of method invocations can contain references to objects, and it is in this way, and via creation of objects, that the interconnection structure among objects changes as a system evolves.
We call the language we consider OOL. Its main syntactic categories are declarations, commands, and expressions. A program comprises some class declarations and an expression, whose evaluation serves to trigger the system's activity. A class declaration consists of some variable declarations, the instance variables of the class, and some method declarations, which describe the actions that objects of the class can perform. A method declaration comprises type information and the body of the method, a command that describes the activity to be carried out when the method is invoked. A variable declaration states the names and types of variables.
To save this book to your Kindle, first ensure no-reply@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.
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.
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.