190 likes | 332 Views
What is AOP?. Once More Around the Wheel. Gregor Kiczales AspectMentor.com and University of British Columbia. Consider developing… a simple drawing application (JHotDraw). *. Shape. Display. moveBy(int, int). Point. Line. 2. getX() getY() setX(int) setY(int) moveBy(int, int).
E N D
What is AOP? Once More Around the Wheel Gregor Kiczales AspectMentor.com and University of British Columbia
* Shape Display moveBy(int, int) Point Line 2 getX()getY()setX(int)setY(int)moveBy(int, int) getP1()getP2()setP1(Point)setP2(Point)moveBy(int, int) objects are intuitive Intuitively thinking of objects? • Points, Lines… • Drawing surfaces • GUI Widgets • …
collection of procedures to operate on and manage table entries objects are intuitive objects are not intuitive In 1969 most programmers would have used this has poor design and code modularity! +
OOP intuitive not intuitive OOP invented in 1961 • about same time as structured programming • term “object-oriented programming” in 1967 • to make simulation code look like the model
OOP intuitive What is OOP? • a “way of thinking” • objects, classification hierarchies • supporting mechanisms • classes, encapsulation, polymorphism… • allows us to • make code look like the design • improves design and code modularity • many possible implementations • style, library, ad-hoc PL extension, integrated in PL many other benefits build on these
class Pointextends Shape { privateint x = 0, y = 0; int getX() { return x; } int getY() { return y; } void setX(int x) { this.x = x; display.update(this); } void setY(int y) { this.y = y; display.update(this); } } 1 * Shape Display moveBy(int, int) Point Line 2 getX()getY()setX(int)setY(int)moveBy(int, int) getP1()getP2()setP1(Point)setP2(Point)moveBy(int, int) OOP MVC Observer Pattern fair design modularitybut poor code modularity
AOP OOP MVC Observer Pattern Meanwhile back at the ranch… • starting in early 80’s (perhaps earlier) • others began work on • crosscutting structure • mechanisms • behavioral reflection, metaobject protocols,subject-oriented programming… • “aspect-oriented programming” term in 1997
OOP AOP * Shape Display moveBy(int, int) Point Line 2 getX()getY()setX(int)setY(int)moveBy(int, int) getP1()getP2()setP1(Point)setP2(Point)moveBy(int, int) aspect ObserverPattern { private Display Shape.display; pointcut change(): call(void figures.Point.setX(int)) || call(void Point.setY(int)) || call(void Line.setP1(Point)) || call(void Line.setP2(Point)) || call(void Shape.moveBy(int, int)); after(Shape s) returning: change() && target(s) { s.display.refresh(); }} 1 ObserverPattern
OOP AOP * Shape Display moveBy(int, int) Point Line 2 getX()getY()setX(int)setY(int)moveBy(int, int) getP1()getP2()setP1(Point)setP2(Point)moveBy(int, int) aspect ObserverPattern { private Display Shape.display; pointcut change(): call(void Shape.moveBy(int, int)) || call(void Shape+.set*(..)); after(Shape s) returning: change() && target(s) { s.display.refresh(); }} 1 ObserverPattern well-definedcrosscutting structure
OOP AOP * Shape Display moveBy(int, int) Point Line 2 getX()getY()setX(int)setY(int)moveBy(int, int) getP1()getP2()setP1(Point)setP2(Point)moveBy(int, int) Ask yourself:could you name asingle class “ObserverPattern” ? aspect ObserverPattern { private Display Shape.display; pointcut change(): call(void Shape.moveBy(int, int)) || call(void Shape+.set*(..)); after(Shape s) returning: change() && target(s) { s.display.refresh(); }} 1 ObserverPattern well-definedcrosscutting structure
OOP AOP What is AOP? • “a way of thinking” • aspects, crosscutting structure • supporting mechanisms • join points, pointcuts, advice… • allows us to • make code look like the design • improve design and code modularity • many possible implementations • style, library, ad-hoc PL extension, integrated in PL
OOP AOP Other Aspects • design patterns [Google: AOP design pattern] • Swing thread safety [AspectJ in Action] • policy enforcement • authentication, synchronization, architecture • transaction management • debugging support • logging (of course) • and many application-specific aspects
OOP AOP • IBM reports • implementation of platform policies • 15-30% quality improvements • significant productivity gains • improvements in modularity of complex software • new business opportunities
Issues • good vs. bad uses • can overuse/misuse any mechanism • we have learned a lot, we need to learn more • over hype, bad pedagogy • each new wave of adoption brings new zealots / critics • some old lessons need to be rediscovered • tools • quality, support… • training, organization structure… • what’s the business value?
OOP AOP Issue: Proper Style • mechanisms can be misused • too many or wrong procedures • too many or wrong classes • too much or wrong overriding • too many or wrong aspects, advice, introductions • we already know a lot • 15% rule, well-defined crosscutting, tool support • we have a lot to learn • interaction w/ JSR-175; more “semantic pointcuts” • scaling
OOP AOP Issue: Implementation Quality • implementations vary > 10x in performance! • range of existing strategies • VM-based implementation just now starting • limited existing benchmarks • but this is getting better fast
OOP AOP Issue: Over-stated claims, bad pedagogy • each wave of interest / adoption • new proponents and critics • have different priorities • but must re-learn old lessons • new generations of proponents • can be too optimistic • new generations of teachers • can miss critical insights • new generation of critics • can miss previously discussed issues
OOP AOP Question for panel:How can Java Platform remain #1 for AOP? • what are the next steps? • how does “really new” technology get in? • what are the technical issues? • how can AOP get proven enough • what are market issues? • is AOP disruptive technology for J2EE? • where does it produce significant value? • what will Redmond do?