"Never memorize something you can look up", Albert Einstein

Aspect Oriented Programming AOP short review

Recently we had to do a presentation about crosscutting concerns and possible solutions during a class on my school. During our research we found one possible solution for crosscutting solutions that is at the moment still a discussion point whether it’s a good Object Oriented Programming (OOP) followup. In this small article some quick information about AOP.

Crosscutting concerns are frequently reoccurring pieces of code that are required across multiple classes, but they’re side problems that don’t have any explicit connection with the code. Some of these crosscutting concerns can be:

  • Logging (you have to add to every method at multiple places a logging-entry)
  • Security (Check if user is authorized to call method)

Now I hear you thinking: Okay and how is AOP going to make my day?
Well, think of AOP as OOP with the possibility to ‘insert code’ at places defined in an external file.

In AOP you can create classes and develop code just as you did in OOP, the only difference is that AOP allows you to create an ‘Aspect’ that can define in what classes and methods it can ‘add code’. So instead of having a if(this.isAuthorized()) in multiple methods in multiple classes you have this line of code in one place inside the Aspect.

Pretty cool, why isn’t it used yet?
Currently you can find AOP in the Spring framework. The Eclipse IDE has also got support for AOP called (AspectJ). But it isn’t used that much outside these two.

Why not?
Well there is quite a discussion about AOP at the current moment regarding when to ‘inject’ this code into your ‘regular code’. Some think that AOP-code should be injected during compiling, others think that it should be injected during runtime. One of the problems that occurs with AOP is the question: When I debug, what’s going to happen when the aspect-code is called, how will it find it’s way to the Aspect-class?

Sources

  1. http://rootdev.nl/downloads/ppt/aop.pptx (Dutch)
  2. http://www.cs.vu.nl/%7Ejnherder/aopatterns/aop-lecture.ppt
  3. http://video.google.com/videoplay?docid=8566923311315412414#
  4. http://en.wikipedia.org/wiki/Aspect-oriented_programming
  5. http://www.eclipse.org/aspectj/

 


Only members are allowed to post a comment.

Comments

Geplaatst door WilliamFarthowe op 06-Dec-11 13:12

I like this resources you provide to us http://www.cs.vu.nl/~jnherder/aopatterns/aop-lecture.ppt but when the next time I visited the link became error. can you please give me some of it?
Or Essay Editing will guide you or give you there information too.