2 Replies Latest reply on Dec 3, 2007 11:17 AM by m_hartnett

    Application architecture

    Zolotoj Level 3
      I am working on an app. that has a main app. window with tree control that is used to load other applications into the main window. I want to be able to reuse as much code as possible. For that I want to keep generic AS code in the main application. Also there are many data sources that in use by multiple applications. For example, a list of US states used for dropdowns.
      I would want to load this data into main application only once and then dynamically assign to data controls.
      Can someone share ideas of doing development in such facion? Any samples?

      Thanks in advance.
        • 1. Re: Application architecture
          JKohn99 Level 1
          There are of course lots of ways to do this. Our approach has been to use singleton classes to hold common data and common functions.
          The instance is declared as Static so there is only one copy.

          for example:
          public class SomeSingleton
          {
          private static var _instance:SomeSingleton;

          private var _someData:ArrayCollection;

          public function SomeSingleton()
          {

          }
          public static function getInstance():SomeSingleton
          {
          if(_instance == null)
          _instance = new SomeSingleton();
          return _instance;
          }
          public function set someData(v:ArrayCollection):void
          {
          _someData = v;
          }
          public function get someData():ArrayCollection
          {
          reuturn _someData;
          }
          }

          To use this anywhere in your flex app just get the instance and invoke it's methods.

          SomeSingleton.getInstance().someData = new ArrayCollection();
          • 2. Re: Application architecture
            m_hartnett Level 3
            This may be too late but I almost always use Cairngorm micro architecture.
            It is a set of objects / design patterns that help to organize a flex application into an MVC design patterns.

            This has the concept JConn99 is talking about. A single modelLocator.

            If you are not already deeply involved in your current architecture then I would give this a read. Here is a good article on Cairngorm and what it can do for you.

            http://www.adobe.com/devnet/flex/articles/cairngorm_pt1.html