Download presentation
Presentation is loading. Please wait.
Published byBertina Barnett Modified over 9 years ago
1
1 Aspects and Modularity: The Hope and the Challenge Jonathan Aldrich Institute for Software Research International School of Computer Science Carnegie Mellon University
2
6 September 20152 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]
3
6 September 20153 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
4
6 September 20154 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?
5
6 September 20155 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
6 September 20156 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
7
6 September 20157 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!
8
6 September 20158 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!
9
6 September 20159 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!
10
6 September 201510 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!
11
6 September 201511 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!
12
6 September 201512 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)
13
6 September 201513 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)
14
6 September 201514 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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.