Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Aspect Oriented Programming

I'm wondering if AOP (Aspect Oriented Programming) is used in the PHP community. It seems like it would be a neat supplement or alternative to Delegation. It's a very hot topic in the ColdFusion world right now and has a lot of neat implications.

Mark, are you familiar with this? Did you consider it while working on Vanilla?


  • From what I know, AOP is all about cutting your software to reusable pieces (aspects) where each piece stands for some kind of functionality. But Vanilla already has that: There is a Discussion class, which contains the discussion data. The DiscussionManager performs certain actions with the Discussion class. And the Discussion controls use the DiscussionManager to store and retrieve the discussion data. It's also known as Business objects. Software development is all about cool names :P
  • My understanding is that the cutting in AOP is about crosscutting.

    I found it hard to understand what that was until I saw some examples. In Spring (Java) and ColdSpring (CF Spring) you manage your business objects and their dependencies with xml configuration files. That's a whole other topic, but in those files you can define advisors for a business object. You specify patterns of function names to match Before, After and Around functions in your advisor. Lets say you have a UserService object that handles registration and account changes. You define a security advisor to map to all "get*" and "set*" functions of your UserService using "before" functions. This automatically executes your security "before" functions before any "get" and "set" functions in your UserService. Your function mappings can be specific: "getUserStatus" or universal "*".

    This is why I asked about in terms of Delegation. With Delegation you need to have points manually inserted in your business objects where you can inject extended functionality. With AOP, you automatically get Before, After and Around points to any function you want.

    (Around advisors replace the mapped function call, it's up to your advisor to call the original function, or not)

    The advantage of Delegation though is that you can insert those points anywhere inside functions.
This discussion has been closed.