Demeter/Java User's Guide Transition Document --------------------------------------------- Reuse the User's Guide for Demeter/C++ http://www.ccs.neu.edu/research/demeter/docs/u-guide.ps and the transition documents: http://www.ccs.neu.edu/research/demeter/course/f96/APbookWithDemJava.html http://www.ccs.neu.edu/research/demeter/course/f96/demjava/FromDemC++ToDemJava.html For simple use, we recommend the: *************************************** Demeter/Java Quick Reference Guide *************************************** (version 0.4.3, Winter 1997) 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 regular objects with a simple extension. (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 j-gen-make make test Whenever you change something, you call again make test To start from scratch, call make 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/sources/DemeterJava/inJava/src/demjava.cd // is the comment character Traversal Specifications ---------------------------------------------------------------- // exactly one *from* // class A { traversal t(V v) { 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. 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, ...} (@ ... @) suffix {A1,A2, ...) (@ ... @) Behavior files ---------------------------------------------------------------- A { // verbatim (@ // Java code void f(B b,C c){ ... } @) // traversal (@ traversal t(V v) { // traversal specification, see above } @) // before and after methods before A (@ ... @) after A (@ ... @) } 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} ")". Copyright 1997 Northeastern University http://www.ccs.neu.edu/research/demeter/sources/DemeterJava/NUDCopyright.html