-------------------------------------------------------------------------- Advanced Software Development Fall 2003 COM 3360 -------------------------------------------------------------------------- Assignment 4 Due date: Oct. 16, 2003 -------------------------------------------------------------------------- This assignment is stored in file $ASD/hw/4 in file assign.txt -------------------------------------------------------------------------- We reuse the abbreviations already introduced in hw 1: THEMES: Evolution of Java programs, change design, translate to Java READING: Read Java book as necessary to understand enough of the Java programs which you need to modify in this homework. This homework requires use of DAJ http://daj.sourceforge.net/ DAJ gives you the the power of AspectJ and the beauty of DJ and the convenience of DemeterJ all at once without having to learn a new programming language other than AspectJ. Installing: For this homework, you need DAJ. Follow the instructions in: $ASD/CCS_DAJ_Usage.html Please note that homework submission is electronic submission using blackboard. This will allow the teaching assistant to run your programs. In ADDITION, please turn in your answers in hardcopy at one of the following places: (1) Bring it to the class room and hand it to me. (2) In 161 Cullinane Hall: Put it into the teaching assistant's mailbox. (3) In 161 Cullinane Hall: Put it into my mailbox. (4) If all those possibilities don't work for you, slide it under my office door. For blackboard, the format for files should be: hw4_[last name].zip you can either use winzip or "zip/unzip" on unix to package up your files. Please package up your whole directory, but without any .class files. Question 1: ----------- Motivation: Learn to write a simple adaptive program using DAJ. Consider the program in $ASD/hw/4/daj-example I used file "my-daj" to compile and file "run" to run. The program prints out all Weight-objects and does currently not sum. The Summing class only consists of one before method: class Summing { void before (Weight host) { System.out.println(host); } } Your task is to enhance this program so that it achieves the following behavior known from hw 3 in the undergraduate class: http://www.ccs.neu.edu/home/lieber/courses/csu670/f03/hw/3/onlyDJ-capacity-with-stack/ Remember $SD = http://www.ccs.neu.edu/home/lieber/courses/csu670/f03/ The purpose of your program is to read in a description of nested containers and to build a Java object. The program then checks whether each container satisfies its capacity restriction. Example: Consider the following container description in $SD/hw/3/onlyDJ-capacity-with-stack/statistics.input ( //begin container 1 apple 1 //item ( //begin container 2 pencil 1 //item ( //begin container 3 apple 1 //item 1) //capacity orange 1 1) //capacity orange 1 kiwi 1 5) //capacity ================= Container 2 is over capacity since it contains three items with a total weight of 3, but the capacity is one. Container 1 is also over capacity. It contains 6 items with a total weight of 6, but the capacity is 5. Container 3 is within capacity. For each container which is over capacity, the program should print a message of the form: total weight 2 but limit is = 1 OVER CAPACITY Turn in the improved files and the output produced for file statistics.input. Hint: In the current version of DAJ you need to solve the problem iteratively. See $SD/hw/3/assign.txt and $SD/hw/3/onlyDJ-capacity-with-stack/constraint-checking.beh for ideas. In DAJ you can give only one visitor to a traversal. Question 2: ----------- Instead of using a visitor class, how would you advise the generated traversal using AspectJ only? Sketch an example how you would simulate a DAJ visitor in AspectJ using pointcuts and advice. ====================== System help: When you think DAJ behaves unexpectedly, remove the gen directory and call "daj" again. Make sure that your traversal aspect in file t.trv has name t.