Demeter/Java Quick Reference ---------------------------- Reuse the User's Guide for Demeter/C++ http://www.ccs.neu.edu/research/demeter/docs/u-guide.ps and the transition document: http://www.ccs.neu.edu/research/demeter/DemeterJava/forReadersAPBook/APbookWithDemJava.html The new Demeter/Java User Manual is under construction in: http://www.ccs.neu.edu/research/demeter/DemeterJava/ For simple use, we recommend the: *************************************** Demeter/Java Quick Reference Guide *************************************** (version 7.0, Fall 1998) A tool for adaptive object-oriented application development in Java. *** CONCEPTS class dictionary Describes the inheritance and the binary relation structure of your application. Serves as a lattice to propagate the functionality. (should reside in file *.cd) traversals and visitors Describe how the functionality is distributed over the classes. Traversals are defined by traversal strategies. Visitors are objects which modify traversals. (should always reside in files with names of the form *.beh) *** GETTING HELP http://www.ccs.neu.edu/home/lieber/Demeter-and-Java.html For further help, send e-mail to demeter@ccs.neu.edu *** SIMPLEST TOOL USE (Demeter/Java offers more functionality; we focus on the most powerful subset) Put your class dictionary into file program.cd Put your behavior into a file of the form program.beh Put your input objects into file program.input Then call the commands demjava new demjava test Whenever you change something, you call again demjava test To start from scratch, call demjava clean *** EXAMPLES http://www.ccs.neu.edu/research/demeter/sources/DemeterJava/examples *** SYNTAX (in simplified form, reflecting typical use) The full syntax is at: http://www.ccs.neu.edu/research/demeter/DemeterJava/ Class dictionary for Demeter/Java // is the comment character Traversal Strategies ---------------------------------------------------------------- // Star graph strategies (several edges have one node in common) // class A { traversal t(Vis vis) { bypassing { // one or more edge patterns, separated by "," -> V,m,W , // construction edge with label m => V,W , // alternation edge ~> V,W} // repetition edge to {Z1, Z2, ...} // Instead of V, W, or m the wildcard symbol "*" may be used. // General graph strategies // class A { traversal t(Vis vis) { { V -> W bypassing { // one or more edge patterns, separated by "," -> V,m,W , // construction edge with label m => V,W , // alternation edge ~> V,W} // repetition edge W -> X bypassing ... } } } // Instead of V, W, or m the wildcard symbol "*" may be used. Visitor methods ---------------------------------------------------------------- Edge V { // edge pattern before -> V,m,W (@ ... @) after V,m,W (@ ... @) } // Instead of V, W, or m the wildcard symbol "*" may be used. Vertex V { // class-valued variables, one or more before {A1,A2, ...} (@ ... @) after {A1,A2, ...) (@ ... @) -- V { // following code goes into V-constructor without arguments init (@ ... @) // Java expression is assigned to return_val. TYPE is type of expression. return TYPE (@ ... @) Behavior files ---------------------------------------------------------------- A { // verbatim (@ // Java code void f(B b,C c){ ... } @) // traversal method (@ traversal t(V v) { // traversal specification, see above } @) } kinds of adaptive methods: strategy/inlined visitor (propagation pattern style) A { int f() // strategy to W { // visitor methods before W (@ ... @) after V (@ ... @) init (@ Java expression @) return TYPE (@ ... @) } } Class dictionary graphs ---------------------------------------------------------------- // zero or more class definitions // construction class Meal = // zero or more parts // required part, construction edge Appetizer // required part, construction edge Entree // optional part, optional construction edge [ Dessert]. // alternation class Dessert : // alternatives, alternation edges, one or more ApplePie | IceCream // separator *common* // common parts, construction edges, zero or more WhippedCream. // repetition class Banquet ~ // repetition edge Meal {Meal}. Shrimps ~ // optional repetition edge {Shrimp}. // Parameterized classes Sandwich(S) = BreadSlice S BreadSlice. RecursiveList(S) : Empty(S) | NonEmpty(S). List(S) ~ S {S}. // Use of parameterized classes Meat = . Sandwiches = RecursiveList(Sandwich(Meat)). // Use of any Java class Put the appropriate import statements at the beginning of your class dictionary graph, for example: (@ import java.util.Vector; @) Then you can use the Java Vector class through inheritance or as a part: Classes = *extends* Vector. // inheritance MyVector = Vector. // part Class dictionaries Syntax may optionally appear around parts. A = "to-introduce" B "to-separate" C "to-terminate". B : C | D *common* "to-continue" B "to-separate" C "to-terminate". CommaList(S) ~ "to-start-collection" S {"to-separate-collection-elements" S} "to-end-collection". StatementList ~ "begin" Statement {";" Statement} "end". FruitList ~ "(" {Fruit} ")". Project file ---------------------------------------------------------------- demjava new creates a default project file program.prj which serves as nerve center of your application. The file explains the various entries. Copyright 1996-1998 Northeastern University http://www.ccs.neu.edu/research/demeter/sources/DemeterJava/NUDCopyright.html