Flex: static var or use flexGlobals.topLevelApplication?
In Flex 4, if I have something like user information that I want to be able to access from anywhere in the application, is it better开发者_JAVA百科 to create a class with static var for the info or to have the variables in the top level application and access via flexGlobals.topLevelApplication?
Creating class with a static var is more preferable from the architecture point of view than coupling your client class with your top level application implementation. But the best way is to inject value in your client instance using delegation or dependency injection library/framework.
精彩评论