Presentation: How to go from Flash to Flex development and why

Flash & Flex October 16th, 2009 @ 15:10

I’ve conducted a small study recently, trying to figure out if we could evolve in our Flash RIA development somehow. I’ve read and experimented a lot with Flex, MXML and related tools to see if we’re missing something (we’re not using it very much today).

It’s not that we’re unhappy with how things are done now, but with the new Flex 4 and everything associated to it, I’ve felt that there’s an opportunity to make some improvements to our workflow.

Summing it up

As presented below, there are a few conclusions to be drawn here, for example:

  • Flex 4 seems to be a really nice upgrade and probably something you can’t ignore in the end.
  • There’s little information on the web about development of large Flash/RIA applications (like those we do). Pretty much all focus is on Flex development of small-to-medium sized applications. I’m not to speculate on the reasons why no one is spreading the word, but hope that my work can shed some light on the area.
  • There’s a lot of fuzz around the Adobe products in general and Flex in particular. Very few seem to have any criticism at all when it comes to Flex, which is a bit disturbing, as nothing that looks too good to be true ever is. But maybe I’ve just been looking at the wrong side of the web? Just a reflection…

Presentation of findings

I held an in-house presentation on my findings yesterday, and I thought I’d better share it with the world (= your favourite search engine). I’ve stripped it down a bit, as there were some company specific things in there, but most of it is free for everyone to read.

A few things to consider before jumping in, though:

  • This is a PowerPoint (well, OpenOffice actually) slide with notes. There was lots said when presenting each slide, so I can’t guarantee that you’ll learn everything I said. I understand this is not perfect, but figured that it’s better to upload this than nothing.
  • It’s just plain slides with notes, really. I did have some imagery in the original slides, but left it out as it’s probably only needed as “distraction” when viewed on a large screen with me talking next to it. So don’t get mad if it’s boring!
  • The plan wasn’t actually to hold an in-house presentation, but I figured it was a good idea. So the format on which it is presented may or may not be optimal, as it’s pretty much been summarized as I’ve went along. It could be a good idea to shape it up and make it a bit better, but at the moment, it’s more important just getting it “out there”.

The presentation itself

With that having been said – and my back having been covered ;-) – here it is (also available as a PDF):

Download (PDF, 134.18KB)

EDIT: Also added the presentation to SlideShare.

Using the Swiz MVC framework for Flex

Flash & Flex September 22nd, 2009 @ 11:09

In my post a few days ago, I mentioned that that Scott Delap and his team were using the Swiz MVC framework. I decided to try it out, and I have to say it looks quite promising. The Swiz tagline is “Brutally simple micro-architecture for Rich Internet Application development with Adobe Flex”, and it was actually pretty easy to set up. The framework is similar to the way Java Spring works with autowiring, so if you’re familiar with that you’ll probably like Swiz.

I’ve only read the docs and tried the demo out so far, but it’s a very interesting candidate for future Flex projects. It’s quite easy to separate the views and controllers from the business logic and using both MXML and ActionScript views seems to work fine. Swiz really gets the job done.

Seems better than PureMVC

I’ve tested the PureMVC framework earlier and kind of liked it, but developing with PureMVC gets quite repetitive and you produce quite a lot of boilerplate code. I like it better when the MVC framework easily guides you towards a proper structure, without having to do too much work to get there.

Also, there seem to be pretty good community activity in the Swiz Google Code project.

It seems like the best MVC framework candidate so far!

Presentation on creating an online multiplayer game lobby in Flex & Air

Flash & Flex September 18th, 2009 @ 15:09

I came across a really interesting presentation from Scott Delap on InfoQ:

Scott Delap shares his experience creating a lobby interface for an online game using Flex&Air. He details on related technologies used, available tooling and frameworks pros&cons, remoting options, unit, functional and load testing approach used.

To sum it up, it’s a good and elaborate presentation from a Java developer’s perspective, with reflections from a online multiplayer game development project. I enjoyed the full hour of watching it! :)

They’ve dealt with many of the questions we have and their conclusions are very interesting.

Presentation summary

