Attending last LFPUG meetup got me thinking about all the latest Flash and Flex development, especially in the way in which this development is going. I think the community is becoming much more mature and this can be observed by the number of frameworks that have recently poped up. Everyone is blogging about it, and you can actually get lost in all those differences each of the frameworks has. But almost all the frakeworks are build on design paterns, which is definitely a good thing. When it comes to Design Patterns it is pretty straight forward. If you don’t know what they are I suggest doing some research because using design patterns makes your code much more elegant and structured.
Here is what wikipedia says, and remember that wikipedia is ALWAYS right:
n software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.
The whole article can be found here.
Bear in mind that not all the design patterns apply to AS3 because of it’s uniqueness (being an OOP language on client side, not server side). Practical use of design patterns in AS3 was well presented by Eamonn Faherty during the LFPUG’s first session. Eamonn seemed to be pretty confident talking about various patterns and I highly recommend you watch the presentation on LFPUG’s site
If that’s not enough for you, you can always get O’reilly’s book for your iPhone/iPod “Actionscript 3 Design Patterns”. Simply search for “O’reilly Design Patterns” in the app store and this book should come up. I got it myself and I find it really handly to have it will me all the time even if you are only using it to show off what cool apps have. It does the job.
Second session on Frameworks was presented by Richard Lord. Richard is well known in the flash community especially because he’s the man behind Flint, the particle system for flash. That is not the only thing Richard is well known for. Second thing is frameworks. He was even presenting on this year’s Flash on the Beach about frameworks and if you look at his blog it looks like he can call himself an expert. I didn’t make it Richards presentation on FOTB because the conference room got filled out to the max. So for those who had seen it, I recommend you watch what he presented on LFPUG because it seemed that what he added to his FOTB presentation was the most interesting stuff, mainly Parsley and Robotlegs.
I assume all of us heard of Cairngorm, PureMVC and roughty heard of Mate and Swiz.
We constantly hear to stay away from Cairngorm because it’s simply shite (although many of the people who say that have never actually used it), PureMVC is not fun to work with, Mate being only flex framework and Swiz being apparently really good but also working only with flex.
I must admit I am a fan of PureMVC because I believe days of cowboy coding are over. There has to be a unified way of writing code in this industry and PureMVC was the first one to make it happen, especially in the flash department. It’s got it’s pros and cons, but it definitely serves it’s purpose. Code in pureMVC is (usually) neatly organized and if you don’t know it, it means you are way behind.
So what is next?
To me it looks like the next big thing is Dependecy Injection and frameworks build on it. Basically all the frameworks apart from Cairngorm and PureMVC rely on DI. The easiest definition I found:
At the simplest, Dependency Injection is that act of supplying objects with their instance variables or properties. When you pass a variable to the constructor of a class, you are using Dependency Injection. When you set a property on a class, you are using Dependency Injection. If you aren’t coding your AS3 in a strictly procedural or linear fashion, the odds are that you are making use of Dependency Injection right now.
Dependecy Injection always comes with a second term Inversion Of Control. IoC container is nothing else than a container that uses DI, it’s pretty straight forward.
DI and IoC are just one of many things that came to Actioscript from other OOP languages. And I think it’s great. It means we are not re-inventing the wheel, we simply apply the best patterns, aka problem solvers from much more mature languages like Java to AS.
So, looking at what we have available in terms of DI and IoC in Actionscript are the following:
Spring Actionscript (formerly known as Prana).
Prana was the first framework using Inversion of Control for ActionScript 3.0. It was nothing else that a port of Spring Framework for Java. I have never used and I don’t think many people actually have. I think it is mosty the Java reference that puts people off but that’s just my opinion.
SmartyPants apart from it’s really interesting name it is the one that started the whole Dependency Injection trend. SmartyPants is not a framework itself it is only the IOC container. It is a bit verbose but it’s pretty good to get your head around DI, because it is the only thing it covers.
And here is where we come to the main reason why I wanted to write this post.
Robotloegs is awesome. Robotlegs is a MVCS framework based on on Dependency Injection using Flash Events. Why MVCS? Well the author, Shaun, decided to split the model tier of the architecture into Model itself, accessed via internal API and the service where the external data is loaded into the application. Which sounds pretty resonable approach and it’s a minor change in terms of MVC approach. I personally quite like it. THe next thing you would expect is SmartyPants to handle DI. Wrong! Guys working on Robotlegs decided to write their own dependecy injection tailored to Robotlegs. And so they did giving it anoter original name SwiftSuspenders. Cool thing about Robotlegs it that you are not limited to using SwiftSuspenders. You can choose your own Dependency Injector if you don’t like the one it comes with by default. I started digging a few days ago into RobotLegs and I must admit it is really fun thing to work with.
It’s not what we had with pureMVC where you were told how to use it and that was it.
There are a lot of discussions how Robotlegs should evolve, what should be added, removed and if you have anything good to suggest, you will be heard.
I suggest you start following the Robotlegs google group.
I personally think it will be the next big framework, the pureMVC 2.0. The sooner you get into it the better. It works with Flex as well as Flash, which many of those other frameworks lack, they have no love for Flash. But is it the only solution that works with Flash as well as Flex? Certainly not.
Other player here is Parsley. Parsley has been developed by PowerFlasher, same guys who developed FDT. I haven’t played with it yet, it is definitely on my list. But following people opinions (which I don’t think is the best thing to do), I hear although it is pretty well documented, there is no community behind this framework. This is not gonna put me off but it definitely is a huge disadvantage.
Is that all?
There is one more candidate on the horizon. Probably not many people have heard about this framework. It’s called Dawn. Dawn relies on
SmartyPants it’s own DI and is also inspired by Guice (just like the SmartyPants itself). If you are into checking it out, I suggest you visit their site and if you live around London, Sam, the author, will be presenting it on next FLUG on 17th of November 2009.
Robotlegs is gaining loads of momentum, it is definitely worth checking it out. I guess the whole DI stuff if fairly new and it is interesting how things are gonna go with it. But keep your eyes open on Parsley as this it the framework that apparently Adobe uses and their Caringorm 3 is pretty much gonna be like Parsley, from what I’ve heard. Also have a look at Dawn it might turn out to be also big.
If you have any questions, comments, or you disagree let me know