Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: 1 ... 6 7 [8]
106  Announcements and General Discussion / General Discussion / Re: the role of the singleton in puremvc on: February 01, 2008, 05:06:47
yeeeerrrrs,

hold on, thats not quite right ;~)

107  Announcements and General Discussion / General Discussion / Re: the role of the singleton in puremvc on: February 01, 2008, 04:19:52
thanks for answering... this is really just academic interest as to why you made your decisions the way you did (I find that coding is a compromise between performance/file size/code readability/dev history and even aesthetics.

this is how I might have considered doing it (and I'm not at all suggesting that its better, just a different set of compromises)

instead of having five singletons (M,V,C,Facade and outside the frame work - AppFacade), they could be boiled down to one (I'm going by the guideline of as few globals vars as poss)

so if the MVC and F are put in the same package, (eg org.puremvc.core) and put in the internal namespace (except for the F which is still public) only the F can instantiate them. This means that the F can control their creation, and since F is a singleton MVC are also.

Then, if instead of containing its own instance, the F contains the instance of its (Final) subclass ApplicationFacade (passed up in the constructor)

final class ApplicationFacade{
   
   public function ApplicationFacade(){

      super(this)
   }
}

public class Facade implements IFacade
   
   public function Facade (f:IFacade){

      if (instance != null) throw Error(SINGLETON_MSG);
      instance = f;
      initializeFacade();   
   }
}


What this means is that the singleton would be invisible outside the framework ( OK, the Facade.getInstance could still be invoked, but a custom namespace would solve that if neccessary).  The FacadeApplication would still throw an Error if there is an attempt to create more than one and the only getInstance() methods called are within the frame work when either a Proxy Mediator SimpleCommand or MacroCommand are created
108  Announcements and General Discussion / General Discussion / Re: the role of the singleton in puremvc on: January 31, 2008, 05:55:30
having the Abstract Facade manage its concrete subclasses' unique instance also means that the subclass would not need to have its own singleton method...
109  Announcements and General Discussion / General Discussion / the role of the singleton in puremvc on: January 31, 2008, 05:11:58
I was wondering why you chose to have to Model, View and Controler classes as singletons??

because the facade is a singleton, and the 'best practice'  route is through the extended facade, then the facade can manage its MVC unique instances. It could also manage its concrete ApplicationFacade's unique instance, allowing access to it by the Notifier class.
Pages: 1 ... 6 7 [8]