views:

43

answers:

2

I'm preparing to reorganize & refactory a Flash Builder application. The goals of the reorg are 1.) keep compile times for the part of the project I'm working on as fast as possible, 2.) keep the unrelated parts separate for code reuse. Goal #1 trumps goal #2 if there's a trade-off.

Currently, the app has assets in one project, core functionality AS3 in another project, and the MXML in a third project that links to the other two.

Would moving resources/code into swc libraries help compile time? What about compiling assets into an swf and embedding that into the main application? Any other techniques?

A: 

We had the same problem, application compile time was more than 1 minute.

Here is our solution:

  1. There is a Core Library that contains class Core with static properties like: Core.resourceManager:IResourceManager, Core.stringManager:IStringManager, etc.
  2. Main application project includes Core Library and provides implementation for all Core.someProp. This can be done via some hidden method like Core.setImpelentation().
  3. There are unlimited number of Modules that use Core Library to contribute their display / logic to the application. Important:
    1. Each Module is a separate Flash Builder project
    2. Module link Core Library as external (it's included in Main App)
    3. Module has XML-file that describes it, example it's name and icon in application control bar. It allows not to load all modules at start.
    4. User should be able to choose which modules he would like to use. This will also help you in development.
  4. You can optionally create Lib Library and include in it all classes that are common between modules and can be implemented using Core Library.

The result is incredible - you application becomes low-coupled, open/compile time decreases, APIs become more clear. Profit!

Maxim Kachurovskiy
A: 

Modules are definitely the way to go here, as Maxim has described. Further to his advice, which is all solid, here's some other tips:

  • Extract styles out to a separate project, and compile the .css to a SWF. Load the SWF at runtime.
  • Structure your packages by business function first, MVC role second,

    Eg: Rather than com.myapp.model.userconfig.UserOptions, use com.myapp.userconfig.model.UserOptions. Enforce that packages can only reference their siblings, or com.myapp.core.*.

    This way, each package is a self contained module, which only references itself, or the core library.

  • Consider the Hellfire Compiler, which can farm your compilation over several CPU's in parallel
  • If not already, consider moving to the Flex 4 SDK, which has several compiler performance improvements, especially around compiling multiple SWC's.
Marty Pitt