On Fri, 6 Aug 2004 09:11:26 +0900, Bill Atkins <dejaspam / batkins.com> wrote: > Can anyone give me a quick explanation of aspect-oriented programming > and AspectR in particular? I keep hearing that it's very useful, but > I haven't been able to find a good description of it anywhere. > > Bill Atkins http://c2.com/cgi/wiki?AspectOrientedProgramming Quick description Advanced preprocessing, where you can say things like, "Take every method that starts with the word 'test', and add it to a list of methods to be run when testing." Allows one to centralize "cross-cutting" concerns that would otherwise appear in many different classes. Longer description AOP is motivated by "SeparationOfConcerns". It is one step further than OOP in abstraction and modularization. If we look back, using POP (Procedure-Oriented Programming), we must deal with all the concerns in a line. Though we can outsource the code into different functions, the main stream still controls all the process. This is the linear model. When OOP is introduced, we can present the world in a more natural way by describing different objects and their functions. Connections between different objects form a network, a matrix of type vs. behavior. This can be called the two dimensional model. Then AOP comes along and tells us that the change from POP to OOP is not complete and the world need more dimensions. This cross-cutting, distributed code can be seen as interconnections over and beyond the two dimensional networking that OOP produced. Rules can be well tangled with the objects they govern. If the system is small, it will not be a problem. But if the system is big enough, these crosscutting concerns can significantly bloat the objects, and AOP should be applied. Aspect oriented programming allows one to pick out a set of "join points" within the program, and then specify code ("advice") that should run at each of these points. The set of join points is specified in the same place as the advice, keeping aspects modular. This is in contrast to multiple-inheritance object systems like CLOS or C++, where the invocation of behavior is specified by the caller, not the callee. This allows one to achieve OnceAndOnlyOnce in a new way. When a UserStory is going to affect a lot of classes, describe once in an Aspect and it can affect a dozen or more different places in code. The tools distribute it to the right places. This allows one to create new views into the software system which modularize the story. See also: AspectOrientedExamples AspectOrientedTools AspectsAndDynamicLanguages AspectsAndMetaObjects UnitTestingAspectOrientedCode External site links: http://www.internetnews.com/dev-news/article.php/3351321 http://aosd.net. Comprehensive source of information. http://www.parc.xerox.com/csl/projects/aop/. Contains a few other links. http://www.ccs.neu.edu/home/lieber/demeter.html. A different take. http://java-source.net/open-source/aspect-oriented-frameworks Contributors: Daisy Wang, StanleyKnutson, AnonymousDonor, DickBotting, DaveHarris Related work SubjectOrientedProgramming AttributeOrientedProgramming?, which may accomplish most of what AOP can do with runtime generated proxies or good old code generation. The RecursiveDesign concept of the ShlaerMellorMethod. They name their aspects "domains"; and the weaving process is called "translation"; but the philosophy is the same. The GenVoca tool. Multi-Dimensional Separation of Concerns: Software Engineering using Hyperspaces by IBM. See http://www.research.ibm.com/hyperspace/. In a sense, AspectOrientedProgramming is the opposite of FunctionalProgramming. The core mindset of FunctionalProgramming is computation without relying on SideEffects; in a sense, the core mindset of aspects is adding SideEffects. Aspects are like the DecoratorPattern applied to functions. Contributors: multiple AnonymousDonors, IanRae, ChanningWalton, LO AspectOrientedProgramming QuickQuestions Q I develop in VbClassic and other related technologies of Pre DotNet days. If I am not doing WebServices do I need to care about AOP? A ?? QHow does AOP interact with (regular) refactoring? Most refactorings involve moving code across method boundaries, but when aspect code is potentially triggered on any method invocation, then such refactorings are no longer behaviour-preserving. AnswerMe, please. --AndersMunch A ?? Q What are some AspectOrientedPatterns?? -- AnonymousDonor A ?? The power of AspectOrientedProgramming Recently, I saw a little example of changing behavior at the meta level [http://www.parc.xerox.com/spl/groups/eca/pubs/papers/Kiczales-Andreas-MOP/]. Until then, I'd thought that meta level work was not terribly behavioral... the stuff of database people and modeling language designers. The power of being able to say that method invocations will work differently for a class of classes, or even the way that member variables are associated with an object seems phenomenal. If this sort of behavior change at the meta level thing is all that it seems to be, it could usher in much more clarity in code. -- MichaelFeathers One (simplified but useful) way of thinking about the techniques (as opposed to the philosophical goals or motivations of) Aspect Oriented Programming is that they put the power of a good debugger into your programming language. A good debugger allows you set actions (print some variables, stop, etc.) whenever a particular variable is accessed or modified or whenever the call stack looks a particular way. Similarly, a good Aspect Oriented Programming language allows you to set up replacement and/or pre/post actions (call this logging procedure, use this cached variable, etc.) whenever a particular variable is accessed or modified or whenever the call stack matches a particular pattern (gets() just called, for example). And because it's in the programming language, these constructs (which can sometimes be too slow to use in a debugger) can be made very computationally efficient. You need only see a couple examples to realize how powerful and useful this can be. You can then treat some of the rest of the ideas of Aspect Oriented Programming as trying to tame these powerful constructs into something that won't frequently shoot you in the foot (much like Structured Programming tamed the wild goto statement). -- ThomasColthurst The "I Want My AOP" articles on JavaWorld do a great job of introducing AOP concepts. It's more complicated than can be effectively communicated here. There is a mental shift that happens in order to understand AOP - sort of like the same shift that happens when you learn OOP for the first time (after programming in a procedural way). -- KenLiu I don't know this stuff too well, so better explanations are invited. One thing that struck me--leading on from ActiveObjectModel--was the range of techniques they used to implement their approach, which included things like reflection and MetaObjectProtocol(s). It does seem to be about making implicit details explicit. -- DaveHarris All of the theory is nice, but Aspect Oriented Programming doesn't quite fit my dream environment, which would allow me to filter the aspects of the program I'm working on, by using fonts, italics, colors, etc. to show visually what is which aspect of given source. I believe that AOP should be woven into the IDE of Delphi or some similar language, and things can REALLY take off. -- MikeWarot EditText of this page (last edited June 11, 2004) FindPage by searching (or browse LikePages or take a VisualTour)