Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am...

11
3.tedC sit. In ment, nplex record tatlon Nand lmen· lbllity plus:' ldent '.Inc. l.base: .cal C mlcal visor T§! ~easy , and Ican Iport DOS. 'a ;met. "and ,Its luen· flies. from ~s: A :Wltt, Cepage: A Software Design Tool· F ormany years, software engi- neers have pro- vided engineers of other fields with advanced design tools that considerably facilitate their jobs, relieve them from tedious tasks, put them in control of the design process, and help them turn out quality products. But the tools used by software designers them- selves look quite primitive in comparison: the standard design environment includes a text editor, a compiler, perhaps a debugger, but hardly anything that could be characterized as a design system. This article presents a system- C6page-whose aim is to provide soft- ware designers with facilities similar to what is known in other application areas as computer-aided design. C6page (pronounced sea-page or say- pajj) is intended to make the full power of computer-aided design available to soft- ware developers in practical environ-, ments. It frees its users from many of the tedious tasks traditionally associated with the construction of programs and other software-related documents and allows them to concentrate on the really important aspects of software design. The aim is to use Cepage as the basis for a complete software development environ- ment supporting all activities of software design. Visual al'ld structured C6page relies on a simple but powerful idea: to allow visual manipulation of structured documents. What do we call a structured document? The most obvious example is a program By Bertrand Meyer written in some high-level language like not only manipulated but actually seen. Pascal, C, Ada, or FORTRAN, with their _ The ease of tailoring the system to any hierarchical structure (program sub- new language, making Cepage a versatile program, block, instruction, expression, tool adaptable to many different and so on). Such programs are indeed one applications. of the primary targets ofCepage but by no _ The open architecture of the system, means the only one. In fact, any document which allows.it to be interfaced with other with an interesting enough structure is an tools and makes it a promising candidate equally good candidate for handling by . as a basis for a complete software devel- Cepage. This description includes such opmentenvironment. software documents as specifications, _ The ambition of the entire system designs, or schedules. design to take structural editing out of the But technical documents whose struc- laboratory and make its exciting potential ture in a given environment is often stan- available to practicing programmers in dardized can also be handled by Cepage. ordinary environments. For example, a certain company or project might require that technical reports begin with a header page of a nor- malized form (author's name, title, abstract, date, approval, etc.). and con- tinue along a formal structure (sections, paragraphs, etc.). The usual way to deal with structured documents on a computer is to use a text editor-in other words, to forget about the structure. All a text editor sees is a flat sequence of characters or lines; In contrast, a structural editor such as Cepage will use the structure as the basis for all manipulations of the documents. Many benefits may be expected from an intelligent system that knows the specific properties of the objects it handles, rather than treating, say, an Ada program the same way as a meeting report or a user's manual. Structural editors have existed before; references to some of the most significant projects are shown in the accompanying sidebar. But I think Cepage is outstanding among these tools primarily because of the following features: - The advanced visual interface through Showing the structure As already mentioned, a structural editor manipulates documents in terms of their structure. This is all good and well, but with interactive systems it is not enough to use adequate representations. One must also present the user with faithful images of these representations. Many early structural editors were rather inadequate in this respect. They used a primitive, often line-by-line inter- face. Cepage relies on an advanced inter- face, modeled on the concepts of direct manipulation pioneered by Smalltalk and analyzed by Ben Shneiderman in "Direct Manipulation: A Step Beyond Program- ming Languages." Shneiderman studied many successful interactive systems in such diverse areas as computer-aided instruction, computer- aided design, games, and others. He attributed their success in large part to their ability to provide users with a clear

Transcript of Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am...

Page 1: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

3.tedCsit. Inment,nplexrecordtatlonNandlmen·lbllityplus:'ldent'.Inc.l.base:.cal Cmlcal

visorT§!~easy, andIcan

IportDOS.'a;met."and

,Itsluen·flies.from~s: A:Wltt,

Cepage:A Software

DesignTool·

Formany years,software engi-neers have pro-vided engineers

of other fields with advanced design toolsthat considerably facilitate their jobs,relieve them from tedious tasks, put themin control of the design process, and helpthem turn out quality products. But thetools used by software designers them-selves look quite primitive in comparison:the standard design environment includesa text editor, a compiler, perhaps adebugger, but hardly anything that couldbe characterized as a design system.

This article presents a system-C6page-whose aim is to provide soft-ware designers with facilities similar towhat is known in other application areasas computer-aided design.

C6page (pronounced sea-page or say-pajj) is intended to make the full power ofcomputer-aided design available to soft-ware developers in practical environ-,ments. It frees its users from many of thetedious tasks traditionally associated withthe construction of programs and othersoftware-related documents and allowsthem to concentrate on the reallyimportant aspects of software design. Theaim is to use Cepage as the basis for acomplete software development environ-ment supporting all activities of softwaredesign.

Visual al'ld structuredC6page relies on a simple but powerfulidea: to allow visual manipulation ofstructured documents.

What do we call a structured document?The most obvious example is a program

By Bertrand Meyerwritten in some high-level language like not only manipulated but actually seen.Pascal, C, Ada, or FORTRAN, with their _ The ease of tailoring the system to anyhierarchical structure (program sub- new language, making Cepage a versatileprogram, block, instruction, expression, tool adaptable to many differentand so on). Such programs are indeed one applications.of the primary targets ofCepage but by no _ The open architecture of the system,means the only one. In fact, any document which allows. it to be interfaced with otherwith an interesting enough structure is an tools and makes it a promising candidateequally good candidate for handling by . as a basis for a complete software devel-Cepage. This description includes such opmentenvironment.software documents as specifications, _ The ambition of the entire systemdesigns, or schedules. design to take structural editing out of the

But technical documents whose struc- laboratory and make its exciting potentialture in a given environment is often stan- available to practicing programmers indardized can also be handled by Cepage. ordinary environments.For example, a certain company orproject might require that technicalreports begin with a header page of a nor-malized form (author's name, title,abstract, date, approval, etc.). and con-tinue along a formal structure (sections,paragraphs, etc.). The usual way to dealwith structured documents on a computeris to use a text editor-in other words, toforget about the structure. All a text editorsees is a flat sequence of characters orlines;

In contrast, a structural editor such asCepage will use the structure as the basisfor all manipulations of the documents.Many benefits may be expected from anintelligent system that knows the specificproperties of the objects it handles, ratherthan treating, say, an Ada program thesame way as a meeting report or a user'smanual.

Structural editors have existed before;references to some of the most significantprojects are shown in the accompanyingsidebar. But I think Cepage is outstandingamong these tools primarily because ofthe following features:- The advanced visual interface through

Showing the structureAs already mentioned, a structural editormanipulates documents in terms of theirstructure. This is all good and well, butwith interactive systems it is not enough touse adequate representations. One mustalso present the user with faithful imagesof these representations.

Many early structural editors wererather inadequate in this respect. Theyused a primitive, often line-by-line inter-face. Cepage relies on an advanced inter-face, modeled on the concepts of directmanipulation pioneered by Smalltalk andanalyzed by Ben Shneiderman in "DirectManipulation: A Step Beyond Program-ming Languages."

Shneiderman studied many successfulinteractive systems in such diverse areasas computer-aided instruction, computer-aided design, games, and others. Heattributed their success in large part totheir ability to provide users with a clear

Page 2: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

picture of the current progress of the ses-sion and the internal state of the system ateach step of a session.

This type of system is in contrast to theall-too-common silent movie systems,which are so shy that they do not tell youanything about what's going on. Ofcourse, one should not say too mucheither; much of the challenge in designinggood interactive systems is in finding theright compromise between undue terse-ness and unwanted verbosity.

So you want to tell the user what'sgoing on. But what do you show? In a texteditor the answer is easy: you displaysome contiguous excerpt of the text beinghandled. If the editor is full screen, likeIBM's SPF or Vi on UNIX, this excerpt isgoing to fill a screen or window-say 24lines of contiguous text. Figure 1 shows atypical screen from an editing sessionwith such an editor, where the text beingedited is an Ada program.

Unfortunately, the selection of dis-played information at any point during thesession-a screenful of contiguous text-has very little to do with the underlyingstructure of the document. Programmerswho use text editors for composing pro-grams know this well. They spend muchoftheir time going back and forth fromone end of the file to the other, chasing forstructurally related but physically remoteelements-the infamous scrollingsyndrome.

When designing Cepage, we came tothe conclusion that such an approach wasunacceptable for a structural editor. Itwould be useless to have a tool relyinginternally on the document's structure ifwe were not able to display this structure.What we had to provide was a structuralview at varying levels of abstraction.

Again, the driving metaphor iscomputer-aided design. For example,with a good CAD system for designingelectronic systems, you may traverse thestructure of your system, choosing to seeat each step a graphical representation atthe level of the whole system, a sub-system, a wafer, a circuit, a gate, a tran-sistor, etc. For programs the representa-tions are more likely to be textual thangraphical (although work has been doneon graphical programming techniques),but the same principles apply. For exam-ple, a representation of the Ada programin Figure I at the top level should be some-

thing like that shown in Figure 2.Here the elements in italics (such as

<5 declarations» represent program ele-ments that are present but may not beshown in detail due to lack of space. Wesay that such elements have beenabstracted. By abstracting elements, it ispossible to give a clear view of the struc-ture at a certain level in the document.Here we see immediately what procedurePROCESSOR is made of.

If one wants to see an abstracted ele-ment, say the procedure _body of pro-cedure RES1ltRT, some of the context willhave to be sacrificed. This is achieved inCepage simply by moving the cursor ormouse to the corresponding place on thescreen and requesting a zoom. Since thescreen is not large enough to show every-thing, some details of the enclosing unitwill disappear to make space for the pro-cedure body; they may be shown againthanks to the unzooming operation. In anycase, the view shown will be a structuralone, corresponding to a meaningful syn-tactic structure rather than an arbitrarygrouping of contiguous elements.

In Cepage, the abstraction mechanismis entirely automatic. From user requeststhe system determines what should beshown and what should be abstracted. Tothis effect it uses a sophisticated displayalgorithm that takes into account both thedocument structure and the available win-dow space.

Excerpts from a sessionThere is more to say about the principlesof Cepage, but since I am cIaiming soloudly that the system is a visual one, it isbetter to interrupt my presentation at thispoint for a small demonstration.

You are using Cepage on an unspecifieddisplay. In this article, various font con-ventions (italics, bold, etc.) are used todistinguish the different types of ele-ments. On an actual terminal, Cepagerelies on the facilities provided by thehardware: fonts on a black and white bit-mapped screen, different colors on a colordisplay, various levels of highlighting,etc.

Figure 3 shows the picture you mighthave at a given moment in a Cepage ses-sion. Actually, Figures 3-6 do not show

the •••devapracidow!lion:usuacatalally (that l

ifica'It;

wor~like,originoteproglabelface-<Besent;(Thecour:term.the eand tticull

Tecane.use tl"proundeturedtianyentit~evenlexpa;textuthee:pass~otheroverUNI:

Th<1mbegirappe:colorweseThes.mentcannlspac~in thelines

Neabstrcamr

Page 3: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

asam ele-eWe

, itistruc-It.~dure

:t will:din'orIthethe{ery-mitpro-lin:nanyural;yn-ry

lismlestseI. To,layh the,win-

pies)

, it isthis

:ifiedon-to

bit-color

the whole screen but the main window,devoted to the main active document. Inpractice, the screen contains other win-dows for such things as session informa-tion and help messages. Also, there isusually not just one active document but acatalog of documents. The others are usu-ally copies of parts of the main documentthat are kept for purposes of partial mod-ification, copy, move, etc.

It appears from Figure 3 that you areworking on a program in some Pascal-like, slightly Ada-ish language. The mostoriginal feature of this program is that it isnot complete. It contains not only trueprogram elements in bold-for example,label and until-but also things in regularface- like < Instruction> and<Boolean_expression> -which repre-sent as yet unexpanded program parts.(The reader who remembers comp.ilercourses will know these parts as non-terminals.) They are distinguished fromthe expanded parts by the angle bracketsand by the regular face font (or, on a par-ticular terminal, by a different color).

Texts such as the one displayed here arecalled partially expanded documents (weuse the word "document" rather than"program" to emphasize again that theunderlying language could describe struc-tured objects other than programs). Par-tially expanded documents are the basicentity that Cepage handles. Of course,eventually a document should be totallyexpanded, and Cepage can then generate atextual version of the finished product. Inthe case of a program, this text may be'passed on to a compiler, for example; ,other kinds of documents might be handedover to a text formatter such as troffonUNIX.

There is also an instance of<Instruction> in the repeat loop at thebeginning of your program body thatappears in italics (again, it might be acolor) rather than regular face. Similarly,we see < 7 Instructions> a little below.These are examples of abstracted ele-ments (abbreviations for elements thatcannot be shown in detail for lack ofspace). The expansion of the instructionin the repeat loop might contain as manylines as needed.

Note that when a compound element isabstracted it may be useful to display acomment associated with the element,

/- . .:::-:;

~(:A~c~J1tfgJou~.pr,99ram'fragment .. ''~«:>:-;::...,.:~<,~,';..~.,';' ." ./.('.':.. ,~.<'.; .•...... -:.~~.._,..:,::.' ~-' ":,,,,:.,.-.'ff':REMAINOER: REAlj'<'. "",'Nit USERS;'INTEGER:=':'0'"

:,~~~~tif~~~~;~~;~~i.Ylo66;,"..,.,'::~<:.H·~.r:~aABl~;~':raV.(1;·;:: UMIT)ofINTEGER;.

ti,"'!':':''- ::d" .for N.•n1, . , LIMIT lo~p, . " .

~ii~~j.!f~:~:~~ji~$~~¥~~::f~~~Ttf':.1''';proce<l"rellACKUR (F: me) Is ... :.. ',' ,', . c,. ; .. '11~}!~~i£~J~!~f:~t~~',Figure 1.

Page 4: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

rather than just an indication like< Instruction> , which is not very infor-mative. It is indeed possible with C~pageto attach a short comment to an element;the comment will be displayed if the ele-ment is abstracted. It may be enteredeither after or before the element has beenexpanded, allowing for both bottom-upand top-down software construction.

Of course, at some point you may wantto see some of the abstracted part. Noth-ing could be easier: just move the cursorto some position in the < Instruction> initalics and press a mouse button (or func-

tion key, depending on the terminal). Ofcourse, as you go in you wiIllose somecontext, which you may see again by mov-ing out again, using the correspondingoption in the menu.

For the moment, however, you areinterested instead in developing your pro-gram a little more. You have decided toexpand the < Instruction> that appearsjust after the repeat loop; thus you havebrought the cursor (represented by thehand on Figure 1) to the window in whichthe word "instruction" appears. You lookand choose the Expand option, againusing whatever selection medium is avail-able: mouse to point in the menu, functionkey, etc.

The basic interaction with C6page isnormally done by show and select. Inother words, you indicate a position on thescreen and select a function from a menu.Sand S is a very productive way of deal-ing with computers interactively; theeffectiveness of this approach is backedby extensive psychological studies. Ofcourse, the S and S principle is at its bestwhen the display and the selection device(mouse, joystick) are adequate.

Once you have said that you wanted toexpand a particular instruction, some-thing new will appear on the screen. Thetext of the document does not change, buta new menu pops up I listing the set of pos-sible instructions in the language at hand(Figure 4).

The new menu allows you to select thetype of instruction you want. You do notneed to type any keywords (such as if);you make a choice from the menu and thesystem will take care of generating theproper syntax for you.

Software developers have more inter-esting things to do than type. The problemis not so much typing itself as the fact thatit detracts your attention from other, moreimportant co'ncems. (However, you mayalso type the beginning of the instructionif you prefer to work in this fashion.)

Assume you decide you want a condi-tional instruction and, with any availableselection facility, choose the correspond-ing item in the menu. The system gener-ates the resulting structure. Figure 5shows what now appears on the window.The part which previously read<Instruction> has been replaced withthe syntax for a conditional instruction.

Note that up to now you haven't used analphabetic keyboard; the mouse hasserved you well enough. You do not haveto use the mouse. You could type phrases,or meaningful beginnings of phrases, ifyou preferred, or you may work by SandS. Which solution makes more sensedepends on your personal taste and on thepower of the terminal hardware available.

At some point, for elements such' asexpressions, it may become tedious tohave to describe the structure-you justwant to type in the stuff. For the elementsof lowest levels, such as identifiers orconstants, this is the only possibility any-way since they have no further structure.To enter such elements you just type them

at th~bepa

Fatypinsion I

instrlIt j

choiction Ian adthat)phralpel aljust \01

is ex!genelloop.

Otlthosedelete(put l

impoCepaapplythep:exam

~else

and"delet(contaone 0hand,by,. 8sponc

LangLang!aims.webeabilit·sis ha

Thlasscs~progrtodayficati(

Page 5: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

isI

In thelenu.eal-

:ed)fbestvice

fhe, butfpos-and

thenot);I thee

er-blem•thatmoreaay;ion

thn.:dan

aveISes,ifand

I theIble.

)

1stents

.ny-:re.ilem

at the place where they appear. They willbe parsed immediately by the system.

For example, you may wish to resort totyping when entering the Boolean expres-sion of our newly built conditionalinstruction, as shown in Figure 6.

It is important to note that the user has achoice at all levels between menu selec-tion and typing. When typing is chosen,an added advantage of structural editors isthat you may type just the beginning of aphrase, provided it is long enough to dis-pel any ambiguity. For example, typingjust while at a place where an instructionis expected is enough for the system togenerate the entire pattern for a whileloop.

Other features of Cepage resemblethose generally available in text editors:delete, copy, move, search, replace, yank(put aside for later use), etc. There is animportant difference, however, since withCepage all such manipulations may onlyapply to syntactically meaningful parts ofthe partially expanded document. Forexample, if we have:

!b:=illE2J Ielse

a:= 5;call P(x)

end

and want to apply an operation such asdelete or copy to a part of the documentcontaining c, then this part may only beone of the boxes shown. On the otherhand, there is no way to replace else callby ; goto since neither pattern corre-sponds to a syntactic entity.

Language independenceLanguage independence is one of the mainaims ofthe design of Cepage. Why shouldwe be so interested in preserving adapt-ability to various languages? This empha-sis has several reasons.

The first reason simply comes from anassessment of the situation. Clearly manyprogramming languages are being usedtoday and there is little prospect for uni-fication in the near future. A tool tied to a

single language would have a limitedpractical interest.

On the other hand, entirely differentlanguages are not the only case when youneed language adaptability. Very oftenlocal programming environments (compa-nies, laboratories, universities, etc.) havespecific variants of programming lan-guages (for example, 'Thrbo Pascal, VMSPascal, and IBM Pascal), which differ insmall but significant details. Adapting atool to such variations should be a simplematter.

Third, methodology-conscious projectsare increasingly defining programmingstandards (such as comment conventions,exclusion of certain constructs, etc.). Itmay be good to have such standards, andbetter to control their application, butnothing can beat using a program con-struction tool where the standards arebuilt-in, having been integrated into thelanguage. A modest example shown bythe preceding session was the automaticaddition of a specific comment at the endof a main program, but much more inter-esting conventions can be supported .

Finally, many types of document struc-tures, which may not always be thought ofas languages (such as a standard structurefor technical reports), may benefit from aversatile tool that will automaticallyenforce the observation of the structure.

With these remarks in mind, Cepagewas designed as a language-independentsystem where the structure of the lan-guage is a parameter. To define a new lan-guage for Cepage, a formalism is used:language description language. An LDLdocument is the description of a certainlanguage, given as a sequence of con-structs. Such a construct is shown as fol-lows, and corresponds to the while loop ofPascal.

construct While_loop-- "While" loop in Pascalshort "while ... "abstract

aggregatetest: Expression;body: Instructionend

concreteformat

"while" test "do" bodyend

endThis description comprises the follow-

ing elements:• A full name, While-loop, used to refer-ences the construct.• A short name, while ... , used for dis-play (for example, in choice menus).

Page 6: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

• An abstract part, giving the structure ofwhile loops, which comprises two compo-nents: an expression (the test) and aninstruction (the body).• A concrete part, which gives the exter-nal representation of a loop with thesecomponents, indicating where the key-words should be placed.

This is a simple but typical example ofconstruct description. Note that there isno need in normal cases to give formattingcodes. Indentations, line feeds, etc., areautomatically taken into account by thedisplay algorithm of Cepage (but thingsare not quite so simple in a language withstrange formatting requirements, such asFORTRAN, for which the concrete partof some LDL construct descriptions has tobe more elaborate) .

An added benefit of language adapt-ability is that Cepage may be used to per-form many ofthe functions of traditionalpreprocessors that are used to artificiallyenrich languages.

A typical case for using preprocessorsis to add instructions such as while loopsto FORTRAN, which does not includesuch a construct. The preprocessor willtransform programs with while loops intoordinary FORTRAN programs where theloops are expressed by conditional and

goto instructions. With Cepage, it is easyto extend the LDL description of FOR-TRAN with a while construct whose con-crete part is the actual FORTRAN struc-ture, namely:

label IF «test» THEN<body>GOTOlabel

label END IF

In this interactive pattern, the user willselect the pseudo-FORTRAN while pat-tern, and the system will generate correctFORTRAN code.

The designers of Cepage felt verystrongly that writing a language descrip-tion should be easy. Using LDL, thedescription of a language should takefrom a few hours (when working on avariant of a previously defined language)to at most a week (for an entirely new lan-guage). We expect many languagedescriptions to be obtained by imitation ormodification of existing ones.

Of course, LDL descriptions will bedone using Cepage. LD L is one of thefirst languages to be supported by thesystem.

System structureTo better understand the concepts andapplications of Cepage, it is useful to ex-

plain some of the techniques underlyingits implementation.

The general structure of the system isshown in Figure 7. Cepage was designedand implemented according to object-oriented techniques, and accDrdingly thestructure is best described by explainingthe main object classes (abstract datastructures) used.

The abstract syntactic fDrest is a hier-archical data structure that provides aninternal representation of the dDcumentbeing manipulated.

The external form is an equivalent rep-resentation, suitable fDr stDrage Dnexter-nal devices. Remember that C6pageworks Dnpartially expanded documents.If a session is interrupted before theexpansion is complete, it must be possibleto store the tempDrary state of the dDcu-ment in an appropriate form for laterretrieval.

The display form is produced by theCepage display system by mapping theinternal document structure, as repre-sented by the abstract syntactic forest,onto the available window space, choos-ing the elements that will be abstracted forlack of screen real estate, and performingthe necessary formatting and indentationoperations. As already mentiDned, thisprocess is entirely automatic. The userdoes not need tDintervene but will get anappropriate view at each stage Dfthecomputation.

The display fDrm is a list Dfwindowsthat can be processed by another of oursoftware tools, Winpack (a general multi-windowing screen package).

The text form may be generated fDr atotally expanded dDcument for possibleprocessing by other tools.

Finally, the grammar graph is the datastructure representing the language. Thisis where Cepage's language adaptabilityCDmesin. The system kernel itself knowsnothing abDut any particular languagewhatsoever; all the information is CDn-tained in the grammar graph, reflectingthe LDL language description.

Further applications Dfthis techniquemay involve mDre than one grammargraph. For example, two windows may beused cDncurrently to run two instances DfCepage, one for a prDgram design lan-guage, the Dther for a programming lan-guage. If the grammar graphs are con-

necte,imme

CepeTo allthe wisysterwill bCepal

Motions]dDcufbierarconte:conte:previc

Mamakein theto CDn

ThfMark,the domost!yet reieffectthath:fashio

EXImake!unexpshow!the inJgraph

Carexpan:into thchDicethe US!as pas:carrie(whenlinstrue

I exprestionalloop.

ConCDmm;(expanchangfmentsempha

SealReplacfunctic

Page 7: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

misgnedt-y theaing1

trep-:xter-

ssiblecu-

t,)OS-

ed forming.lionliser:t an

wsurmlti-

lataThislitytOWS

e1-

ng

aybe:s ofl-

an-i-

-I--

I

nected, changes to the former may beimmediately reflected in the latter.

Clipage functionsTo allow the reader to get a better grasp ofthe whole scope of Cepage, we now give asystematic list of the functions that are orwill be supported by the current version ofCepage.

Moving around. A basic set of func-tions makes it possible to move around adocument in a manner consistent with itshierarchical structure: out (to enclosingcontext), in (to some subset of the currentcontext), to the next element, and to theprevious element.

Marking. The marking commandsmake it possible to take note of positionsin the document while moving around andto come back to them later.

The three marking commands are:Mark, which marks the current position inthe document; Back, which returns to themost recent position to which one has notyet returned; and Forth, which cancels theeffect of the most recent Back commandthat has not yet been canceled in thisfashion.

Expansion. The expansion functionmakes it possible to expand a previouslyunexpanded element of the document, asshown earlier. It is executed according tothe information contained in the grammargraph.

Cancel and Modify. Canceling anexpansion puts an expanded node backinto the unexpanded state. In the case of achoice node, the Modify function allowsthe user to make a new selection; as muchas possible of the initial expansion will becarried over to the new one. For example,when transforming an if ... then ... elseinstruction into a while loop, the Booleanexpression and the then part of the condi-tional instruction will be transferred to theloop.

Comment and Explain. Thc Commentcommand attaches a comment to a node(expanded or not). The Explain commandchanges the display mode so that com-ments will be displayed with particularemphasis.

Search and Replace. Search andReplace correspond to traditional editorfunctions. In Cepage, however, the search

pattern and (in the Replace case) thereplacement are structured elements simi-lar to the document being edited: the edi-tor is called recursively to enable the userto define them (in special windows).

Selection. The selection facility allowsthe user to make a choice among a set ofpredefined possibilities and allows thesystem to determine which item wasselected. The way in which the list ofchoices is displayed and the user makes aselection (pointing with a mouse in amenu, pressing a function key, typing anordinary key, etc.) depends on the temu-nal hardware.

Parsing. The parsing function makes itpossible to read a text typed in by the userand to build the corresponding syntacticstrocture (subtree of the abstract syntaxtree). The text can be incomplete. Theparsing method used in Cepage allows thesystem to fill in the missing parts ifthetext typed is incomplete but unambiguous.

Undo and Redo. Undo makes it possi-ble to back up to previous states of the edi-ting session by canceling the effects ofpreviously issued commands. Redo can-cels such a cancellation.

Record and replay. The record andreplay facility makes it possible to archivethe succession of commands issued duri ng

an editing session and to replicate them. Itthus allows recovering from a systemcrash.

Catalog management and copy. Cata-log management keeps several documentsduring an editing session, one of which isthe active document, the others consti-tuting the catalog. This function allowsthe user to select an element of the catalogas the new active document, to copy partof the active document into a new entry ofthe catalog, or to copy an element of thecatalog onto an unexpanded node of theactive document.

Delimit. The delimiting functionenables the user to define a part of a docu-ment to be used as a parameter for a func-tion such as cancel, copy, etc. Since themoving around functions are particularlysimple to invoke, delimiting is mainlyuseful for selecting sublists.

Save and restore. The save/restorefunction copies documents (which may bepartially or totally expanded) frommemory to files and back, using an appro-priate external representation.

Library management. Library man-agement maintains data bases of (partially

Page 8: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

CDYNAMONEWUICROSOFTC $249.95C FUNCTION LIBRARY

BEST YOU CAN GET325 FUNCTIONSFULLY TESTED

SUPERB DOCUMENTATION. BETTER FUNCTIONS

Most complete screen handling piusgraphics; cursor/keyboard/dataentry, 72 string functions with wordwrap; status and control; utility/DOSBIOS/time/date functions; printercontrol & more. Special functions.Functions you NEED but don't have!Full source code. No royalties.4 disks $129.95

POWER WINDOWSMOST POWERFUL YETPOP-UP WINDOWS FOR

Menus/OverlaysHelp Screens

Messages/AlarmsZAP ON/OFF SCREEN

FILE·WINDOW MANAGEMENTCOMPLETE CONTROL OF:

CursorAttributesBorders

AUTOMATICHorizontal & Vertical Scrolling

Word WrapLine Insertion

The most powerful, flexible and easyto use windowing package available!Many types of menus. Highlighting.Move data between files, keyboard,program and windows. Status lines.Change size/location/overlapping.Move/add/delete/cascade windows.Full source code. No royalties.3 disks $129.95

SUPERFONTS FOR CSUPER SIZE CHARACTERS

Monochrome adapterColor/graphics adapter8 FONT LIBRARIES

Dramatic high impact screens/titles/messages. Use with or \'lith outwindows. Great for projection TVCreate own font & image libraries oruse oLirs. Use with windows forspecial effects or animation. Fullsource code. No royalties.Font and Function Library $49.95

iiiPOILYTIRO~Hid, Qlt,l!in' S, ,tr\\'dr" Sin,,· 19~2

NEW!VERSION CONTROL SYSTEM

FOR PROGRAM DEVELOPMENTStorelretrieve multiple versionsRelease & configuration control

Auto-logging & display of changesInvaluable audit trail of changes

PVCS gives you complete control ofprogram development, includinghistory & recoverability of allchanges. Permits multiple parallellines of development, multipleversions of your program. The longerthe program the more essentialPCVS is. Don't develop anotherprogram without it. Saves criticaltime, adds control and flexibilitySingle user license $395.00

B-TREE LIBRARY& ISAM DRIVER

POWERFUL DATA MANAGERFixedNariable length records

FAST I EASY TO USEI16.7 MILLION RECORDSIFILE

16.7 MILLION KEYS/FILEFast B-tree indices. Addlremovekeys Find firstllastlnext/any key. Findkeys by Boolean selection. Read/write/delete or add records to file.Full source. No royalties. $129.95MAKEUtility (Snake) $59.95

C·TERPINTERPRETER FOR C

NO COMPROMISE, FULL K&R- BUILT IN SCREEN EDITOR

FAST, FASTCOMPILE/LINKUSE EXTERNAL L1BRARIESl

SYMBOLIC DEBUGGINGSINGLE STEPPING

RAVE REVIEWSI2 disks and manual $299.95

C FUNCTION LIBRARIESPOWER WINDOWSSUPERFONTS FOR CB-TREE LIBRARY & ISAMPCNX, UNIXTMWORK ALIKE

C· TERP INTERPRETER FOR C

POLYTRON VERSIONCONTROLSYSTEM ''"AT&T

COMBINE AND SAVElC LIBRARY plus C WINDOWSBOTH for only $179.95+ SUPERFONTS FOR C $199.95

(A$310VALUE)

C BUSINESS LIBRARYINCLUDES C FUNCTION LIBRARY. POWER WINDOWS.SUPERFONTS FOR C. B-TREE LIBRARY, ISAM

ALL for $299.95(A $440 VALUE)

C PRODUCTIVITY LIBRARYINCLUDES C FUNCTION LIBRARY. POWER WINDOWS.SUPER FONTS FOR C, and C-TERP INTERPRETERALL for $419.95

(A $610 VALUE)

C TOTAL LIBRARYINCLUDES C FUNCTION LIBRARY. PC WER WINDOWS.SUPERFONTS FOR C. B·TREE LIBRARY.ISAM and C:TERPC Interpreter

ALL for $499.95(A $740 VALUE)

SPECIAL OFFER*(expires 9/30/86)

$L1ST $SALE $SAVEMICROSOFT C COMPILER 450 250 200

Version Control SystemVirtual Memory ManagerPolytron PowerCommPolyFORTRAN Tools 1Poly Cross Ref(C & Assembly) 178 88 90

Poly DeskPlus &Poly Archivist &PolyCryplographer 185 95 90

Polylibrarian II 149 69 80Polymake 99 59 40PolyOverlay 99 59 40

OPERATING SYSTEMSMu/li-User Mu/li· Tasking Networking

PCNX" 99 19 80PCVMS" 99 19 80OIS TOOL BOX" (BUild your own

operating system) 99 19 80"WENDIN SOFTWARE'with purchase 01any Enteiekon combinetion librarylisted above. Limit 1Special ONer item per customer.Offer expires 9/30/86_

Entelekon

~I

or tot.undermenti

Ge:creattexpan

lotmodildescriuses (

I LDL.. relies

a desctionpmodii

j possilmargcorre:devel,

Setcheck

! perfo:, only ~

incluling Sf

ExmakedOCUIprogrguaglsemaltiallycutedunexiactivlexeclltowarrapid

Di!anah:givensental

Litprimienablthee.C~palCepalware-beuslsoftwvariOlanaly.transl

Page 9: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

--:----1I

79.9599.95

,

or totally expanded} documents, storedunder the external representation alreadymentioned.

Generation. The generation functioncreates textual versions of totallyexpanded documents.

Interactive language description andmodification. The interactive languagedescription and modificatio~ functionuses Cepage itself to enter and modify

I LDL descriptions (grammars). It thusrelies on a grammar graph obtained froma description ofLDL in LDL. This func-tion provides for incremental languagemodification. In other words, it makes itpossible to construct and modify a gram-

i mar graph in a stepwise fashion, as the! corresponding LDL description is being

developed and updated.Semantic checking. The semantic

checking function makes it possible to! perform verifications on documents. It is, only applicable if the language description

includes the definition of the correspond-ing semantic constraints.

Execution. The execution functionmakes it possible to execute the activedocument, considered as an executableprogram. It is only applicable if the lan-guage description includes dynamicsemantics for each operand type. A par-tially expanded document may be exe-cuted: when execution reaches anunexpanded element, the user is inter-actively asked to provide the results of theexecution. This facility is a first steptoward making Cepage into a tool forrapid prototyping and program testing.

Display. The display function displaysan abstract syntax tree or subtree in agiven window area, finding the best repre-sentation it can.

Library of primitives~ The library ofprimitives is a set of procedures thatenables outside programs to access all ofthe Cepage functions mentioned and theCepage data structures. By making theseCepage internals accessible to other soft-ware tools, it is planned that C6page willbe used as the kernel of a more completesoftware environment, in which tools ofvarious kinds (such as static programanalysis, complexity analysis, programtransformation, testing compiling, rapid

prototyping, text processing, etc.) will beable to take a~vantage of the powerful setof basic data structures and functions pro-vided by Ccpage.

ImplementationA prototype version ofCepage was devel-oped at Electricite de France in 1982-83by the author and Jean-Marc Nerson foran mM mainframe environment runningMVS and TSO, with 3279 color termi-nals. The current version is an entirelynew development, applicable at themoment to any UNIX or XENIX environ-ment. Versions for MS-DOS systems andVAX-VMS are planned.

The development, undertaken by Inter-active Software Engineering, Inc., uses aSumitomo Electric workstation (D-station) running UNIX System V, with acolor bit-map display.

The design and implementation weredone with an object-oriented language,.Eiffel, emphasizing reusability of soft-ware through techniques of multiple andrepeated inheritance and security throughstatic type-checking. The underlyingDynamem memory management systemuses virtual memory and parallel garbagecollection. Screen access is through Win-pack, a multi-wind owing screen manage-ment package.

We view Cepage, Eiffel, Winpack, andDynamem as bricks toward a powerful,integrated software development environ-ment emphasizing the efficient productionof high-quality software.

The next stepThis article has emphasized three aspectsofCepage:• Editor-the system for creating andmodifying documents at the source lan-guagelevel• Program development system, withfacilities for program checking, testing,and rapid prototyping• Basis for a programming environment.

These goals are short-term. To con-clude with a more futuristic view, we willnow present a more remote but verypromising application of this system insolving the problem l)f softwarereusability. We may call the Cepage solu-tion pattern-based interactive programgeneration.

", .•···;:.'-o'j.",

..'Jj,

Most of the software written today is ofa repetitive nature. A number of basicprogram patterns (counting, searching,sorting, comparing, exchanging, assign-ing, creating ... ) exist on which pro-

. grammers compose endless variations.Most of this work is done at the lowestreasonable level, that of commonlanguages.

The use of shared, standard compo-nents is not-despite a few exceptionssuch as libraries of numerical software-commonplace. This situation stems inpart from the fact that each new situationmay be slightly different from the onesencountered previously. For example,even though most search routines share ageneral organization (go to the beginningof the table, loop until either the requiredelement has been found or the subset ofthe table in which it may appear has beenexhausted, report "found" or "absent"),the representation details will consid-erably vary from one case to the next.

It is not easy to construct software com-ponents that provide a suitable answer tothe problem of reusability. Consider thesimple problem ofproviding users of acomputing center with a tool for sortingarrays. Assume the algorithm chosen isQuicksort, which is well explained incomputer science textbooks, so you don'thave to worry about this aspect of thequestion. A particular problem instance ischaracterized by how elements will becompared and how they will beexchanged. The solutions open to a soft-ware toolsmith are the following:

A. Provide procedures for the most fre-quently occurring cases, for example,increasing and decreasing sort of integer,real, etc., arrays.

B. Provide a single procedure (or oper-ating system command) with manyparameters or options.

C. Provide a single procedure with twoprocedure parameters corresponding tothe comparison criterion and the exchangemechanism.

D. Have a sorting procedure skeletonand manually create a tailor-made versionfor each user who requests it, filling i.nhisor her particular sorting criterion andexchange mechanism, with the help of atext editor.

Page 10: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

Whitesllliths, Ltd. HasFor over seven Th C -I V "'Ir t The result is ayears Whitesmiths, e Otn.pt er .I.OU~Van product line built

~~d~f~~:t:os~~:~: On The MachineYouUse. f~~mt:;r~~r~:~on developmg and .- umform enVIron-supporting a family of quality systems software. ment for the professional applications developer.Today, Whitesmiths is the only company offering Identical source code across all machine archi-compatible C and Pascal native and cross tectures; support for ROM-based programs; acompilers for the full spectrum of computers uniform run-time environment; and the abilityon the market-from the IBM PC to the to mix code in assembler and other highIBM 370, from the DEC Micro-ll to level languages are just a few of thethe VAX 8600, and all of the most many features that comprise thesepopular processors in between. superior compilers.

As a forerunner in the development of If you need a C or Pascal compiler forC and Pascal compilers, Whitesmiths has your machine, give Whitesmiths a callplayed a major role in at 1-800-225-1030.defining and refining the Wht-tesffil.ths, Ltd. Chances are, we havestandards for ANSI C and what you want./usr/group libraries.

INTERNATIONAL DISTRIBUTORS: FRANCE. COSMIC SARL. 52 Quai des Carrieres. 94220 Charenton Le Pont. Paris. (14) 378·8357· GERMANY. GEl, Gesellscheftfuer Elektronische.lnformationsverarbeitung MBH. Pascalstrasse 14. 0-5100 Aachen. 02408/13-0 • JAPAN. Advanced Data Controls Corp .. Nihon Seimei OtsukaBldg .• #13·4. Kita Otsuka 1-Chome. Toshima·ku. Tokyo 170. (03) 576-5351 • SWEDEN. Unisoft AB. Fiskhamnsgatan 10. S-14155 Goleborg. (31) 125810. UNITEDKINGDOM. Real Time Systems ltd .• P.O. Box 70. Douglas. Isle 01 Man. (624) 26021.

E.gene:

Ncreuse

Sotheu.pointin phas kecasesmuti:

Inlargerequiusinll

·andeSo

ineffaspathe irTheeoflO,

SotailoIprom

So:venti,proc!with .used,samemacrpilerdiffe!ses, CFuth!inter,actuamnlisproc!in the

Strsolutinotioas a ~ting (a sor1

Onthee(activlrion,inap

Page 11: Cepage - ETH Zse.ethz.ch/~meyer/publications/architext/cepage_cl.pdf · of Cepage, but since I am cIaiming so loudly that the system is avisual one, it is better to interrupt my presentation

t is abuiltoundide airon-)per.rchi-ns; a)ilityhighfthehesellers.r forI call030.haverant.

Ischaft)tsukaUTED

-- ~------------oI'Solution A is too partial. In many cases,

the users will want to sort an array ofpointers, leaving the elements themselvesin place, or use only part of the elementsas keys, so it is unlikely that many actualcases will be covered by the libraryroutines.

In solution B, the options may cover alarger number of cases, but the tool willrequire coding many options and thususing a reference manual, a cumbersome

,and error-prone process.Solution C will work but with great

inefficiency since the procedures passedas parameters will be called repeatedly inthe inner loops of the sorting program.The overhead, which is typically a factor

'oflO, will be unacceptable in many cases.Solution D, using an editor to generate

tailor-made versions, is tedious and error-prone.

Solution E implies learning the con-ventions of the particular macro-processor on hand, which may be at oddswith those of the programming languageused, even if they were designed by thesame group. For example, on UNIX, themacro-processor embedded in the C com-piler and the M4 macro-processor havedifferent conventions regarding parenthe-ses, commas, reserved words, etc.Futhermore, macro-processing is notinteractive-the user must first provideactual arguments in the adequate for-malism, then wait for the macro-processor to generate a text for inclusionin the program.

Structural editing may provide a bettersolution. A simple idea is to apply thenotion of abstract syntax. In the same wayas a while loop was described as consis-ting oftwo components, a test and a body,a sorting program may be defined as:

One can thus envision an extension ofthe editing process in which the user inter-actively describes the comparison crite-rion and exchange mechanism to be usedin a particular instance, and the system

from the description of the language, theuser providing only c, A, and B. The onlydifference is that the amount of text gener-ated by the system will be proportionallylarger in the case of program generation.

We believe that such interactive,pattern-directed program generation ispossible in the C6page framework. Thebasic mechanisms are already present. Inparticular, since the language is a mod-ifiable parameter, it is possible to extendthe basic constructs such as conditionaland loop with libraries of program pat-terns such as search, sort, or even payroll.Such patterns will be defined in the sameway as basic language constructS-bytheir abstract and concrete syntax,

The idea of program patterns 'is close tothe concept of "plans" used in the Pro-grammer's Apprentice project. We think,however, that reusable, parameterizableprogram modules can be implemented inthe Cepage framework without recourseto the artificial intelligence techniquesused in the Programmer's Apprentice. IIReferencesCard, Stuart K., Thomas P. Moran, and Allen

Newell. The Psychology o!Hu1rUJn-Computer Interaction. Hillsdale, N.J.; Law-rence Erlbaum Associates, 1983.

Meyer, Bertrand. EijJel: A Language for Soft-ware Engineering. Technical ReportTRCS85-19. Santa Barbara: Univ. of Cali-fornia, Nov. 1985.

Shneiderman, Ben. "Direct Manipulation: AStep Beyond Programming Languages."Computer (IEEE) 16 (Aug. 1983): 57-69.

Waters, Richard C. "The Programmer'sApprentice: Knowledge-based ProgramEditing." In Interactive Programming Envi-ronments. edited by David R. Barstow etaI., pp, 464-468. New York: McGraw-Hill,1984. Originally in IEEE Transactions onSoftware Engineering SE-8 (Jan. 1982),

Bertrand Meyer is a visiting associate pro-fessor at the University of California atSanta Barbara and president of SantaBarbara-based Interactive SoftwareEngineering Inc. He was previouslydivision head at Electricite de France.

Its good for your system.

FULLY Integrated,Data Entry Windows!

• Complete input formatting• UnlimitedValidation• Full attribute control• Multiplevirtual windows• Fully automatic, collision proof overlay and

restore• Print to & scroll background windows• Animated window "zoom"

Move.grow. shrink. hide, or show any window"Loopfunction" allowsprocessing while await·ing inputAND MUCH MOREl

Includes 100%source. tutorial, reference manual.examples, and sample programs,Specify Microsoft. lattice v2 or v3. ComputarInnovations. Altec, 0 eSmet. orMarll Williams. A 511about Unil(.

100% Money Back Guarantee

NOW ... VCScrBBn!Ournew interactive screen "painter" actually letsyou draw your data entry windowsl Define fields.text. boxas & borders. Move them around. Changaattributes, Thenthe touch of a button generates Csource code calls to the Vitamin C routinesl

Requires VI~amin C lihrary above. for IBM &compa/ibles.

For Orders Or Information,(214) 245-6090

Creative Programming Consultants, Inc.Box 112097 Carrollton. TX 75011-2097InclUde$3 ground, 56 air, $15 overnightshipping,525 if outsideUSA,Texansadd61>'lIlax.Allfundsmustbe inU.S.dollarsdrawnonaU.S. bank.