-------------------------------------------------------------------------- Adaptive Object-Oriented Software Development Fall 1996 COM 3360 --------------------------------------------------------------------------- Final - Answer Form YOUR NAME: Final - Answer Form YOUR NAME: Question 1: ================================================== UNKNOWN1 = bypassing L to B; or bypassing ->*,l,* to B; Question 2: ================================================== 1. It is restrictive but takes structure-shyness to the extreme. All structural information in the visitor methods will be elastic. Instead of writing host.get_x().f(); we would write a traversal from Class(host) through {-> *,x,*} to {Class(x)} and we put a visitor method at Class(x) which calls f. (Of course, we have to make sure that the traversal does not do more than host.get_x().f().) Now, the host class and the class of x may be far apart. The disadvantage of the restrictive rule is that we need to write more traversals. But we could generate the traversal code! For example, an annotation /// from Class(host) through {-> *,x,*} to {Class(x)} host.get_x().f() could automatically generate all the traversal and visitor code and a function elastic_xf and replace the above line by: host.elastic_xf(); An alternative way to make host.get_x().f() conform to the law of Demeter for visitors, is to extend the traversal to Class(x). 2. Similar discussion as in 1. 3. This makes visitors less structure-shy but for good reasons. The visitors are the classes that are not part of the "real world class graph". These classes are added by the programmer in order to compensate for the changes in the "real world class graph". Now those visitor classes are going to be less in number compared to the class graph on which they operate. It is appropriate that a visitor method can access the immediate parts of its visitor class. 4. In CountingVisitor: this.get_total().intValue() not really a violation since get_total() returns Integer (a predefined class; it will hopefully never change) In PrintConsClassesVisitor: this.dig_out().get_name() Question 3: ================================================== UNKNOWN1 = "," UNKNOWN2 = b UNKNOWN3 = U( < z > : Z ( ) < y > : Y ( ) < x > : X ( ) ) UNKNOWN4 = b UNKNOWN5 = UNKNOWN3 UNKNOWN6 = c UNKNOWN7 = C UNKNOWN8 = b UNKNOWN9 = UNKNOWN3 UNKNOWN10 = c UNKNOWN11 = C UNKNOWN12 = d UNKNOWN13 = UNKNOWN3 UNKNOWN14 = b UNKNOWN15 = UNKNOWN3 UNKNOWN16 = c UNKNOWN17 = UNKNOWN3 UNKNOWN18 = e UNKNOWN19 = E UNKNOWN20 = f Question 4: ================================================== UNKNOWN1 = C_DetectionVisitor UNKNOWN2 = E_DetectionVisitor UNKNOWN3 = C_RestrCountVisitor UNKNOWN4 = E_RestrCountVisitor UNKNOWN5 = new Integer(0),cd UNKNOWN6 = new Integer(0),ed UNKNOWN7 = cr,er UNKNOWN8 = after UNKNOWN9 = C (@ this.set_d(host); @) or (less flexible) C (@ d = host; @) UNKNOWN10 = C (@ this.set_d(null); @) or (less flexible) C (@ d = null; @) UNKNOWN11 = E (@ this.set_d(host); @) or (less flexible) E (@ d = host; @) UNKNOWN12 = E (@ this.set_d(null); @) or (less flexible) E (@ d = null; @) UNKNOWN13 = if (this.get_d().get_d() != null) this.set_c(new Integer(this.get_c().intValue() + 1)); or (less flexible) if (d.get_d() != null) c = new Integer(c.intValue() + 1); UNKNOWN14 = if (d.get_d() != null) c = new Integer(c.intValue() + 1); UNKNOWN15 = V = RestrCountVisitor(C) RestrCountVisitor(E). RestrCountVisitor(S) = Integer DetectionVisitor(S). DetectionVisitor(S) = S. or V = Restr(Detect(C)) Restr(Detect(E)). Restr(V) = Integer V. Detect(C) = C. Question 5: ================================================== (syntax may be omitted) UNKNOWN1 = ClassDef UNKNOWN2 = ClassName ConstructionClass "." UNKNOWN3 = "=" UNKNOWN4 = Integer UNKNOWN5 = ClassName UNKNOWN6 = ClassName UNKNOWN7 = ClassNameTranspVisitor