Search code examples
javascriptbackbone.jsaopmixins

Aspect programming using Backbone


I am looking for some detailed example with code where I the Aspect Oriented programming is implemented using Backbone.Advice mixin.

I have looked at following links but those are not that intutive and I am finding it difficult to integrate that into my Backbone MV* application.

https://github.com/rhysbrettbowen/Backbone.Advice

Also can someone tell me whether using advice can I access the original parameters passed to the method around which the advice gets applied.

Edit: answering your questions here in original thread

Q: What are you really looking for? Trait based composition and conflict resolution by method modifiers like before, after, around or real Aspect-oriented programming?

A: I have few views which which are inherited from a common view, Now all this view contents their own implementation for render, I would like apply a advice i.e. after every render do some custom stuff etc.


Solution

  • I am looking for some detailed example with code ...

    Unfortunately I'm not able to point you somewhere on that. But I might be able to provide help for the rest.

    ... where ... the Aspect Oriented programming is implemented using Backbone.Advice mixin.

    Having a look into the source code, "Backbone.Advice" does not provide any functionality for Aspect-oriented programming.

    But - as the first sentence at Backbone.Advice states - it does provide "Functional mixins for Backbone based on Advice by Angus Croll". Thus it provides its own mechanics of how to solve composition conflicts if one is going to use Mixins like Traits.

    Q: What are you really looking for? Trait based composition and conflict resolution by method modifiers like before, after, around or real Aspect-oriented programming?

    Q: What are you trying to achieve?

    Also can someone tell me whether using advice can I access the original parameters passed to the method around which the advice gets applied.

    Looking into the source code of Backbone.Advice again ...

    https://github.com/rhysbrettbowen/Backbone.Advice/blob/master/advice.js#L36 https://github.com/rhysbrettbowen/Backbone.Advice/blob/master/advice.js#L48 https://github.com/rhysbrettbowen/Backbone.Advice/blob/master/advice.js#L64

    ... the answer is "Definitely yes".