SlideShare a Scribd company logo
1 of 36
Machine-level Composition of Modularized Crosscutting Concerns ,[object Object],[object Object],[object Object]
Special Thanks To... ,[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Modularization ,[object Object],[object Object],[object Object],=> Which Modules? => How to Decompose the System?
Employee Management System Task 1 Find Out Employee-Boss Relationships Sales Research Financial Support
Employee Management System Task 2 Calculate Salaries ? Sales Research Financial Support
Employee Management System Task 2 Calculate Salaries Research Monthly Hourly Bonus
Employee Management System Task 1 Find Out Employee-Boss Relationships ? Research Monthly Hourly Bonus
Dominant Decomposition: Organizational Hard to calculate salary... Easy to find out supervisor  relationships... Employee Research ResearchManager Sales SalesManager Financial FinancialManager Support SupportManager
Dominant Decomposition: Payroll Easy to  calculate salary... Hard to find out supervisor relationships... Employee HourlyWage MonthlyWage Research Regular Sales SalesManager RegularManager Secretary Labourer ResearchManager
Crosscutting Concerns source: http://www.ercim.org/publication/Ercim_News/enw58/van_deursen1.jpg  Column: Module Each Color: Task
Modularizing Crosscutting Concerns MDSOC  approaches  deal with the  modularization of  crosscutting concerns . tangling / scattering extra module (e.g., aspect, layer, ...) modularized code  (e.g., advice, ...) join points Now somehow  make all modules work together...
State-of-the-Art: Weaving... ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
I've Got Troubles, Oh-Oh Ik Heb Zorgen ,[object Object],[object Object],[object Object],[object Object],[object Object],We Need a Dedicated (Virtual) Machine
Core Mechanisms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Dedicated Machine Model ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],self object actual-object foo = ( ... ) bar = 23 delegate instance-of-C actual-instance-of-C v = 23 C actual-C m = ( ... ) m
Basic Modularization Operations // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... } void h() { ... } } class A { before(): execution(void C.f()) { ... } after(): execution(void C.g()) { ... } void  around(): execution(void C.h()) { ... proceed(); ... } } ... deploy(new A()); ... actual-C f = ( ... ) g = ( ... ) h = ( ... ) C instance-of-C actual-instance-of-C A-proxy f = ( ...;  resend  ) g = (  resend;  ... ) h = ( ...;  resend;  ... ) f
Instance-Local Deployment // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... } void h() { ... } } class A { before(): execution(void C.f()) { ... } after(): execution(void C.g()) { ... } void  around(): execution(void C.h()) { ... proceed(); ... } } ... deploy(new A(), instance-of-C); ... actual-C f = ( ... ) g = ( ... ) h = ( ... ) C instance-of-C actual-instance-of-C A-proxy f = ( ...;  resend  ) g = (  resend;  ... ) h = ( ...;  resend;  ... )
Thread-Local Deployment // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... } void h() { ... } } class A { before(): execution(void C.f()) { ... } after(): execution(void C.g()) { ... } void  around(): execution(void C.h()) { ... proceed(); ... } } // in thread T1 ... deploy(new A()) { ... } ... actual-C f = ( ... ) g = ( ... ) h = ( ... ) C instance-of-C actual-instance-of-C A-proxy f = ( ...;  resend  ) g = (  resend;  ... ) h = ( ...;  resend;  ... ) the delegate of  C  is a function  of the thread T1 others
cflow: Continuous Weaving // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... f(); ... } } class A { before(): execution(void C.f()) && cflow(execution(void C.g())) { ... } } ... deploy(new A()); ... actual-C f = ( ... ) g = ( ... f(); ... ) C instance-of-C actual-instance-of-C // in thread T1 ... instance-of-C.g(); ... T1 others A-cw-proxy g = (  act-cflow;  resend;  deact-cflow  ) A-proxy f = ( ...; resend ) f g
Introduction // CaesarJ-like pseudo code class C { int x; void f() { ... } } class A { int C.y; void C.g() { ... } before(): execution(void C.f()) { ... } } ... deploy(new A()); ... actual-C f = ( ... ) C instance1-of-C actual-instance1-of-C x = 23 ... instance1-of-C.y ... instance2-of-C actual-instance2-of-C x = 42 A-int-proxy y = ( /* add y field to instance */; self y ) g = ( /* imp. of introduced method */ ) y A-int1-proxy y = 0
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
j  – Object-Oriented Programming  [Skipper04] class Subject  ext Object   { Integer attr Observer obs void doSomething(Object x) { this.attr := 25 } void changed(Object x) { this.obs.update(this) } void setObserver(Observer x) { this.obs := x } } class Observer ext Object { void update(Subject x) { out.println(x.attr) } } class Main ext Object { Subject s Observer o void main(Main x) { x.s := new Subject; x.o := new Observer; x.s.setObserver(x.o); x.s.doSomething(null); x.s.changed(null) } }
j  Prepared Heap Subject_prototype attr obs Subject_proxy Subject doSomething  = (...) changed = (...) setObserver = (...) Main_prototype s o Main_proxy Main main  = (...) Observer_prototype Observer_proxy Observer update  = (...) Object proxy Object
j  Class Instantiation doSomething Subject_prototype attr obs Subject_proxy Subject doSomething  = (...) changed = (...) setObserver = (...) Main_prototype s o Main_proxy Main main  = (...) Observer_prototype Observer_proxy Observer update  = (...) Object proxy Object subject_inst attr obs subj_inst_proxy
ij  – Inter-Type Declarations  [Skipper04] class Observer ext Object { void update(Subject x) { out.println(x.attr) } Subject <--  Observer obs Subject <-- void changed(Object x) { this.obs.update(this) } Subject <--  void setObserver(Observer x) { this.obs := x } } class Subject  ext Object   { Integer attr void doSomething(Object x) { this.attr := 25 } } class Main ext Object { Subject s Observer o void main(Main x) { x.s := new Subject; x.o := new Observer; x.s.setObserver(x.o); x.s.doSomething(null); x.s.changed(null) } }
ij  Prepared Heap Subject_proto attr Subject_proxy Subject doSomething  = (...) Main_proto s o Main_proxy Main main  = (...) Observer_proto Observer_proxy Observer update  = (...) Object proxy Object intr_proxy 1 changed = (...) setObserver = (...) obs=(... self obs)
ij  Class Instantiation obs Subject_proto attr Subject_proxy Subject doSomething  = (...) Main_proto s o Main_proxy Main main  = (...) Observer_proto Observer_proxy Observer update  = (...) Object proxy Object intr_proxy 1 changed = (...) setObserver = (...) obs=(... self obs) subject_inst attr subj_inst_proxy intr_proxy2 obs
aj  – Pointcut and Advice AOP  [Skipper04] class Subject ext Object { Integer attr void changed(Object x) { out.println(this.attr) } } aspect Observer  { bool changed before set (Integer Subject.attr) { this.changed := v.neq(r.attr) } after set (Integer Subject.attr) { if (this.changed){ r.changed(null) } else { null } } } class Main ext Object { Subject s void main(Main x) { x.s := new Subject; x.s.attr := 25; } }
aj  Prepared Heap setAttr attr Subject_proto attr Subject_proxy Subject setAttr = (... self attr ...) changed = (...) Main_proto s Main_proxy Main main  = (...) Observer_Asp changed Object Object_proxy obs_proxy_1 setAttr = (... resend) obs_proxy_2 setAttr = (resend; ...) subject_inst attr obs subj_inst_proxy
cj  – Context-Oriented Programming class Subject  ext Object   { Integer attr void Subject.setAttr(Integer x){ this.attr := x } void Subject.changed(Object x){ out.println(this.attr)} } layer Observer  { bool changed void Subject.setAttr(Integer x)  { thislayer.changed := x.neq(this.attr); proceed(x); if(thislayer.changed) { this.changed(null) } else { null }} } class Main ext Object { Subject s void main(Main x) { x.s := new Subject; x.s.setAttr(12); withlayer(Observer)  { x.s.setAttr(25) } } }
cj  Prepared Heap attr setAttr Subject_proto attr Subject_proxy Subject setAttr = (... self attr ...) changed = (...) Main_proto s Main_proxy Main main  = (...) Observer_Lyr changed Object Object_proxy subject_inst attr obs subj_inst_proxy obs_proxy_1 setAttr = (... resend; ...)
Prototypical Implementation ,[object Object]
Experimental Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Onward! (Listen up, OOPSLA!) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Thank You - Questions?

