Presentation is loading. Please wait.

Presentation is loading. Please wait.

Good for DJ over Java Extending traversals for collections (b..*)

Similar presentations


Presentation on theme: "Good for DJ over Java Extending traversals for collections (b..*)"— Presentation transcript:

1

2 Good for DJ over Java Extending traversals for collections (b..*)
returning a single object instead of a collection (Find) modifying the collection (Add, Delete) implementations are different for different implementations of collections

3 Embedding versus path control
Embedding does mapping work once but requires mapping construct Path control may repeat mapping work

4 Reuse of an AC written with DJ
Copy AC rename everything change path control: assumes original AC is written with path control Leads to duplication of code

5 UML Class Diagram BookName bN Book Copy Library copies books 0..* 0..*
avail book 0..* checkOutItems users What does tool do 0..* uId User Boolean UserId

6 UML Class Diagram BookName bN Book Copy Library copies books 0..* book
avail copy checkOutItems 0..* users What does tool do CheckOutItem 0..* uId User Boolean UserId

7 How can addition be expressed with ACs
Required: participant graph Provided: modified participant graph: has all the paths in original but may have more

8 Interaction schema Checkout a book for a user CheckOut { Library(
Find-> Book Find(avail==true)-> c:Copy; Find-> u:User;) addCopy { u:User Add-> Copy; c:Copy Set(avail,false)-> Boolean } }//participants: Library, Book, Copy, User Here you start ti see some of the tool features

