1 / 15

AP/DJ

AP/DJ. AP: a generic technology DJ: a low-learning-curve implementation of AP. From Mike Mannion. Regarding DOM navigation, I would be very interested in taking a look at the library you mention (DJ). Can I use XPath expressions to navigate a DOM within Java? That would be very useful indeed!.

wells
Download Presentation

AP/DJ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AP/DJ • AP: a generic technology • DJ: a low-learning-curve implementation of AP

  2. From Mike Mannion • Regarding DOM navigation, I would be very interested in taking a look at the library you mention (DJ). Can I use XPath expressions to navigate a DOM within Java? That would be very useful indeed!

  3. Law of Demeter Principle • Each unit should only have limited knowledge about other units: only about units “closely” related to the current unit. • “Each unit should only talk to its friends.” “Don’t talk to strangers.” • Main Motivation: Control information overload. We can only keep a limited set of items in short-term memory.

  4. Law of Demeter FRIENDS

  5. Application to OO • Unit = method • closely related = • methods of class of this/self and other argument classes • methods of immediate part classes (classes that are return types of methods of class of this/self) • In the following we talk about this application of the Law of Demeter Principle to OO

  6. Rumbaugh and the Law of Demeter Quote: Avoid traversing multiple links or methods. A method should have limited knowledge of an object model. A method must be able to traverse links to obtain its neighbors and must be able to call operations on them, but it should not traverse a second link from the neighbor to a third class.

  7. Law of Demeter(alternative formulation) A method should have limited knowledge of an object model. AP is a reaction to this view of the Law of Demeter

  8. Agreement that LoD Good Idea • How to follow LoD: good solutions exist but not widely known. Two approaches to following LoD: • OO approach • Adaptive approaches • DJ • APPC • Demeter/Java

  9. DJ • An implementation of AP using only the DJ library and the Java Generic Library (JGL) • All programs written in pure Java • Intended as prototyping tool: makes heavy use of introspection in Java • Integrates Generic Programming (a la STL) and Adaptive programming

  10. Integration of Generic and Adaptive Programming • A traversal specification turns an object graph into a container. • Can invoke 50+ generic algorithms on those containers. Examples: add, delete, find, etc. • What is gained: genericity not only with respect to data structure implementations but also with respect to class graph

  11. Sample DJ code // Find the user with the specified uid Container libUsers = new Container(library, "from Library to User"); User user = libUsers.find("uid", uid);

  12. In addition: Traverse method: excellent support for Visitor Pattern // class ClassGraph Object traverse(Object o, Strategy s, Visitor v); traverse navigates through Object o following traversal specification s and executing the before and after methods in visitor v ClassGraph is computed using introspection

  13. Using DJ: BusRoute example public int count (){ // class BusRoute getT().traverse( this, new Visitor(){ int r; public void before(Person host) { r++; } public void start() { r = 0;} …) } }

  14. Using DJ TraversalGraph getT() {return new TraversalGraph( classGraph1, new Strategy( “from BusRoute via BusStop to Person”));}

  15. More info • DJ Home Page: www.ccs.neu.edu/research/demeter/DJ

More Related