More Related Content

What's hot

Tutconstructordes
TutconstructordesTutconstructordes
TutconstructordesNiti Arora
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)Make Mannan
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manualSANTOSH RATH
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Platonov Sergey
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Sumant Tambe
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manualnikshaikh786
 
An introduction to thrust CUDA
An introduction to thrust CUDAAn introduction to thrust CUDA
An introduction to thrust CUDAAdrien Wattez
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manualSyed Mustafa
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rathSANTOSH RATH
 

What's hot (20)

Tutconstructordes
TutconstructordesTutconstructordes
Tutconstructordes
 
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)Lab manual data structure (cs305 rgpv) (usefulsearch.org)  (useful search)
Lab manual data structure (cs305 rgpv) (usefulsearch.org) (useful search)
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
Constructor
ConstructorConstructor
Constructor
 
C++11
C++11C++11
C++11
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
Ds lab handouts
Ds lab handoutsDs lab handouts
Ds lab handouts
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)Fun with Lambdas: C++14 Style (part 2)
Fun with Lambdas: C++14 Style (part 2)
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
 
Berlin meetup
Berlin meetupBerlin meetup
Berlin meetup
 
An introduction to thrust CUDA
An introduction to thrust CUDAAn introduction to thrust CUDA
An introduction to thrust CUDA
 