9 Compiler asks for information or determines it by rules
CheckOut (Library lib,BookName bN, UserId uId){ lib:Library( Find(this.bN==bN)-> Book Find(avail==true)->c:Copy; Find(this.uId==uId)-> u:User;) addCopy { u:User Add(c)-> Copy; c:Copy Set(avail,false)-> Boolean } Here you start ti see some of the tool features

10 Compiler asks for information or determines it by rules
class Library { Copy CheckOut (Library lib,BookName bN, UserId uId){ Book b = lib.Find(“Book”,“bN”,bN); Copy c = b.Find (“Copy”,“avail”,true); User u = lib.Find(“User”,“uId”,uId); u.Add(“Copy”,c); c.Set(“avail”,false); return c; } Here you start ti see some of the tool features

11 For DJ class Library { Copy CheckOut
(Library lib,BookName bN, UserId uId){ Book b = cg.Find(lib,“to Book”,“bN”,bN); Copy c = cg.Find (b,“to Copy”,“avail”,true); User u = cg.Find(lib,“to User”,“uId”,uId); cg.Add(u,“to Copy”,c); cg.Set(c,“to Boolean”,”avail”,false); return c; } Here you start ti see some of the tool features

12 Doug’s proposal Book b = cg.fetch( lib, new Strategy (“to Book”),
new Predicate() { boolean match(Object obj){ return((Book) obj).get_isbn() == 678); } ) Instead of: Book b = cg.Find(lib,“to Book”,“isbn”,678);

13 Doug’s proposal More flexible but more verbose Book b = cg.fetch(
lib, new Strategy (“to Book”), new Predicate() { boolean match(Object obj){ return((Book) obj).get_isbn() == 678); } ) Instead of: Book b = cg.Find(lib,“to Book”,“isbn”,678); interface Predicate { boolean match(Object); } Anonymous object of anonymous class

14 For DJ/paper Book b = cg.Find(lib,“to Book”,“bN”,bN);
Copy c = cg.Find (b,“to Copy”,“avail”,true); User u = cg.Find(lib,“to User”,“uId”,uId); cg.Add(u,“to Copy”,c); Copy cg.Delete(u,“to Copy”, “avail”,true); cg.Set(c,“to Boolean”,”avail”,false); Boolean cg.Get(c,“to Boolean”,”avail”); int cg.Traverse(company,”to Salary”,v); Here you start ti see some of the tool features

15 For DJ/paper/constraints
0..*, 1..*: Book b = cg.Find(lib,“to Book”,“bN”,bN); cg.Add(u,“to Copy”,c); cg.Delete(u,“to Copy”, “avail”,true); cg.Traverse(company,”to Salary”,v); cg.Gather(company,”to Salary”); 0..1, 1..1 cg.Set(c,“to Boolean”,”avail”,false); cg.Get(c,“to Boolean”,”avail”); Here you start ti see some of the tool features

16 For DJ/paper/constraints
0..*, 1..*: Book cg.Find(lib,“to Book”,“bN”,bN); Find in library lib a book with data member “bN” = bN. void cg.Add(u,“to Copy”,c); Add to user u a copy c Copy cg.Delete(u,“to Copy”, “avail”,true); Delete from user u a copy with avail == true Here you start ti see some of the tool features

17 For DJ/paper/constraints
0..*, 1..*: int cg.Traverse(company,”to Salary”,v); traverse from company to Salary and perform visiting actions of v. Vector cg.Gather(company,”to Salary”); collect all Salary-objects reachable from company 0..1, 1..1 Boolean cg.Set(c,“to Boolean”,”avail”,false); Boolean cg.Get(c,“to Boolean”,”avail”); Here you start ti see some of the tool features

18 Aspect Language: don’t use
CheckOut { Find(this.bN==bN)-> Book Find(avail==true)->Copy; Find(this.uId==uId)-> User; addCopy { u:User Add(c)-> Copy; } Here you start ti see some of the tool features

19 Compiler asks for information or determines it by rules
CheckOut (lib,bN,uId){ lib:Library( Find(this.bN==bN)-> Book Find(avail==true)-> c:Copy; Find(this.uId==uId)-> u:User;) addCopy { only one choice u:User Add(c)-> Copy; c:Copy Set(avail,false)-> Boolean } Definition: an interaction schema is a sequence of navigation statements of the form o1:T1 -Action1-> o2:T2 -Action2-> o3:T3 ... Here you start ti see some of the tool features

20 Advantages High-level description of behavior in terms of an ideal UML class diagram Behavior can be adapted to many concrete class diagrams Some details of action parameters may be filled in under compiler control

21 Generalized Traversals
Library Find-> Book Traversal from Library to Book must have upper cardinality > 1, e.g., 0..*, 1..*. Compiler will ask for properties to select a book. Rule: if an object of the class of a data member of Book is available, it will choose that one as default

22 Generalized traversals
lib:Library Find-> b:Book DJ: Book b = cg.Find(lib, new Strategy(“from Library to Book”), “property bN”,bookName); “property isbn”,isbnNumber);

23 Connection actions/class graph
lib:Library Find-> b:Book u:User Add(c)-> Copy lib:Library Delete-> b:Book 0..*, 1..*

24 Connection actions/class graph
c:Copy Set(avail,false)-> Boolean c:Copy Get(avail)-> b:Boolean == c:Copy Fetch(avail)-> b:Boolean 1..1, 0..1 --- traverse a little different c:Company Traverse(v1)-> r:Result traverses to all classes mentioned in v1 and performs visiting action. There must be a path to each such class?

25 Generalized traversals
lib:Library Find-> b:Book DJ: Book b = cg.Find(lib, new Strategy(“from Library to Book”), “property author”,authorName); Find is like a generalized fetch

26 Generalized traversals
u:User Add(c)-> Copy; cg.Add(u,new Strategy (“from User to Copy”), c); Expects a unique path from User to Copy that is “insertable” and it adds c at end. Insertable means ...

27 New Operations for DJ Find, Delete, Add Set, Get=Fetch
Traverse, Gather c:Copy Set(avail,false)-> Boolean cg.Set(c, new Strategy( “from Copy through -> *,avail,* to Boolean”), false);

28 DJ: dealing with vectors
How can DJ deal with Java vectors and other collection classes? A = B C. //from A via B to C B = Vector. R = Q. Q = C. S = T. T = .

29 DJ: dealing with vectors
A = B C. //from A via B to C B = Vector. R = Q. Q = C. S = T. T = . Q A C R T S Vector B

30 DJ: dealing with vectors
A = B C. //from A via B to C B = Vector. R = Q. Q = C. S = T. T = . Q A C R T S Vector B

31 Dealing with Vector Enlarge the class graph by drawing a subclass edge from Vector to every node. Might create many edges Use the generality of the strategy compilation algorithm


Download ppt "Good for DJ over Java Extending traversals for collections (b..*)"

Similar presentations


Ads by Google