开发者

What is the purpose of a ModelLocator Singleton in ActionScript

开发者 https://www.devze.com 2023-04-08 19:39 出处:网络
The use I have for it is for storing user credentials, and calling a transfer object that functions as a sort of \"cache\" for the current session in all of the flex modules.

The use I have for it is for storing user credentials, and calling a transfer object that functions as a sort of "cache" for the current session in all of the flex modules.

Thinking about objects that have to be present in every module. Is开发者_StackOverflow there any alternative to a singleton instance for this?


Yes! Automated dependency injection frameworks, such as Mate, Robotlegs, Parsley, or Swiz. Check out http://www.developria.com/2010/06/robotlegs-for-framework-beginn.html and http://www.developria.com/2010/05/mate-for-framework-beginners.html for a more in-depth look about how two of these work.

For just a few reasons you should avoid Singletons, see http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars

0

精彩评论

暂无评论...
验证码 换一张
取 消