Data structures lab manual
Data structures lab manualData structures lab manual
Data structures lab manual
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rath
 

Similar to Machine-level Composition of Modularized Crosscutting Concerns

Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoMuhammad Abdullah
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitVaclav Pech
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaWiem Zine Elabidine
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)PROIDEA
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional ProgrammingEelco Visser
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design PatternsStefano Fago
 
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CSteffen Wenz
 
constant member functions and this pointer - Copy.ppt
constant member functions and this pointer - Copy.pptconstant member functions and this pointer - Copy.ppt
constant member functions and this pointer - Copy.pptSyedHaroonShah4
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerDavid Muñoz Díaz
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2Leonid Maslov
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.pptssuserd64918
 
Halide tutorial 2019
Halide tutorial 2019Halide tutorial 2019
Halide tutorial 2019Champ Yen
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2ppd1961
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersBartosz Kosarzycki
 

Similar to Machine-level Composition of Modularized Crosscutting Concerns (20)

functions
functionsfunctions
functions
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demo
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruit
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
 
ZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in ScalaZIO: Powerful and Principled Functional Programming in Scala
ZIO: Powerful and Principled Functional Programming in Scala
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
 
constant member functions and this pointer - Copy.ppt
constant member functions and this pointer - Copy.pptconstant member functions and this pointer - Copy.ppt
constant member functions and this pointer - Copy.ppt
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 
T3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmerT3chFest 2016 - The polyglot programmer
T3chFest 2016 - The polyglot programmer
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 
Python Software Testing in Kytos.io
Python Software Testing in Kytos.ioPython Software Testing in Kytos.io
Python Software Testing in Kytos.io
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.ppt
 
Halide tutorial 2019
Halide tutorial 2019Halide tutorial 2019
Halide tutorial 2019
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2Handling Exceptions In C &amp; C++ [Part B] Ver 2
Handling Exceptions In C &amp; C++ [Part B] Ver 2
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
 