I’ve summarized the most interesting contents of the presentation. They’re actually notes taken during the presentation, so please forgive any poor language or formatting:

  • The Flex Builder WYSIWYG actually works, which isn’t common at all
  • MVC in Flex is pretty much MVc, where the controller and view are sort of bundled together
  • When choosing an MVC framework, Swiz turned out to be most interesting (among likes of Cairngorm, PureMVC etc). Swiz is similar to Spring with auto-wiring. Also supports Dependency Injection, Command Chains, and has MXML support even for non-views (i.e. for wiring the M:s, V:s and C:s).

Their MVC implementation:

  • MXML for the views
  • ActionScript for the controllers
  • Remoting interfaces + specific back-end implementation
  • Swiz wiring it all up
  • They found no real reasons to use a “big MVC framework”, whereas Swiz did the job well enough

Remoting

Looked at several candidates, where WebORB, Hessian, XMPP, GraniteDS, Rest not weren’t considered enough for various reasons. Also evaluated BlazeDS, which doesn’t scale and has no NIO support.
Best candidate: LiveCycleDS - supports NIO, RTMP and lots of connections:

  • Good for remoting Java <> Actionscript and easy to integrate
  • Some Java <> ActionScript translations a bit problematic, i.e. enums and null values
  • Some lack of documentation when it comes to messaging

Unit testing

  • Evaluated ASUnit, FlexUnit, DpUnit/Fluint
  • Chose Fluint, but could just as well have chosen FlexUnit. Unit testing Utilities, Controllers, Remoting Services with Mocks

Functional testing

  • FlexMonkey not working properly with AIR and had a bit of lag
  • Wrote a stripped-down version of Selenium

Load testing
Currently no good way of performing load testing.

  • Hard to simulate 1000:s of users
  • No really good tool for load testing at the moment

Final thoughts on Flex

  • MXML works as advertised
  • Easy to do complex things
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/

Optimizing the development process

Other March 23rd, 2009 @ 15:03

I’m currently working with some research on how to create an optimized development process with between Artists <-> UI designers <-> Developers. This will be an ongoing discussion and evaluation process, but I’ve come to some conclusions this far.

What’s the deal, anyway?

I’ve been discussing the issue a lot with Peter, our team’s designer, and we’ve been trying to pin-point the most important parts of the process. Two of the main issues are:

  1. being able to have short “design-implement-test” iterations when implementing new features, making changes etc.
  2. maintaining a solid code base while still allowing non-developers to make changes to the interface.

Does the technology matter?

It’s hard to say which technology to use in order to meet the demands, as it depends very much on what the product really is. If it’s a game where instant and fluffy feedback is important, then we should probably make it a Flash app. If it on the other hand is more of a site, where larger sets of data are important to display in an easy-to-understand manor, then we should probably make it a HTML/AJAX app.

In our upcoming, and many of our current, projects we’re focusing a lot on the visual experience. We’re developing games. In Flash. So how can we optimize the processes with focus on Flash development?

Supporting short development iterations

In order to support short iterations, we need to make it easier for project members to change things without being hindered by their technical skills; a designer or artist shouldn’t need to have ActionScript expertise to change the colors of a button or the placement of a menu.

One way of solving this can be to use Flex with MXML. In MXML, the layout (View) can be changed using a special markup language, logically similar to HTML. Various components, such as buttons, can be positioned freely with some pretty easy-to-use tags. This is quite commonly used among developers all over the world.
Now I haven’t used MXML to any massive extent, but in my opinion, using MXML isn’t really all I want it to be. The code gets a bit ugly and somewhat hard to control.

We’ve got a great tool for this

A while ago, one of my co-workers developed our own framework where it’s possible to easily define views on an XML format. Some capabilities of the framework:

  • a widget (component) class can be mapped to an SWF file, i.e. containing the art assets for a widget
  • widgets can be positioned anywhere in its container, either with an absolute position or relative to any other widget
  • widgets can listen to events from other widgets, in order to allow for them to communicate with each other
  • a widget can consist of another XML definition to allow for better structure in the view document

