Someone else can probably give a better definition of AOP, but a very
simplistic view is the ability to add additional functionality (aspects)
to your code.  This functionality is contained in its own methods and
objects, leaving your original code nice and clean.  

Here's an example I heard/read a while back but I can't remember where.
Picture a banking transaction where you transfer money from one account.
This is really very simple in theory; you check that the funds are
available, debit one account and credit the other.  However, in reality
you need to do a lot of overhead such as implement transactions,
database queries, user permissions, account restrictions, etc.  In the
end this simple task can be extremely cluttered, confusing and hard to
test.  If you rather add these additional "aspects" to the original code
then this keeps things clean and organized.  I haven't had a chance to
play with it but I hesitate to think AOP is as easy as the example above
sounds, otherwise it would have caught on much quicker, but I have heard
of great uses, such as an easy way to add logging to your functions.  

Here's an interesting article on dynamic library loading in JavaScript.

http://www.ddj.com/linux-open-source/202401087?pgno=1

If you have a large app using a lot of JavaScript, it goes to say that
hardly any of the users will use every single function you wrote.  So,
if you organize your JavaScript into logical separate files you can
dynamically load libraries as their needed rather than loading all your
code at once.  Using the jQuery plug-in you found this would probably be
a little easier and cleaner.

The ideas put forth in the article are interesting but need a little
more work.  While calling a function only loads that library once,
calling several similar functions that require the same library will
cause the presence of the library to be checked over and over again.
What they need to add is a table listing all the dependencies on a
particular library.  Once the library is loaded the aspects can be
removed from all remaining dependent methods.

Maybe I'll work on something like this someday when I have time.  :)

Matt Penner

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of PragueExpat
Sent: Monday, January 07, 2008 3:26 AM
To: jQuery (English)
Subject: [jQuery] Aspect Oriented Extension for jQuery


Surfing dzone.com this morning, I came across this plugin for jQ:

http://code.google.com/p/jquery-aop/wiki/Reference.

Being unfamiliar with aspect oriented programming, I did a quick
wikipedia lookup and quickly realized that this could be a great way
to keep code clean.

My question is this: who among us can better explain aspect oriented
programming or provide some examples of how to use it effectively?

What types of functions are best applied via this methodology?

Any known drawbacks?

Thanks for any info on this subject.

Reply via email to