Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOP Support - where to implement? #139

Closed
jasperblues opened this issue Jan 1, 2014 · 9 comments
Closed

AOP Support - where to implement? #139

jasperblues opened this issue Jan 1, 2014 · 9 comments
Labels

Comments

@jasperblues
Copy link
Member

Erik has kick-started AOP support.

Can we implement this in a separate module or does it need to be tightly coupled with core?

@eriksundin
Copy link
Contributor

So the options as I see it:

  1. Part of Typhoon Core
    Pros: All in one place, we could use Pod sub specs to make it optional. Typhoon/Core Typhoon/AOP
    Cons: Won't work as a stand alone module, would need to keep in a branch until considered stable
  2. Module dependent on core (typhoon-aop repo)
    Pros: Separation, optional to users as a stand alone pod,
    Cons: Won't work as a stand alone module. Separate versioning, might be a pain in the long run.
  3. Stand alone module
    Pros: You can use the lib without Typhoon if you'd like
    Cons: We'd need to make a third module that has the typhoon integration.

I think 2 is probably a good option if we introduce an integration point, like the ComponentPostProcessor in Core, where typhoon-aop could hook in. Separate versioning should not be too much problems if we keep the integration points stable. We could probably achieve 3, within option 2, with the use of pod sub specs if we wanted to.

How do you guys see this set up?

@jasperblues
Copy link
Member Author

I was thinking option 2.

  • ComponentPostProcessor is a good integration point and would certainly make sense to build one of these in any case.
  • The proxy based approach is flexible in that it applies to specific instances of a class, instead of all instances. The downside is repetitive setup, but this is. to a problem if using typhoon - it'll do this for you.
  • That said it could still be used separately or embedded in other applications

@jasperblues
Copy link
Member Author

Ps: I was originally thinking about a swizzle-powered approach. Advantages:

  • It can be used to apply 'DI' to non-container managed classes. (Similar to how Spring's Configurable annotation does. . This is useful if say, if you're using CoreData and need DI after they're emitted from it. Could also be used for StoryBoard integration. . . .
  • one-time setup

Cons:

  • it's not opt-in. You're stuck with it for all instances
  • Probably more chance of breaking, and breaking more spectacularly.

The proxy-based approach would be akin to the Java dynamic-proxy and cglib based weaving in Spring 2. (In java you need to mechanisms one for concrete classes, one for interfaces, in message-based . . Dynamic method dispatch means objc only requires the one approach) .... And the swizzling approach is similar to AspectJ weaving.

There's also Justin Spahr-Summers' libffi based approach, however given Daniels research, it's not a good time to adopt as 64bit vs 32bit can cause issues. (Also while proven to work in theory, the demo in libextobjc has never been stable. . It quickly crashed for me.)

. . . So now I'm sold on the proxy approach, though it still be interested in seeing other styles in future. As an added challenge, it would be good, if possible, to make the weaver pluggable.

@eriksundin
Copy link
Contributor

Alright, option 2 it is then. Let's see where it takes us. I agree it would be nice to have both proxy and swizzle weavers. Will look into how this can be done nicely.

If you create a Typhoon-AOP repo (I'm missing the permissions) I will start setting things up to get us started. Will probably need some help with the CI/build-setup at some point.

@jasperblues
Copy link
Member Author

Oops. . . didn't realize about the permissions (will fix). . . have created the repo.

Re CI build - I'll give you a login to the server, etc . . . (but I can set it up for you).

Over the holidays I did some work on making some gradle tasks for Xcode. . I'm having a look again today. . This should provide build scripts that read much more nicely.

@eriksundin
Copy link
Contributor

Great, thanks. You gave me a login before .. I think I might have misplaced my credentials though ;-S Appreciate if you can set the account up for me (again).

@jasperblues
Copy link
Member Author

Once you have a couple of files in there I'll set up a build. . . . (gradle stuff should be ready in a few hours too).

@eriksundin
Copy link
Contributor

Cool. I'm gonna be on the road today but will get back to it once I have the time.

@jasperblues
Copy link
Member Author

Have fun :)

(ps: fixed - you should have admin rights now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants