Concepts, Techniques, and Models of Computer Programming by Peter Van-Roy & Seif Haridi

Concepts, Techniques, and Models of Computer Programming by Peter Van-Roy & Seif Haridi

Author:Peter Van-Roy & Seif Haridi [Van-Roy, Peter & Haridi, Seif]
Language: eng
Format: epub
Tags: Computers, Programming, General
ISBN: 9780262220699
Google: _bmyEnUnfTsC
Amazon: 0262220695
Publisher: MIT Press
Published: 2004-02-20T00:00:00+00:00


6.3 The declarative model with explicit state

421

We give a concrete example from our experience to show the usefulness of

components. Component-based programming was an essential part of the In-

formation Cities project, which did extensive multi-agent simulations using the

Mozart system [155, 162]. The simulations were intended to model evolution and

information flow in parts of the Internet. Different simulation engines (in a single

process or distributed, with different forms of synchronization) were defined as

reusable components with identical interfaces. Different agent behaviors were de-

fined in the same way. This allowed rapidly setting up many different simulations

and extending the simulator without having to recompile the system. The setup

was done by a program, using the module manager provided by the System mod-

ule Module. This is possible because components are values in the Oz language

(see Section 3.9.3).

6.2.3

Object-oriented programming

A popular set of techniques for stateful programming is called object-oriented

programming. We devote the whole of Chapter 7 to these techniques. Object-

oriented programming adds a fourth property to component-based programming:

• Inheritance. It is possible to build the system in incremental fashion, as

a small extension or modification of another system.

Incrementally-built components are called classes and their instances are called

objects. Inheritance is a way of structuring programs so that a new implementa-

tion extends an existing one.

The advantage of inheritance is that it factors the implementation to avoid

redundancy. But inheritance is not an unmixed blessing. It implies that a com-

ponent strongly depends on the components it inherits from. This dependency

can be difficult to manage. Much of the literature on object-oriented design, e.g.,

on design patterns [58], focuses on the correct use of inheritance. Although com-

ponent composition is less flexible than inheritance, it is much simpler to use.

We recommend to use it whenever possible and to use inheritance only when

composition is insufficient (see Chapter 7).

6.3

The declarative model with explicit state

One way to introduce state is to have concurrent components that run indefinitely

and that can communicate with other components, like the stream objects of

Chapter 4 or the port objects of Chapter 5. In the present chapter we directly

add explicit state to the declarative model. Unlike in the two previous chapters,

the resulting model is still sequential. We will call it the stateful model.

Explicit state is a pair of two language entities. The first entity is the state’s

identity and the second is the state’s current content. There exists an operation

that when given the state’s identity returns the current content. This operation

Copyright c

2001-3 by P. Van Roy and S. Haridi. All rights reserved.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.