Modelling Objects in PICT 1 Introduction
Total Page:16
File Type:pdf, Size:1020Kb
Mo delling Ob jects in PICT JeanGuy Schneider Markus Lump e Software Comp osition Group IAM January Abstract For the development of presentday applications programming languages supp orting high order abstractions are needed These high order abstractions are called com p onents Since most of the currently available programming languages and systems fail to provide sucient supp ort for sp ecifying and implementing comp onents we are developing a new language suitable for software comp osition It is not clear how such a language will lo ok like what kind of abstractions it must supp ort and what kind of formal mo del it will b e based on Ob jectoriented programming languages address some of the needs of presentday applications and it is therefore obvious to integrate some of their concepts and abstractions in the language As a rst step towards such an integration we have to dene an ob ject mo del Since no generally accepted formal ob ject mo del exists we have chosen the calculus as a basis for mo delling In order to nd a suitable ob ject mo del we have built up an ob ject mo delling workbench for PICT an implementation of an asynchronous calculus In this work we dene a rst abstract ob ject mo del describ e several implementations of the ob ject mo del in PICT and discuss interesting features and p ossible extensions Keywords calculus PICT ob ject mo delling software comp osition CR Categories and Sub ject Descriptors D Programming Techniques Concurrent Programming D Programming Techniques Ob jectoriented Pro gramming D Software Engineering RequirementsSpecication D Pro gramming Languages Language Constructs and Features F Mathematical Logic and Formal Languages Formal Languages Authors address Institute for Computer Science and Applied Mathematics IAM University of Berne Neubr uckstrasse CH Bern Switzerland email fschneidrlumpegiamunibech WWW httpiamwwwunibechscg Introduction Software development and maintenance has always b een an exp ensive task To reduce its costs sp ecialpurp ose programming languages and metho ds have b een developed and used For presentday applications however which are getting more complex and increas ingly op en these metho ds and languages are not suitable any more new ones have to b e developed that address op en systems requirements Mo delling Ob jects in PICT Ob jectoriented programming addresses some of the needs of presentday applications but only oers limited supp ort for viewing applications as congurations of adaptable and reusable software comp onents What we need are higher abstractions than classes and ob jects These higher abstractions are comp onents b eing congurable entities which can b e comp osed to build an applica tion ND Unfortunately most ob jectoriented techniques fail to provide suitable ab stractions for general comp onent sp ecication and comp onent comp osition comp osition mechanisms NM In order to get a system for comp osition where comp onents can b e sp ecied and implemented but also comp onents written in other systemslanguages can b e used we have to dene our own comp osition language In this language we would like to integrate and combine asp ects concepts and paradigms of existing languages and sys tems and develop an abstract mo del for software comp osition NGT NM Since a lot of new applications run in distributed environments our mo del for software comp osition must also supp ort the denition and use of concurrent comp onents According to Nie the development of concurrent ob jectbased programming languages has suered from the lack of any generally accepted formal foundation for dening their semantics Several formal mo dels have b een presented refer to Men for a summary but none of them has b een used as a formal basis for mo delling software comp osition Unfortunately it is not clear what kind of formal mo del is suitable for software com p osition Therefore we have to dene and implement several mo dels which need to b e evaluated The calculus is a calculus in which the top ology of communication can evolve dy namically during evaluation Mil It has b een successfully used to mo del ob jects Jon BSa and simple ob jectoriented programming languages Wal Therefore it seems to b e a go o d formal foundation for mo delling software comp osition esp ecially since it p ossible to embed the calculus into the calculus where metho ds for program reasoning have b een developed Fortunately there exists an implementation of an asyn chronous calculus Pieb which has already b een used for the implementation of a simple ob ject mo del PT This ob ject mo del lacks several abstractions available in most ob jectoriented languages but can b e used as a basis for further mo delling Based on this mo del we try to nd other implementations of ob jects in PICT in order to obtain an ob ject mo delling workbench Using this workbench it will b e easier to evaluate and implement ob ject mo dels which can b e used as a basis for a comp osition language As a rst step towards a mo delling workbench we will only concentrate on mo delling common abstractions used in ob ject technology which are not necessarily concurrent Full concur rency will b e introduced in a later stage but we will already discuss problems and p ossible solutions due to a concurrent ob ject mo del In this work we rst dene an abstract ob ject mo del based on ob ject mo dels used in other programming languages section In section we describ e several implementations of our mo del and cite interesting features of PICT Finally in section we summarize our work and mention future p ossible work Mo delling Ob jects in PICT Ob ject Mo del As mentioned ab ove it is not clear what kind of ob ject mo dels are suitable for software comp osition In order to b e able to evaluate several ob ject mo dels we think that the mo delling workbench should contain features of already existing ob ject mo dels As a starting p oint we have dened a rst abstract ob ject mo del which will b e used throughout the rest of this work It has b een strongly inuenced by the ob ject mo dels of C Str Eiel Mey and Ob ject Pascal BF and supp orts the following features class variables class metho ds instance variables instance metho ds selfreference of ob jects inheritance genericity static and dynamic binding To keep the rst mo del simple metho ds and variables of a class are either exp orted to clients public or hidden private no selective exp ort like in Eiel will b e mo delled A 1 sub class of a given class will inherit all public features and private instance variables from its sup erclass but none of the private metho ds A sub class can redene any of its inherited public features Although it might b e necessary to mo del multiple inheritance we will not discuss problems due to this mechanism Since we do not know yet what kind of features are necessary for an ob ject mo del for software comp osition it is p ossible that we have to add other features to our list They will b e added and mo delled during evaluation In Figure the interfaces of two example classes are describ ed in pseudoco de notation which will b e used throughout the rest of this work to explain our ob ject mo dellings in PICT The example classes use most of the features introduced ab ove The class IntStack denes a class for integer stacks with its usual features The keyword public is used to dene features of a class which are exp orted to clients whereas private denotes features only visible within the class common is used to dene features shared by all ob jects of a class class variables and metho ds and override is used to sp ecify an inherited feature which will b e redened The class IntStack has a class variable Pushed which is used to count the number of items pushed on all stacks The class IntTower is a sub class of IntStack where it is only p ossible to push items in a decreasing order A description of b oth classes can b e found in App endix A or in BL 1 The term feature is used like in Eiel it denotes metho ds and variables of a class Mo delling Ob jects in PICT class IntStack f private Lo calPushed Integer Contents List of Integer public function empty Bo olean procedure push Value Integer procedure p op function top Integer function lo calPushed Integer private Pushed Integer common public function pushed Integer common g class IntTower IntStack f private function CanPush Value Integer Bo olean public procedure push Value Integer override g Figure Abstract ob ject mo del Implementation in PICT In this section we will describ e several PICT implementations of the abstract ob ject mo del Readers not familiar with the language PICT can nd an introduction in Pieb or Var For additional background in the calculus please refer to Mil Mil Details ab out the implementation of PICT esp ecially its type system are describ ed in Tur Ob ject mo del of Pierce and Turner In PT Pieb Tur Pierce and Turner introduce a simple ob ject mo del based on pro cesses an ob ject is a pro cess consisting of a server pro cess with some internal state b eing able to service requests of clients to query and manipulate the state and a set of request channels which can b e used by clients to request services Mo delling Ob jects in PICT The following pro cess based reference cell Tur illustrates their ob ject mo del def ref init let new Contents run Contentsinit in set abs vc Contents Contentsv c end get abs r Contentsv Contentsv rv end end A pro cess based reference cell consists of an internal channel Contents which is used to store the internal