Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • thanks for your response. In a multi-user desktop scenario, each user would run the application on their own system and so the view could still be a singleton? In a web context, I'm not that experienced, but imagine you could still have a singleton if each user is given their own process on the server. Commented Feb 4, 2013 at 8:58
  • Yes, in your case, the view can be a singleton, barring multiple stateful views opened by the same user on her desktop. But beware view reuse, as reinitializing views just to recycle singletons can get messy. Either way, don't let your view consumers (controllers and what have you) know that they are singletons. Best to hide that detail behind a registry or a factory. Focus closely on what the view must promise about its lifecycle (e.g., that there's only one at any given time, e.g. due to statefulness, multiple users) and that pretty much tells you if it can be a singleton. Commented Feb 4, 2013 at 18:42