1 Aspects and Modularity: The Hope and the Challenge Jonathan Aldrich Institute for Software Research International School of Computer Science Carnegie Mellon University
6 September Why Modularity? Protect client code from changes to design decisions encapsulated within a module [Parnas, others] Protect invariants of module code from ill- behaved clients [Milner, others]
6 September Aspects: A New Hope Key benefit: capture concerns more locally and consistently Better protects clients from change by localizing crosscutting concerns Can be used to consistently enforce invariants of a module
6 September Aspects: A Double-Edged Light-Saber? This works when you use AOP to modularize a concern What happens when the client of a module uses AOP?
6 September Aspects: The Phantom Menace Aspect-oriented clients can become dependent on details of a module’s implementation Aspect-oriented clients can break a module’s invariants
6 September Non-Solution: Read-Only Aspects AOP clients may still depend on information that might change Even non-mutator AOP clients can break invariants Untrusted code can view sensitive data Aspects can create new objects with broken invariants Many concerns require mutator aspects
6 September Non-Solution: Semantic Pointcuts Control flow, data flow pointcuts are more robust Still can be broken if control/data flow does not exactly match problem Only one kind of semantic pointcut is a solution: Do what I mean! We say this already with interfaces!
6 September Non-Solution: Semantic Pointcuts Control flow, data flow pointcuts are more robust Still can be broken if control/data flow does not exactly match problem Only one kind of semantic pointcut is a solution: Do what I mean! We say this already with interfaces!
6 September Non-Solution: Semantic Pointcuts Control flow, data flow pointcuts are more robust Still can be broken if control/data flow does not exactly match problem Only one kind of semantic pointcut is a solution: Do what I mean! We say this already with interfaces!
6 September Solution: Interfaces Use Interfaces to Mediate Interaction Aspects may advise entry/exit join points of a module Aspects may advise pointcuts explicitly exported by a module “do what I mean” by this pointcut Other advice is prohibited Module changes which preserve interface pointcuts also preserve client behavior Can be formalized and proved for simple pointcuts Aldrich, FOAL ‘04, ECOOP ’05 Work needed to extend to practical system Interfaces also enforce internal invariants This story is old…but controversial in AOP!
6 September Solution: Interfaces Use Interfaces to Mediate Interaction Aspects may advise entry/exit join points of a module Aspects may advise pointcuts explicitly exported by a module “do what I mean” by this pointcut Other advice is prohibited Module changes which preserve interface pointcuts also preserve client behavior Can be formalized and proved for simple pointcuts Aldrich, FOAL ‘04, ECOOP ’05 Work needed to extend to practical system Interfaces also enforce internal invariants This story is old…but controversial in AOP!
6 September Obliviousness is Bunk! Well-known AOP “requirement” Code does not have to be specifically prepared to receive AOP enhancements Bunk because aspects depend on details of code As soon as you advise it, code is no longer oblivious! Can’t change code or rely on invariants obliviously (without knowing about aspects)
6 September Obliviousness is Bunk! A proxy for what you really want: agility Ease of change of crosscutting concerns Modify a pointcut declaratively and locally within a module After-the-fact enhancement Tools could give it to you transparently View or modify a pointcut in an interface Even if it’s a reflection of a more global pointcut Add or modify a pointcut that cuts across interfaces This may require negotiation with another stakeholder (other developers, the user, the application architect)
6 September Obliviousness is Bunk! A proxy for what you really want: agility Ease of change of crosscutting concerns Modify a pointcut declaratively and locally within a module After-the-fact enhancement Maybe tools could give this to you transparently View or modify a pointcut in an interface Even if it’s a reflection of a more global pointcut Add or modify a pointcut that cuts across interfaces This may require negotiation with another stakeholder (other developers, the user, the application architect) Insufficient to calculate one from the other Both must be editable if you want both modularity and agility Changes to pointcuts in interfaces of module require negotiation