AS3 IOC Containers: Spring Actionscript (Prana) vs Parsley
Today, I decided to bring some good ol' IOC and dependency injection into my AS3 workflow. I took two of the most popular IOC containers for test drives and compared the features of both, and in this post, I'm going to log my findings.
1. SpiceFactory's Parsley (current version 1.0.2)
Download | Documentation
Learning to use Parsley was really easy. The documentation was very concise and yet complete, it didn't just shove a bunch of examples and ASDocs in your face, it explained in-depth how the various aspects of Parsley work and how they can be extended. It has really interesting features, kind of a little break from just regular IOC and dependency injection.
Some of the things I really liked about Parsley were:
2. Spring's "Spring Actionscript", formerly Prana (current version 0.6)
Download | Documentation
Spring Actionscript (Prana) was a bit more difficult to learn because of lack of documentation, but proved to be far more powerful than Parsley, though it lacks some of the cool features that Parsley has. As far as I know, it lacks the cool localization that Parsley offers standard, and it definitely lacks the "listener" tag that Parsley boasts, though you can achieve the same general result with the Spring Actionscript "method-invocation" node. Plus, since Spring has taken charge of the project, it's just like Spring! This, for me, is huge. I love Spring. Spring is amazing and easy to use, and their Actionscript IOC container is such as well.
What I loved about Spring Actionscript:
Until then, here's my two test projects. They contain basically translations of the same general project, translated to Spring Actionscript and Parsley. The required libraries are included in each projects corresponding lib folder, though I used Arthropod for debugging and I didn't include that. They're Flex projects by the way. These are to help you make your informed choice on what to go on, rather than just depending on my glorious madness to make your decisions upon:
uploads/as3ioctesting.zip
Good luck in the wonderful world of IOC!
EDIT**
Here's a bit of a disclaimer about Parsley. Parsley does have a sort of "method-invocation" tag, though it wasn't clear to me at first. According to Jens Halm, the project lead, you can have multiple init-method tags to invoke methods when the object is instantiated. So basically, you can achieve the same result without the method invocation tag. So now my choice is more unclear. I like Parsley AND Spring Actionscript. I don't know what I'm going to do, but you can still make a choice at least :)
1. SpiceFactory's Parsley (current version 1.0.2)
Download | Documentation
Learning to use Parsley was really easy. The documentation was very concise and yet complete, it didn't just shove a bunch of examples and ASDocs in your face, it explained in-depth how the various aspects of Parsley work and how they can be extended. It has really interesting features, kind of a little break from just regular IOC and dependency injection.
Some of the things I really liked about Parsley were:
- The documentation. It rocked. It was so complete and so in-depth that it made it a breeze to get started with Parsley. It showed a lot of examples of how to use Parsley to its fullest, and explained the various API's well.
- Localization of messages. Parsley makes it really easy to provide localization to your applications. Localization is one of the things that has always been a pain for developers to implement, but Parsley covers this facet extremely well. Localization can be manually set or automatically interpreted by Parsley. You create message bundles for the various strings required by your application (such as a tooltip for a button: "Opens a file for editing.") and you create multiple message bundles (which can go in separate XML files) for each locale you're targeting. It's super easy and though I haven't tried it out just yet, one can see how it makes localization a non-issue for application development. The more you take advantage of IOC in Parsley, the more you can incorporate localization. Awesome feature.
- Event listener tags in XML contexts. You can easily register event listeners in the context with the "listener" tag. This makes life a heck of a lot easier for me at least. I despise typing out "addEventListener" four to ten times for a complicated object with lots of dependencies.
- Easy to extend. Fo' sho'.
- Non Spring-like XML definitions. Parsley breaks away from the Spring XML definitions that I like, and am used to. I'm OCD, so this is basically life-and-death for me ;) Plus the Parsley definition structure is a bit more verbose, so you'll end up typing more code in your definition files.
- Inability to simply invoke methods. For the logging framework I've developed and use, I need to call functions like "registerOutput" on my objects, and Parsley simply can't do that yet. Spring Actionscript (Prana) handles this with the "method-invocation" tag, which I like... a lot.
- More verbose setup in parsing contexts. You need to instantiate a parser and have that load a context into another object. This extra step is kind of useless, at least to me it is.
2. Spring's "Spring Actionscript", formerly Prana (current version 0.6)
Download | Documentation
Spring Actionscript (Prana) was a bit more difficult to learn because of lack of documentation, but proved to be far more powerful than Parsley, though it lacks some of the cool features that Parsley has. As far as I know, it lacks the cool localization that Parsley offers standard, and it definitely lacks the "listener" tag that Parsley boasts, though you can achieve the same general result with the Spring Actionscript "method-invocation" node. Plus, since Spring has taken charge of the project, it's just like Spring! This, for me, is huge. I love Spring. Spring is amazing and easy to use, and their Actionscript IOC container is such as well.
What I loved about Spring Actionscript:
- It's just like Spring. \m/
- The "method-invocation" node. This really helps make the framework a heck of a lot more flexible.
- XML declaration files are less verbose and AS3 instantiation is a less wordy. And it runs just as you'd expect an IOC container to run. If you've used Spring, the migration to Spring Actionscript is a no brainer.
- It's a huge framework. I guess this is both good and bad, but I like having a lot versus a little, but maybe that's just me. It has plugins to Cairngorm and PureMVC, which I'm sure a lot of people are grateful for.
- It doesn't have the "listener" tag that Parsley has. It's more of a convenience thing than a lack of a feature, but it's still really nice to have.
- It doesn't have the localization features of Parsley. The message bundle API of Parsley is genius, really powerful and super easy to use.
- Lack of documentation. Insert sad face here. It was a bit of a challenge to get up and going with it, but in the end it was worth it.
- Lack of "init-method" and "destroy-method" and "factory-method" subtags of an "object." It supports the "init-method" and "factory-method" parameters on the "object" tag, but it's nice to just nest those underneath the "object" tag rather than as a parameter to the base "object" tag. The "destroy-method" is completely left out, though I'm not sure how that would apply in AS3, if at all. I'm really missing the "static-factory-method" tag that Parsley supports though. So maybe this aspect of Parsley is more like Spring than, dare I say, Spring Actionscript?
- Not so easy to extend. There's little documentation beyond the ASDocs, so I wouldn't know if I could implement a preprocessor like in Parsley or anything advanced like that.
Until then, here's my two test projects. They contain basically translations of the same general project, translated to Spring Actionscript and Parsley. The required libraries are included in each projects corresponding lib folder, though I used Arthropod for debugging and I didn't include that. They're Flex projects by the way. These are to help you make your informed choice on what to go on, rather than just depending on my glorious madness to make your decisions upon:
uploads/as3ioctesting.zip
Good luck in the wonderful world of IOC!
EDIT**
Here's a bit of a disclaimer about Parsley. Parsley does have a sort of "method-invocation" tag, though it wasn't clear to me at first. According to Jens Halm, the project lead, you can have multiple init-method tags to invoke methods when the object is instantiated. So basically, you can achieve the same result without the method invocation tag. So now my choice is more unclear. I like Parsley AND Spring Actionscript. I don't know what I'm going to do, but you can still make a choice at least :)
Labels: as3, dependency injection, flash player, ioc, parsley, prana, spring
8 Comments:
thanks for the review, and thanks for including your code. You could also have a look at lowra which has a big ioc package. Though it's really lacking a lot of documentation...
I took a look at LowRA and it doesn't seem to be very powerful or flexible. If you think that it's a huge library and worth the time, I could definitely write up my findings on it, but I can't see that it's really a competitor to Spring Actionscript and/or Parsley.
Oh, and there is an updated link to Spring Actionscript, but I'm going to leave the Prana link up there:
http://forum.springframework.org/showthread.php?t=64370
Very Nice. Thanks for the intro. I'm about to dive into the IOC World via Spring right now.
Good luck! Spring Actionscript is a really nice library, it just lacks a lot of documentation and examples, which is where Parsley excels at. Have fun!
Where does the MATE Framework fit into all of this? It's not IoC, but I'm wondering if you've had a chance to form and opinion yet.
Where does the MATE Framework fit into all of this? It's not IoC, but I'm wondering if you've had a chance to form an opinion yet.
I haven't actually looked into the Mate framework because I can't really find any information on it :P
What I heard was that it was a compile-time IOC-like framework that allowed you to wire together your objects and drive things by events. It sounds really rad, but I just haven't been able to get any information on it, and I actually don't do too much work in Flex.
I am stoked to try Parsley now that you made a sample file. I think I would like to have the option to do real IoC via an XML file or compile time IoC like Mate.
I have worked with Mate on one commercial project and have to say I liked it. The only complaint that I have is that there is a bit of magic in there I haven't figured out, like the DI mechanisms. Ideally I would like to borrow the IoC/DI from it combine it with the Mediators concept from PureMVC and the command structure of Cairngorm. All while having an external IoC Container to boot.
Post a Comment
Subscribe to Post Comments [Atom]
<< Home