This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
VUB Programming Technology Lab
Aspect-orientedSoftware Development
AnIntroduction
Johan Brichau
Inno.com 2 VUB Programming Technology Lab
Talk Contents
• Separation of Concerns– Broader Context of AOSD
• Aspect-orientation– Definition, History
• Ready-to-use Technologies– An overview
• Research activities• AspectJ demo
2
Inno.com 3 VUB Programming Technology Lab
Talk Contents
• Separation of Concerns• Aspect-orientation• Ready-to-use Technologies• Research activities• AspectJ demo
Inno.com 4 VUB Programming Technology Lab
Separation of Concerns
• E.W. Dijkstra, Parnas• Organize code according to common
functionality– Modular programming– Need for programming language mechanisms
• enforce encapsulation of module internals• provide module composition mechanisms
• Benefits:– Manage complexity– Fewer defects, easier to localize defects– Reusability– Ability to respond to market changes
3
Inno.com 5 VUB Programming Technology Lab
Structured Programming
• Tangling from explicit gotos• Recognized common control structures
– capture in more explicit form
• Resulting code– more clear, easier to write, maintain, debug etc.
i = 1TEST: if i < 4 then goto BODY else goto END
BODY: print(i) i = i + 1 goto TESTEND:
i = 1while (i < 4) { print(i) i = i + 1}
Inno.com 6 VUB Programming Technology Lab
But… still tangled main () { draw_label(“Haida Art Browser”); m = radio_menu( {“Whale”, “Eagle”, “Dogfish”}); q = button_menu({“Quit”}); while ( ! check_buttons(q) ) { n = check_buttons(m); draw_image(n); } }
button_menu(labels) { i = 0; while (i < labels.size) { draw_label(labels[i]); set_y(get_y() + BUTTON_H); i++; } }
4
Inno.com 7 VUB Programming Technology Lab
Group functionality… main () { draw_label(“Haida Art Browser”); m = radio_menu( {“Whale”, “Eagle”, “Dogfish”}); q = button_menu({“Quit”}); while ( ! check_buttons(q) ) { n = check_buttons(m); draw_image(n); } }
Synchronisation code is separatedusing an aspect language withsynchronisation primitives
Inno.com 20 VUB Programming Technology Lab
AO Technologies
• Well known general AO technologies– AspectJ (Aspect-oriented Programming)– HyperJ (Multidimensional SoC)– DemeterJ (Tree traversals)– Composition Filters (Message adapters)
• Many more Academic Prototypes– JAC (Dynamic AOP in Java)– AspectC (AOP in C)– AspectS/Andrew/Soul (AOP in Smalltalk)
• Different crosscutting => different solution
11
Inno.com 21 VUB Programming Technology Lab
AOP Terminology
• Base program– (Object-oriented) program
• Aspect– Modularization of a crosscutting concern
• Weaver– Composes (Compiles) the aspect into the base
program
• Joinpoint– Particular point in the base program where the
aspect can be woven
Inno.com 22 VUB Programming Technology Lab
AOP Example
class Buffer { char[] data; int nrElements; Semaphore sema;
• using an objectcaptures tracingsupport, but doesnot capture itsconsistent usage byother objects
• using an aspectcaptures theconsistent usage ofthe tracing supportby the objects
TraceSupport TraceSupport
18
Inno.com 35 VUB Programming Technology Lab
HyperJ
• No base program– Different views on one program– Compose different views– One concern per view
Expression view methods
Literalview methods
BinaryOP view methods
Display
Expression get/set methods
Literal get/set methods
BinaryOP get/set methods
Kernel
Expression check methods
Literal check methods
BinaryOP check methods
Checker
Inno.com 36 VUB Programming Technology Lab
HyperJ vs AspectJ
• Weaving– Both at compile-time
• Joinpoints– HyperJ: static locations in source
(static joinpoint model)– AspectJ: static and dynamic locations
(dynamic joinpoint model)
• Aspects?– HyperJ: different views on OO program– AspectJ: OO program + aspects
19
Inno.com 37 VUB Programming Technology Lab
DemeterJ: traversals
BusRoute BusStopList
BusStopBusList
Bus PersonList
Person
passengers
buses
busStops
waiting
0..*
0..*
0..*
find all persons waiting at any bus stop on a bus route
OO solution:one methodfor each redclass
Inno.com 38 VUB Programming Technology Lab
DemeterJ: traversals
• Describe traversal– Language primitives to describe complex Visitor
Design Patterns– In terms of graph of classes
• Program robust towards changes in classhierarchy/relationships
• Special case of AspectJ aspects– Maybe even domain-specific aspect-language for
traversals…
20
Inno.com 39 VUB Programming Technology Lab
Composition Filters (Sina)
• Extend Object with Filters (Modular Units)• Filters intercept Messages
• Conditions on messages• Extra behaviour on messages
• Also possible in AspectJ• Different Model
BaseObject
Error Handling Filter
Contract Enforcer Filter
message
Inno.com 40 VUB Programming Technology Lab
Aspect Visualisation
• Aspect Browser– Aspect classifier
• FEAT– Code ‘Surfer’ to classify crosscutting concerns
21
Inno.com 41 VUB Programming Technology Lab
Inno.com 42 VUB Programming Technology Lab
Talk Contents
• Separation of Concerns• Aspect-orientation• Ready-to-use Technologies• Research activities• AspectJ demo
22
Inno.com 43 VUB Programming Technology Lab
Research in AO
• Active Research Community– Over 50 research groups participated in proposal for
European network on AOSD– ±200 participants at first two AOSD Conferences– AOSD workshops at conferences– Many academic prototypes– Many open problems and questions
• Research Topics– Many research in alternative implementations– AO design– Composition and interference of Aspects– Dynamic aspects– …
Inno.com 44 VUB Programming Technology Lab
Belgian Research
• Separation of Business Rules from coreapplication using AspectJ– Augustina Cibran, Maja D’Hondt (VUB)– Models business rules using standard OO
techniques– Coupling of business rules and base program
with aspectJ
23
Inno.com 45 VUB Programming Technology Lab
Belgian Research
• Composable Aspect-specific Languages– Johan Brichau (VUB)– Combine advantages of domain-specific and
general-purpose aspect-languages.– Tackle issues of composition
• Intentional crosscut expressions– Kris Gybels (VUB)– Use a logic programming language (Prolog) to
describe how an aspect crosscuts a baseprogram
Inno.com 46 VUB Programming Technology Lab
Belgian Research
• Runtime Aspect Composition forDistributed Systems– Eddy Truyen (KUL)– Composition of services required from a system.
Each service is an aspect
• Security Aspects– Bart De Win (KUL)– Use aspects to modularize security
• Arriba Research Project– UIA / VUB / RUG– Use aspect technology for code instrumentation
24
Inno.com 47 VUB Programming Technology Lab
Talk Contents
• Separation of Concerns• Aspect-orientation• Ready-to-use Technologies• Research activities• AspectJ demo