Machine-level Composition of Modularized Crosscutting Concerns

  • 1.
  • 2.
  • 3.
  • 4.
  • 5. Employee Management System Task 1 Find Out Employee-Boss Relationships Sales Research Financial Support
  • 6. Employee Management System Task 2 Calculate Salaries ? Sales Research Financial Support
  • 7. Employee Management System Task 2 Calculate Salaries Research Monthly Hourly Bonus
  • 8. Employee Management System Task 1 Find Out Employee-Boss Relationships ? Research Monthly Hourly Bonus
  • 9. Dominant Decomposition: Organizational Hard to calculate salary... Easy to find out supervisor relationships... Employee Research ResearchManager Sales SalesManager Financial FinancialManager Support SupportManager
  • 10. Dominant Decomposition: Payroll Easy to calculate salary... Hard to find out supervisor relationships... Employee HourlyWage MonthlyWage Research Regular Sales SalesManager RegularManager Secretary Labourer ResearchManager
  • 11. Crosscutting Concerns source: http://www.ercim.org/publication/Ercim_News/enw58/van_deursen1.jpg Column: Module Each Color: Task
  • 12. Modularizing Crosscutting Concerns MDSOC approaches deal with the modularization of crosscutting concerns . tangling / scattering extra module (e.g., aspect, layer, ...) modularized code (e.g., advice, ...) join points Now somehow make all modules work together...
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Basic Modularization Operations // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... } void h() { ... } } class A { before(): execution(void C.f()) { ... } after(): execution(void C.g()) { ... } void around(): execution(void C.h()) { ... proceed(); ... } } ... deploy(new A()); ... actual-C f = ( ... ) g = ( ... ) h = ( ... ) C instance-of-C actual-instance-of-C A-proxy f = ( ...; resend ) g = ( resend; ... ) h = ( ...; resend; ... ) f
  • 18. Instance-Local Deployment // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... } void h() { ... } } class A { before(): execution(void C.f()) { ... } after(): execution(void C.g()) { ... } void around(): execution(void C.h()) { ... proceed(); ... } } ... deploy(new A(), instance-of-C); ... actual-C f = ( ... ) g = ( ... ) h = ( ... ) C instance-of-C actual-instance-of-C A-proxy f = ( ...; resend ) g = ( resend; ... ) h = ( ...; resend; ... )
  • 19. Thread-Local Deployment // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... } void h() { ... } } class A { before(): execution(void C.f()) { ... } after(): execution(void C.g()) { ... } void around(): execution(void C.h()) { ... proceed(); ... } } // in thread T1 ... deploy(new A()) { ... } ... actual-C f = ( ... ) g = ( ... ) h = ( ... ) C instance-of-C actual-instance-of-C A-proxy f = ( ...; resend ) g = ( resend; ... ) h = ( ...; resend; ... ) the delegate of C is a function of the thread T1 others
  • 20. cflow: Continuous Weaving // CaesarJ-like pseudo code class C { void f() { ... } void g() { ... f(); ... } } class A { before(): execution(void C.f()) && cflow(execution(void C.g())) { ... } } ... deploy(new A()); ... actual-C f = ( ... ) g = ( ... f(); ... ) C instance-of-C actual-instance-of-C // in thread T1 ... instance-of-C.g(); ... T1 others A-cw-proxy g = ( act-cflow; resend; deact-cflow ) A-proxy f = ( ...; resend ) f g
  • 21. Introduction // CaesarJ-like pseudo code class C { int x; void f() { ... } } class A { int C.y; void C.g() { ... } before(): execution(void C.f()) { ... } } ... deploy(new A()); ... actual-C f = ( ... ) C instance1-of-C actual-instance1-of-C x = 23 ... instance1-of-C.y ... instance2-of-C actual-instance2-of-C x = 42 A-int-proxy y = ( /* add y field to instance */; self y ) g = ( /* imp. of introduced method */ ) y A-int1-proxy y = 0
  • 22.
  • 23. j – Object-Oriented Programming [Skipper04] class Subject ext Object { Integer attr Observer obs void doSomething(Object x) { this.attr := 25 } void changed(Object x) { this.obs.update(this) } void setObserver(Observer x) { this.obs := x } } class Observer ext Object { void update(Subject x) { out.println(x.attr) } } class Main ext Object { Subject s Observer o void main(Main x) { x.s := new Subject; x.o := new Observer; x.s.setObserver(x.o); x.s.doSomething(null); x.s.changed(null) } }
  • 24. j Prepared Heap Subject_prototype attr obs Subject_proxy Subject doSomething = (...) changed = (...) setObserver = (...) Main_prototype s o Main_proxy Main main = (...) Observer_prototype Observer_proxy Observer update = (...) Object proxy Object
  • 25. j Class Instantiation doSomething Subject_prototype attr obs Subject_proxy Subject doSomething = (...) changed = (...) setObserver = (...) Main_prototype s o Main_proxy Main main = (...) Observer_prototype Observer_proxy Observer update = (...) Object proxy Object subject_inst attr obs subj_inst_proxy
  • 26. ij – Inter-Type Declarations [Skipper04] class Observer ext Object { void update(Subject x) { out.println(x.attr) } Subject <-- Observer obs Subject <-- void changed(Object x) { this.obs.update(this) } Subject <-- void setObserver(Observer x) { this.obs := x } } class Subject ext Object { Integer attr void doSomething(Object x) { this.attr := 25 } } class Main ext Object { Subject s Observer o void main(Main x) { x.s := new Subject; x.o := new Observer; x.s.setObserver(x.o); x.s.doSomething(null); x.s.changed(null) } }
  • 27. ij Prepared Heap Subject_proto attr Subject_proxy Subject doSomething = (...) Main_proto s o Main_proxy Main main = (...) Observer_proto Observer_proxy Observer update = (...) Object proxy Object intr_proxy 1 changed = (...) setObserver = (...) obs=(... self obs)
  • 28. ij Class Instantiation obs Subject_proto attr Subject_proxy Subject doSomething = (...) Main_proto s o Main_proxy Main main = (...) Observer_proto Observer_proxy Observer update = (...) Object proxy Object intr_proxy 1 changed = (...) setObserver = (...) obs=(... self obs) subject_inst attr subj_inst_proxy intr_proxy2 obs
  • 29. aj – Pointcut and Advice AOP [Skipper04] class Subject ext Object { Integer attr void changed(Object x) { out.println(this.attr) } } aspect Observer { bool changed before set (Integer Subject.attr) { this.changed := v.neq(r.attr) } after set (Integer Subject.attr) { if (this.changed){ r.changed(null) } else { null } } } class Main ext Object { Subject s void main(Main x) { x.s := new Subject; x.s.attr := 25; } }
  • 30. aj Prepared Heap setAttr attr Subject_proto attr Subject_proxy Subject setAttr = (... self attr ...) changed = (...) Main_proto s Main_proxy Main main = (...) Observer_Asp changed Object Object_proxy obs_proxy_1 setAttr = (... resend) obs_proxy_2 setAttr = (resend; ...) subject_inst attr obs subj_inst_proxy
  • 31. cj – Context-Oriented Programming class Subject ext Object { Integer attr void Subject.setAttr(Integer x){ this.attr := x } void Subject.changed(Object x){ out.println(this.attr)} } layer Observer { bool changed void Subject.setAttr(Integer x) { thislayer.changed := x.neq(this.attr); proceed(x); if(thislayer.changed) { this.changed(null) } else { null }} } class Main ext Object { Subject s void main(Main x) { x.s := new Subject; x.s.setAttr(12); withlayer(Observer) { x.s.setAttr(25) } } }
  • 32. cj Prepared Heap attr setAttr Subject_proto attr Subject_proxy Subject setAttr = (... self attr ...) changed = (...) Main_proto s Main_proxy Main main = (...) Observer_Lyr changed Object Object_proxy subject_inst attr obs subj_inst_proxy obs_proxy_1 setAttr = (... resend; ...)
  • 33.
  • 34.
  • 35.
  • 36.