After working on two big applications in flash I have realized that with normal modular approach it’s not easy to manage thousands of lines of code. This is a nightmare if there are multiple programmers working on the same application. When I was working for a big project called Thunder, we had a really really tough time integrating the code from different programmers (Keep in mind that the flash application had more than 50K lines of code). At that time though Flash was not that grown up, I believe that we could have worked more on architecture design to make it more manageable. But the problem was as usual the crazy rush of finishing the product that made us take quick decisions which were not healthy enough for the application to make it easily manageable.
Here I want to talk about extendability and manageabiltiy in an interactive application that contains rich animated UI elements and also server side interactions (either streaming media or database access).
To me the main challenge is to make application highly flexible such that when I want to change a particular part of the application I can create another file and just plug it to the main application. I am following MVC pattern for my current project (because it was coded that way earlier), but I have come to realize that I need more than MVC for interactive applications, especially if you want highly customizable architecture. Though I should confess here that I am not at all expert in MVC pattern, but I do get the motive behind it. Here is how I think an application can be broken down. (just the rough ideas)
1. Visual Unit: This Module will basically represent the data. Similar to “View” Module in MVC. But this is broken down more into two parts.
- UI : Just the graphics (loaded from external source)
- Interactive: Code implementation of interaction with a UI element ( UI element is passed to this module )
2. Logical Unit : This module gets the visual data from View and processes it or gets data from server side and tells Visual module to update itself with given data.
3. Backend Unit : As it says, this will interact with any kind of backend, e.g. streaming server or a database.
This looks pretty much like MVC, but there more things that I want to add. Any application should be customizable by any developers without changing the core of the application. So any flash application has to have some level of customizablity. And when I say customizability I mean a developer should be able to plug different modules, either new or replacing the old ones without actually touching the main code. Here is an example,
-> Suppose I have a video player that has a volume bar that acts in a certain way. Now, a volume bar itself can be made flexible so it can have different orientation or different graphics. But what if I want to add different kinds of volume controls.

So there has to be a flexible architecture within application to be able to do it.So the idea to do that is load the whole component externally including necessary code and any other required data. It’s pretty much like Dynamic Link Library (dll) concept. But since flash does not have dll concept we have to rely on external movie clip loading to do this. So in a way we can create something similar where we can load code from external source and use it.
Here are few questions that came to my mind before continuing with the dll idea in flash.
- How will a component talk to the main application
- How will a component resize and fit into the layout
- Does that component need external config file
To do this we will need to add new modules to the above architecure. Just to be modular I will post details of this implementation that I am working on in the next post. So stay tuned.
Another main issue to be addressed in rich interacrive application is synchronizing the events. There are cases where a particular function should be executed at the end of animation and not while the animation is going on. Or the UI should be updated only at the end of animation. So you have to synchronize UI with the data in two way data communication.
I am still discovering new things as I am learning new problems. I am not sure if I am reinventing the wheel, but for my ideas about extendability and manageability of code I think i need to work on this more.