Skip to main content

Posts tagged with 'aop'

I really enjoyed Cammy's brief talk on AOP in Ruby, and I think she successfully shows that even software written in a dynamically-typed language like Ruby can still benefit from AOP. There is some sort of technical issue early in the video that caused the sound not to be recorded, but it is fixed about 20 seconds in.

Follow Cammy on Twitter.

Hello, again! "Weekly Concerns" is a post-a-week series of interesting links, relevant to programming and programmers. You can check out previous Weekly Concerns posts in the archive.

In a previous post, I showed off prototype's 'wrap' function, which gives JavaScript some AOP capabilities.

jQuery, a tool that I'm more familiar with, doesn't have an equivalent function that I know of. But there is a jQuery AOP plugin that provides a great AOP framework to your JavaScript. 

While 'wrap' is akin to 'interception' style AOP, jQuery-aop includes some 'boundary' style aspects (as well as replacement/interception), including:

  • before a method
  • after a method
  • when a method throws an exception
  • when a method completes (exception or not)
  • "around" a method
  • replace a method (i.e. an "introduction")

There is some good API documentation available. Here's a little 101 example using "before" and "after":

Just paste that into an HTML file and run it in your browser, and you should get two alert messages. Since it's JavaScript, you can apply AOP to built-in functions like String.replace, or jQuery functions, just as easily as you can functions that you've written.

Week #2 is coming to an end here at CrossCuttingConcerns, which means it's time for another link dump post.

Thanks for reading, and please leave a comment or use the contact link above if there's something you'd like to see covered here on CrossCuttingConcerns.com (or if you have something to say and want it published here).

Matthew D. Groves

About the Author

Matthew D. Groves lives in Central Ohio. He works remotely, loves to code, and is a Microsoft MVP.

Latest Comments

Twitter