Question on Good Architecture

Hey guys,

I have a quick question about architecture in flex. I have a virtual world project I am working on so once you are logged into the world, it brings you to the WorldView state. This is just an mxml component where I load the background and the avatar into the world. I am now in the process of adding interface items to the world. Currently, I have a .swc file with all of my interfaces that I put into my flex library. This gives me access to all of my interface objects. So what I am currently doing is creating an instance of each interface item in my WorldView.mxml file like this:


private var _globePanel:GlobeView = null;
private var _globePanelComp:UIComponent;

public function showGlobePanel(status:int):void
{
     // Check to see if the globe has an instance
     if(_globePanel == null)
     {
          _globePanel = new GlobeView();
     }
                
     // Check to see if the window is already open
     if(_globePanelComp == null)
     {
         // Set the position of the window
         _globePanel.loadGlobe(status);
                    
         _globePanelComp = new UIComponent();
         _globePanelComp.addChild(_globePanel);
         this.addChild(_globePanelComp);
     }
}

public function removeGlobePanel():void
{
    try
    {
        if(this.contains(_globePanelComp))
            this.removeChild(_globePanelComp);
            
        // Check to see if the window is open
        if(_globePanelComp != null)
        {
            while(_globePanelComp.numChildren > 0)
                _globePanelComp.removeChildAt(0);
            _globePanelComp = null;
        }
        
        if(_globePanel != null)
        {
            _globePanel = null;
        }
    }
    catch(e:Error)
    {
        trace("Error removing Globe Panel");
    }
}

This works fine, but as I was thinking about optimization, I had an idea I would like to run across other developers to get their opinion.

The idea is that instead of creating a variable for each interface object in the world view, should I create a separate component in flex called “InterfaceView” and add this component on top of the world component. Technically, it should work either way, but I’m looking to optimize my code as much as possible. I’m using the Pure MVC framework, so essentially, for every view that I have, I need to have a mediator as well. So I’m wondering if it is worth the time to create an interface component with a mediator or should I just simply add my interface items (created in flash) directly to my WorldView component? The downside is that the WorldView.mxml file will become a little larger than I hoped, though it will still be fairly easy to manage.Thanks in advance!

Will