Programmers used to more dynamic, reflective languages like LispLanguage, SmalltalkLanguage, PythonLanguage, or RubyLanguage can be found puzzling about what is new enough about this to give it an "*OrientedProgramming" name.
AOP is just an extension of ObjectOrientedProgramming. Both of these tools allow us to more easily achieve CodeNormalization.
The RubyLanguage also lets you do this - you can (for example) change the behavior of method invocation or attribute access on a particular object or class of objects, all at run time. For example, you could define your own tracing capability, point it at an object, and suddenly that object traces all accesses to its attributes, all with no change to that object's source. Once you have decent reflection and metaclasses, AOP is just part of the language. -- DavidThomas
Could you offer an example that would clarify this, please? :)
Any OO language lets you define class methods, like so:
# User.rb class User def getRank self.rank end ... endRuby also lets you define, at runtime, methods on a predefined class, outside of that class' original definition. This lets you do things such as, say, add a method to a predefined class:
# UserPlus?.rb # User was already defined in User.rb, but let's add one more method here class User def selfEsteemProgram true end endIn Python, this can be done as:
# User class already defined, but we add another method here User.selfEsteemProgram = lambda x: TrueBack to Ruby, you can also define, at runtime, methods on individual objects:
# happyUsers.rb myUser = User.new if selfEsteemProgram def myUser.getRank "Supervisor" end endAnd in Python:
myUser = User() if myUser.selfEsteemProgram(): def f(x): return "Supervisor" import new myUser.getRank = new.instancemethod(f, myUser, myUser.__class__)Also, Ruby's MixIns or Python's MetaClasses might be enough to take care of what AOP is supposed to do.
For Python, see Pyarie (http://pyarie.wikisophia.org/index.php/AOP), which uses the Pythius (http://pythius.sf.net) AOP module. Also TransWarp? seems to have had some Aspect aspect. (http://www.zope.org/Members/pje/Wikis/TransWarp/AOPTutorial). And, finally, there's http://www.logilab.org//projects/aspects/.
For a more detailed/better example of AOP in Ruby, and a rewrite of an AOP refactoring tutorial from http://www.theserverside.com/articles/article.jsp?l=AspectOrientedRefactoringPart1, see http://homepages.ihug.com.au/~naseby/16.html. -- AnonymousDonor
IoLanguage has similar capabilities to Ruby's. -- JasonGrossman