Application Frameworks: The new kids on the block

  • 3,947 views
Uploaded on

The past year has seen an rapid growth in the development and adoption of a new breed of frameworks for Flash and Flex development. Based around Dependency Injection, these frameworks are lightweight …

The past year has seen an rapid growth in the development and adoption of a new breed of frameworks for Flash and Flex development. Based around Dependency Injection, these frameworks are lightweight and flexible.

But why should you consider these newcomers over the existing incumbents, and if you are to adopt a member of this new gang, which should it be?

In this session Richard will show you four of these newcomers – Robotlegs, Swiz, Parsley, and Spring Actionscript. He’ll discuss what they have in common and where they differ, why he thinks they are ready for mainstream use, and how to choose between them.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,947
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
0
Comments
0
Likes
10

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide


































Transcript

  • 1. gotoAndSki(), June 2010 Application Frameworks The new kids on the block Richard Lord twitter.com/Richard_Lord Technical Architect www.richardlord.net BrightTALK www.brighttalk.com
  • 2. Application Frameworks Robotlegs (1.0) Swiz (1.0) Parsley (2.2) Spring Actionscript (1.0)
  • 3. History and evolution Generation 1.0 Cairngorm Out of date PureMVC Generation 1.5 Mature Mate Swiz Parsley Generation 2.0 Entering their prime Robotlegs Spring AS
  • 4. Coming Up Similarities Dependency Injection Event Bus Differences Conclusions
  • 5. They are very similar • Open-source. • May be used with the Flex Framework, Pure AS, or Flash CS. • Non-prescriptive about your architecture. • MVC is optional. • Provide a dependency injection container. • Provide an event bus.
  • 6. Dependency Injection
  • 7. Dependency Injection How objects obtain references to each other
  • 8. Not dependency injection New class Controller { private var _model:Model; public function Controller() { _model = new Model(); } } Singleton class Controller { private var _model:Model; public function Controller() { _model = Model.getInstance(); } } Registry class Controller { private var _model:Model; public function Controller() { _model = Registry.get( Model ); } } Factory class Controller { private var _model:Model; public function Controller() { _model = Factory.create( Model ); } }
  • 9. Dependency injection Constructor class Controller { Injection private var _model:Model; public function Controller( model:Model ) { _model = model; } } Setter class Controller { Injection private var _model:Model; public function set model( value:Model ) { _model = value; } }
  • 10. Dependency injection container • The DI Container is an object for managing these dependencies. • The DI Container is configured to inject the correct objects into the correct classes. • We may ask the DI Container to create our objects. • Or we may ask it to inject objects that are created by some other means.
  • 11. Dependency injection container Model 1. Create 2. Create DI Controller Container 3. Inject Model 4. Inject Model View (created by Flex)
  • 12. Configure DI with XML Spring Actionscript <objects> <object class="package.Model" id="model"/> <object class="package.Controller" scope="prototype"> <property name="model" ref="model"/> </object> <object class="package.View" id="view" singleton="false"> <property name="model" ref="model"/> </object> </objects> Supported by Robotlegs Parsley Spring AS
  • 13. Configure DI with MXML Parsley <Objects> <Model id="model"/> <Object type="{Controller}" singleton="false"> <Property name="model" value="{model}"/> </Object> <View type="{View}"> <Property name="model" value="{model}"/> </View> </Objects> Swiz <BeanProvider> <Model id="model"/> <Prototype type="{Controller}" id="controller" constructor-arguments="{model}"/> </BeanProvider> Supported by Swiz Parsley Spring AS
  • 14. Configure DI with actionscript Robotlegs class MyAppContext extends Context { override public function startup():void { injector.mapSingleton( Model ); injector.mapClass( Controller ); } } Swiz class MyAppContext { public function startup():void { var model:Model = new Model(); var proto:Prototype = new Prototype( Controller ); proto.constructorArguments = model; bp = new BeanProvider( [ model, proto ] ); } } Supported by Robotlegs Swiz Parsley
  • 15. Configure injections with metadata Robotlegs, Swiz & Parsley class View { [Inject] public function set model( value:Model ) { _model = value; } } Spring Actionscript class View { [Autowired] public function set model( value:Model ) { _model = value; } } Supported by Robotlegs Swiz Parsley Spring AS
  • 16. Injecting into view components Use Annotations Supported by Robotlegs Swiz Parsley Spring AS Use Configuration Supported by Parsley Spring AS
  • 17. The Event Bus
  • 18. Event Bus dispatch dispatch dispatch event event event Event Bus listen for listen for listen for event event event
  • 19. Using a single event dispatcher dispatch dispatch dispatch event event event Event Dispatcher listen for listen for listen for event event event
  • 20. Using a single event dispatcher Dispatcher var event:Event = new Event( EventNames.CUSTOM ); eventBus.dispatchEvent( event ); Listener eventBus.addEventListener( EventNames.CUSTOM, eventHandler );
  • 21. Implementations
  • 22. Inject the event bus Robotlegs [Inject] public var eventBus:EventDispatcher; var event:Event = new Event( EventNames.CUSTOM ); eventBus.dispatchEvent( event ); Swiz [Dispatcher] public var eventBus:EventDispatcher; var event:Event = new Event( EventNames.CUSTOM ); eventBus.dispatchEvent( event ); Supported by Robotlegs Swiz Parsley
  • 23. Inject the event bus Robotlegs [Inject] public var eventBus:EventDispatcher; eventBus.addEventListener( EventNames.CUSTOM, eventHandler ); Swiz [Dispatcher] public var eventBus:EventDispatcher; eventBus.addEventListener( EventNames.CUSTOM, eventHandler ); Supported by Robotlegs Swiz Parsley
  • 24. Use metadata to indicate bus events Parsley [Event(name="custom",type="Event")] [ManagedEvents("custom")] var event:Event = new Event( EventNames.CUSTOM ); dispatchEvent( event ); Spring Actionscript [Event(name="custom",type="Event")] [RouteEvents("custom")] var event:Event = new Event( EventNames.CUSTOM ); dispatchEvent( event ); Supported by Parsley Spring AS
  • 25. Use metadata to indicate listeners Parsley [MessageHandler( selector="custom")] public function eventHandler( event:Event ) {...} Spring AS [EventHandler( selector="custom")] public function eventHandler( event:Event ) {...} Swiz [Mediate( event="EventNames.CUSTOM")] public function eventHandler( event:Event ) {...} Supported by Swiz Parsley Spring AS
  • 26. Autowire commands Robotlegs commandMap.mapEvent( EventNames.CUSTOM, MyCommand, Event ); Parsley <DynamicCommand type="MyCommand" selector="custom"/> Supported by Robotlegs Parsley
  • 27. Which leaves one question
  • 28. Which is best?
  • 29. Spring Actionscript Favours XML configuration Very good for Spring Java developers Very detailed documentation Lots of configuration options Still has a few bugs (but they're working on it)
  • 30. Parsley Greatest range of features Favoured by Adobe Consulting Few examples Little community involvement Single developer
  • 31. Swiz Favours MXML configuration Loves Metadata Extendable metadata processor Lots of community involvement Limited documentation (but improving)
  • 32. Robotlegs Favours Actionscript configuration Choice of DI Container Reference MVCS implementation Lots of community involvement Good documentation
  • 33. You choose.
  • 34. This is me www.richardlord.net twitter.com/Richard_Lord