views:

991

answers:

3

I have the feeling that is easy to find samples, tutorials and simple examples on Flex.
It seems harder to find tips and good practices based on real-life projects.
Any tips on how to :

  • How to write maintainable actionscript code
  • How to ensure a clean separation of concern. Has anybody used an MVC framework such as cairngorm, puremvc or easymvc on a real Flex project ?
  • How to fetch data from a server with blazeds/amfphp ?
  • How to reduce latency for the end-user ?
  • ...
+4  A: 

I work often with Flex in my job, and I will be happy to help.. but your questions deserve an article for each one :) I'll try some short answer.

Maintenable code: I think that the same rules of any other OO languages apply. Some flex-specific rules I'm use to follow: use strong typed variables, always consider dispatching events as the way for your UI components talk each other (a little more initial work, very flexible and decoupled later).

Frameworks: looked at it, read the documentation.. very nice, but I still feel that their complications are not balanced by the benefits they provide. Anyway I'd like to change my mind on this point..

Talking with server: Right now I'm using BlazeDS, it works very well.. there are many tutorials on the subject out there, if you find any trouble setting up it I would be happy to help.

Latency: Do you mean in client/server comunications? If so, you should explore the various type of channels BlazeDS implements.. pull-only, two-way http polling, near real-time on http (comet).. if you need more, LiveCycle Data Services ES, the commrcial implementation from which BlazeDS is born, among other things offer another protocol called RTMP, it isn't http-tunnelled so there can be problem with firewalls and proxies, but it offers better performance (there is a free closed-source version of LCDS). I use the standard http channels in intranet environments, and found no real performance problems even with large datasets.

Well.. quite a lot of stuff, can't be more specific now on each of this points, ask you if need :)

Cosma Colanicchia
Thanks for your responseAbout latency: I have an application with a homepage that needs data from many services. I have used before with DWR (ajax framework) to batch several service calls into a single httprequest. Do you know how to achieve this with flex ? http channel with a command pattern ?
Alexandre Victoor
Why should you batch commands in a single HTTP request? Usually you don't code against such low level details, you simply call your remoteobject methods (and use XML configuration to describe how to handle them). The simplest way could creating an ad-hoc service that gather all the data at once..
Cosma Colanicchia
+3  A: 

Here are a couple of great resources to do with Flex/AS3 best practices and standards:

Flex SDK coding conventions and best practices

Flex best practices – Part 1: Setting up your Flex project

The first one I found especially useful and I try to make sure any team I work with have all read it

defmeta
thanks a lot for these useful links !
Alexandre Victoor
A: 

I have found the MVC framework RIAWave http://ria.richtechmedia.com/flexsample/sample.rar">link to be absolutely incredible. It is super lightweight and easy to use. I found Cairngorm and PureMVC to have a pretty steep learning curve and they both feel a bit too bulky for me. RIAWave stays out of the way and just gives you the MVC basics to work with.

AMFPHP on the backend is very nice as well. AMFPHP also has an apache module that will take care of serializing/unserializing the sent and received data all in C which is blazing fast.

If latency is a worry, you will want to make sure you get a good webhost or even deploy to multiple data centers so that your users are never far from a server. Sounds like a bit early to be worrying about that though.