It pretty much meets the demands one’s got on such a framework! An advantage (which could also be seen as a disadvantage) is that we can develop the framework further when needed, in order to add more nifty functionality.

Is this enough for us?

Anyway. Allowing the designer/artist to create widgets/components and using the widget framework for creating a layout is probably a very good way of meeting the demands of our desired work process. A couple of things that are vital:

  • The View (Widgets and Layout) needs to be clearly distanced from the actual functionality in order to maintain a solid and independent code base, i.e. no functionality should reside in the Widgets or the View document.
  • The widgets should be kept as small and isolated as possible, to make it as flexible as possible and avoid difficulties/conflicts in version systems.

We should try to identify if we have any further needs that aren’t met by our widget framework of today. As it’s a great system, we should really try to cling on to it and keep developing it (as we have up until today).

Testing the PureMVC framework

Flash & Flex March 6th, 2009 @ 11:03

Objective

Testing the PureMVC framework.

Evaluation

I decided to test using the PureMVC framework in a small application in order to find its pros and cons.

As I had tested setting up the framework once before (in another project), it wasn’t really a big deal installing it and creating my first classes. Also, after having spent a few hours reading the PureMVC documentation and best practices, I already had knowledge on how the system worked.

Result

After completing the application, I’ve found both pros and cons with the implementation of PureMVC.
(Please note that I haven’t taken other pros/cons to consideration here, such as how often the framework is updated, community size etc.)

Pros

  • A clear structure for Models, Views and Controllers – the roles of each part is quite easy to understand and make use of.
  • Good use of Controller part of MVC, which usually is difficult to put in the AS equation. In PureMVC, the Controller is a “Command” instructing the application on what to do next (i.e. to register Proxies/Mediators).
  • Good and clear separation of “true” View and Model via Proxy and Mediator – makes it easier to let the View actually “be a View” and Model “be a Model”. The View component (i.e. an actual MovieClip) is manipulated through the Mediator and the Model (i.e. a data object, such as a Player) is manipulated through a Proxy. This ensures that no logic is misplaced in the View component.
  • Nice being able to access Proxies, Mediators etc through the ApplicationFacade from wherever. Allows for Commands to be quite complicated if needed.

Cons

  • All Mediators, Proxies and Commands are registered using a unique key. Hence, there are some difficulties keeping track of Mediators/Views (“M-V”) that are unique for the Proxy’s data object, i.e. the M-V of a certain “Player” with a certain “id”. Perhaps M-V:s should only be implemented for functionality that will only require a single instance of its type?
  • Could be troublesome to keep track of the dependencies etc in the notification system, although the references can quite easily be searched using an IDE. This is probably an issue no matter which system being used.

Other observations (not necessarily to be considered as either pros or cons)’

  • The PureMVC “pattern” needs to be implemented all the way, meaning that the view (component) cannot contain any functionality to affect the world outside of it. A mediator’s “view component” must be completely isolated.
  • Setting up a new class requires some manual labor (as some classes needs to be extended/interfaces implemented), i.e. specifying which events to listen to and how it affects the class

What do I need to know to get started?

It takes a little effort to learn the system and understand what its parts do; i.e. what a Mediator is and how it correlates to the actual View. But once you understand the system, it’s really easy to create new classes for your application.

A few vital things that need to be understood before using PureMVC (I’ll try to sum it up, but the official docs are recommended):

  • What are Notifications? All Mediators, Proxies and Commands listen to notifications specified by the user. If a certain Mediator should display a message at a certain time, it will listen for a notification of that type.
  • What the Mediator is and why it’s being used: it’s basically a layer to the actual View (MovieClip), handling all functionality related to the other parts of the application (i.e. outside of the View)
  • What the Proxy is and why it’s being used: works in the same way as a Mediator, but in a more simpler way. Manipulates the “true” model object, which could be a domain object such as a “Player” or “Table” in a card game application.
  • Where is the Controller? The controller is implemented as a Command, meaning that it’s invoked when a certain notification is sent. Once invoked, it has no function until the notification is sent again.

Conclusion

In my point of view, PureMVC is a good framework to use for MVC applications. It can get a bit complex with boilerplate code, though.

References