7.2 Object versus Library Style

There is no doubt that you should always try to abstract when using a new data data structure (rather than leaving it implicit in some code). So is is clearly useful to introduce our own data abstract data structures if the Oz libraries do not already provide them for us.

Beside of this, we will also introduce the object style for abstract data structures, in contrast to the the Oz library style. Most importantly, both styles help us to avoid naming conflicts: One can easily reuse the same name for different procedures of different abstract data structures.

The object style is well known from object-oriented programming. The difference to the Oz library style is quite easy: In the object style, every instance of an abstract data structures owns all its functions by itself. In the library style, in contrast, there are comon functions for all instances of tbe same type of abstract data structures.

So why we do we mostly use the object style instead of the Oz libraray style? This is mainly a matter of convenience. Let us consider an example to clarify the difference. If we have an instance History of the abstract stack data structure then it is simply shorter to write

{History.push 'what I did today'}

in object style than

{Stack.push History 'what I did today'}

in the Oz library style.

Finally, note that we will not make use of the special Oz object system. This system comes with a new syntax and its own implementation. This means that it mainly intoduces yet another programming language within Oz. It does not give use any more expressiveness or convenience than we already have (even though it has some nice features too). We will give an example for how to use the Oz object syntax at the end of this section.


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)