Serge
Serge

Reputation: 1601

Asynchronous application design

I am building an app in ActionScript 3, that:

Whats the best practice for dealing with all the possible states of an application, and coordinating all the callbacks from completed threads, such as a web service request?

For a simple app, storing a few properties in an App's Singleton does the job. However for a more complex app, the complexity of such tracking grows in a geometric progression.

Example: to enable a particular button, three web requests should complete, two of them are sequential, one uses results from the previous, after both are complete, a panel should appear using slide animation. If a user decides to cancel the procedure during the web requests or the animation phase, he should be able to do so, by hitting another button. And there are dozens of pieces of this kind, with varying logic and requests. So far I am doing this with callbacks and App's Singleton variables. The number of callbacks grows dramatically.

Planning such an app becomes quite difficult. Please also advice a way to sketch such logic and dependencies in a schematic way? I'm not used to UML yet, plain algorithm schemes are more familiar to me.

Upvotes: 2

Views: 180

Answers (1)

net.uk.sweet
net.uk.sweet

Reputation: 12431

My advice would be to spend some time looking at a couple of the more popular MVC based frameworks for ActionScript 3.0. These have been designed specifically to service the kind of requirements you detail in a highly decoupled way and with the use of best practices.

I've been using PureMVC for a few years now and have found it to be light, flexible and intuitive. It also has the advantage of being incredibly well-supported (its author is heavily involved in answering questions on the forums), and knowledge of the framework is transferable as it has been ported to a variety of other languages (JavaScript very recently).

A good framework will make a lot of the fundamental architectural decisions for you and leave you free to concentrate on the implementation. With a little bit of investment up-front in understanding the framework, planning applications such as the one you describe becomes much easier as you will be able to look at the requirements and immediately start mapping them to the various actors of your chosen framework.

Upvotes: 3

Related Questions