QSOUL/Aop

678 views
611 views

Published on

QSOUL/Aop: Aspect Oriented Software Development using Logic Meta Programming.

Johan Brichau, ESUG 2001, Essen, Germany.

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
678
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

QSOUL/Aop

  1. 1. QSOUL/Aop Aspect Oriented Software Development using Logic Meta Programming Johan Brichau, Programming Technology Lab, Vrije Universiteit Brussel, Brussel, Belgium 7/29/10 ESUG 2001, Essen 1
  2. 2. Overview  Aspect Oriented Software Development  Goals of QSOUL/Aop  Logic Meta Programming in QSOUL  Aspect Oriented Logic Meta Programming  QSOUL/Aop tool  Demo time 7/29/10 ESUG 2001, Essen 2
  3. 3. Software Development  Software development today happens through hiërarchical decomposition in ‘generalised procedures’   Break program complexity   Modularize concerns 7/29/10 ESUG 2001, Essen 3
  4. 4. Aspect Oriented Software Development  But some concerns cannot be modularized and occur in every module of the decomposition   Cross-cutting concern (= aspect)   E.g. synchronization, distribution, … 7/29/10 ESUG 2001, Essen 4
  5. 5. Aspect Oriented Software Development  AOSD tries to modularize these aspects.  Aspects are combined with component program using a weaver  Aspects specified in an aspect-language   Describing •  Cross-cutting •  Functionality   Examples: •  COOL (synchronisation) •  RG (loop fusion optimisation) •  AspectJ (advices over methods) 7/29/10 ESUG 2001, Essen 5
  6. 6. Overview  Aspect Oriented Software Development  Goals of QSOUL/Aop  Logic Meta Programming in QSOUL  Aspect Oriented Logic Meta Programming  QSOUL/Aop tool  Demo time 7/29/10 ESUG 2001, Essen 6
  7. 7. Goals of QSOUL/Aop (1)  Declarative Aspect Language   Aspects have a declarative nature   Examples •  Synchronisation: declare what methods are synchronized •  Error handling: declare what errors should be catched where and what should be executed. •  Wrap methods: declare what methods should be wrapped and what should be executed. 7/29/10 ESUG 2001, Essen 7
  8. 8. Goals of QSOUL/Aop (2)  User-defined aspect-languages   An open framework that allows definition of user-defined aspect-languages   Express one aspect-language in another aspect- language   Examples: •  A ‘wrap methods’ aspect-language could be used to introduce synchronisation or error handling, but is less suited than a specialized ‘synchronisation’ or ‘error handling’ aspect-language. 7/29/10 ESUG 2001, Essen 8
  9. 9. Goals of QSOUL/Aop (3)  Combination and composition of several aspects   Implemented in one aspect-language   Implemented in different aspect-languages   Detect and resolve conflicts between aspects  Example conflict:   If a scheduler-aspect does not know about a synchronisation aspect, deadlocks can occur! 7/29/10 ESUG 2001, Essen 9
  10. 10. Overview  Aspect Oriented Software Development  Goals of QSOUL/Aop  Logic Meta Programming in QSOUL  Aspect Oriented Logic Meta Programming  QSOUL/Aop tool  Demo time 7/29/10 ESUG 2001, Essen 10
  11. 11. Logic Meta Programming  Combines a logic meta language with a standard object-oriented base language   base-level programs are expressed as terms, facts and rules at the meta level   meta-level programs can manipulate and reason about the base-level programs 7/29/10 ESUG 2001, Essen 11
  12. 12. QSOUL: setup QSOUL Smalltalk Meta-level Interface Image Reason about and manipulate source code: Smalltalk check, extract, search, implementation artefacts generate, enforce, transform 7/29/10 ESUG 2001, Essen 12
  13. 13. QSOUL language  Prolog and…   Smalltalk terms allClasses([Smalltalk allClasses])   Smalltalk clauses aCollection object write(?text) if [Transcript show: (?text asString). true].   Quasi Quoted Code true methodCode(Foo,bar, { ^ nil } ) 7/29/10 ESUG 2001, Essen 13
  14. 14. LMP achievements  Emerging technique to build state-of-the art software development tools  In particular, tools to support co-evolution in all facets and phases of the software life-cycle •  information in implementation and earlier life-cycle phases may evolve independently •  need to keep information in these phases synchronised  To support advanced software engineering techniques 7/29/10 ESUG 2001, Essen 14
  15. 15. LMP Achievements Declarative Reasoning about object-oriented base programs supporting the Co-Evolution of design and implementation  Extract design information from the implementation.  Verify the implementation with the corresponding design.  Generate the implementation from the design Theo D'Hondt, Kris De Volder, Kim Mens & Roel Wuyts, Co-evolution of Object- Oriented Software Design and Implementation. In Proceedings of SACT 2000. Kluwer Academic Publishers, 2000 7/29/10 ESUG 2001, Essen 15
  16. 16. Overview  Aspect Oriented Software Development  Goals of QSOUL/Aop  Logic Meta Programming in QSOUL  Aspect Oriented Logic Meta Programming  QSOUL/Aop tool  Demo time 7/29/10 ESUG 2001, Essen 16
  17. 17. Aspect Oriented Logic Meta Programming (AOLMP)  Aspect language embedded in logic language.  An aspect language consists of two parts   the aspect-code   how the aspect crosscuts the base program  Inference engine gathers the logic declarations of all aspects and weaves them in the base program.  Using logic rules we can build a domain-specific aspectlanguage embedded in the logic language.  E.g. TyRuBa and QSOUL/Aop 7/29/10 ESUG 2001, Essen 17
  18. 18. AOLMP using QSOUL/Aop  Composition-mechanism to support composition of aspects  Integrated Smalltalk-weaver  Exploit symbiosis   Use reasoning about base program to specify user- defined crosscuts. (E.g.: all places in the program where a certain variable is initialized)   Multi-paradigm programming (logic & procedural programming) eases complexity of rules that implement a user-defined aspect-language 7/29/10 ESUG 2001, Essen 18
  19. 19. Overview  Aspect Oriented Software Development  Goals of QSOUL/Aop  Logic Meta Programming in QSOUL  Aspect Oriented Logic Meta Programming  QSOUL/Aop tool  Demo time 7/29/10 ESUG 2001, Essen 19
  20. 20. QSOUL/Aop  Consider a simple aspect-language for error-handling:   onError(?class,?selector,?error,?error-handling-block)  Consider two simple error-handling aspects:   onError([Array],[#at:put:],[OutOfBoundsError], {[:e | … handle exception e…]})   onError(?class,[#at:put:],[OutOfBoundsError],{…}) if subclass([SequenceableCollection],?class) 7/29/10 ESUG 2001, Essen 20
  21. 21. QSOUL/Aop  Consider a wrap-around aspect-language:   around(?class,?selector,?code)  Define the meaning of the error-handling aspect- language in terms of the wrap-around aspect- language   around(?class,?selector, {[original()] on: ?error do: ?errorcodeBlock}) if onError(?class,?selector,?error,?errorcodeBlock).  Define the wrap-around aspect-language in terms of another aspect-language… 7/29/10 ESUG 2001, Essen 21
  22. 22. QSOUL/Aop  Basic weaver   Hard-coded in Smalltalk   Invisible overriding of methods •  Only supports method-crosscuts   Share state in group of overriden methods QSOUL Smalltalk Basic weaver 7/29/10 ESUG 2001, Essen 22
  23. 23. Basic weaver  Basic aspect language: crosscut declarations   weave(method(?class,?selector),{<aspect-code>}) Override the method ?selector in ?class with N>0 <aspect-code>   scopeOf(?instVarList,{ <aspect-scope-code> }) Share instance variables in all executions of aspect-code where <aspect-scope-code> results in same value. Create new instance variables where N=0,1 <aspect-scope-code> results in a new, unique value. 7/29/10 ESUG 2001, Essen 23
  24. 24. Basic weaver  Basic aspect language: aspect-code weave(method(? class,?selector),{<aspect-code>})   Smalltalk code and…   thisObject Access to the current receiver in aspect-code   original() Execute the original method (with the original arguments)   thisAspect not yet… 7/29/10 ESUG 2001, Essen 24
  25. 25. A basic-weaver aspect: Logging Write the size of the collection to the Transcript every time after an element is added to an Array or an OrderedCollection weave(?pc, { |tempResult| tempResult := original(). Transcript write: thisObject size asString. ^ tempResult } ) if location(?pc). location(method([Array],at:put:) ). location(method([OrderedCollection],add:)) QSOUL Smalltalk 7/29/10 Basic2001, Essen ESUG weaver 25
  26. 26. Building your own aspect language  An AspectWeaverMixin…   …defines a new aspect-language in terms of another aspect-language.   …defines a transformation of a higher-level aspect language to a lower-level aspect- language   …can be mixed with other aspectweavermixins and the basic weaver to form a complete aspectweaver 7/29/10 ESUG 2001, Essen 26
  27. 27. Building your own aspect language after(execution(?class,?selector),{Transcript write: thisObject size asString}) if location(?class,?selector). location([Array],at:put:). location([OrderedCollection],add:) weave(method(?class,?sel), { |tempResult| tempResult := original(). ?code. ^ tempResult } ) if after(execution(?class,?sel),?code). QSOUL Smalltalk 7/29/10 Basic2001, Essen ESUG weaver 27
  28. 28. Building your own aspect language location([Array],at:put:). location([OrderedCollection],add:) Size Logging AspectWeaverMixin location Advice AspectWeaverMixin before/after/around QSOUL weave Smalltalk 7/29/10 Basic weaver ESUG 2001, Essen 28
  29. 29. Combination of aspect-languages Logging aspect Synchronization aspect Logging and Synchronizing AspectWeaverMixin QSOUL Smalltalk 7/29/10 Basic2001, Essen ESUG weaver 29
  30. 30. Combination of aspect-languages Logging Synchronization aspect aspect Logging Synchronization Weavermixin Weavermixin Advice Combination Weavermixin Advice Weavermixin QSOUL Smalltalk Basic weaver 7/29/10 ESUG 2001, Essen 30
  31. 31. QSOUL/Aop: Open crosscut language  QSOUL’s reasoning about Smalltalk basecode allows detection of patterns.   Extract implicit call-structure   Extract design patterns   Etc…  This information can be used to implement user- defined crosscuts   Method that initializes instance variables   Methods that send messages to a Stack instance   Etc… 7/29/10 ESUG 2001, Essen 31
  32. 32. Integration in Smalltalk QSOUL/Aop AspectWeaverMixins (an AspectWeaverMixin is a logic program) Smalltalk metasystem metaclass QSOUL/Aop basic-weaver Smalltalk system Invisible class generated aspect-class 7/29/10 Invisible woven-calls ESUG 2001, Essen 32
  33. 33. QSOUL/Aop: Future Work  thisAspect  Scope per aspect-instance variable  Aspect methods  Extend basic weaver to weave on other language elements  Technical improvements   Use method wrappers instead of hidden classes   Check for uses of self in aspect-code   … 7/29/10 ESUG 2001, Essen 33
  34. 34. Demonstration: The Conduits Framework 7/29/10 ESUG 2001, Essen 34
  35. 35. Aspects in Conduits-Framework  User Interface update   After each fill, update view  Synchronization and message order   fill and drain: in alternate order + blocking  Overflow logging   Setting of content everywhere should produce same message (throws error?)  Etc… 7/29/10 ESUG 2001, Essen 35
  36. 36. Links Declarative (Logic) Meta Programming: http://prog.vub.ac.be/poolresearch/dmp/ QSOUL2: http://prog.vub.ac.be/poolresearch/qsoul/qsoul2.html QSOUL/Aop: http://prog.vub.ac.be/poolresearch/aop/qsoulaop.html johan.brichau@vub.ac.be 7/29/10 ESUG 2001, Essen 36
  37. 37. QSOUL LMP-tool  Strong symbiosis between logic language and Smalltalk   Logic language acts on current Smalltalk image   Smalltalk objects are constants in the logic language   Logic clauses can execute parameterised Smalltalk expressions  Code generation through manipulation of quasi-quoted codestrings 7/29/10 ESUG 2001, Essen 37
  38. 38. Aspect Oriented Software Development  Subject Oriented Programming and Multidimensional Separation of Concerns   Different views on the program’s decomposition, each addressing a concern   Compose the different views with composition rules  Composition Filters   Place wrappers around encapsulations, each addressing a cross-cutting concern 7/29/10 ESUG 2001, Essen 38
  39. 39. Aspect Oriented Software Development  Design Patterns   Use exisiting ‘generalised procedure’ techniques to separate cross-cutting concern (e.g. Visitor pattern)  Aspect Oriented Programming   Encapsulate aspects   Aspect-weaver composes aspects with other encapsulations guided by a pointcut-language 7/29/10 ESUG 2001, Essen 39
  40. 40. AOLMP using TyRuBa Basic Functionality Code Parser Facts representing basic functionality code Weaver Code + with Logic Program aspects Logic program representing aspect declarations 7/29/10 ESUG 2001, Essen 40

×