I think its the terminology that is misleading. Managers (or Services / public APIs / facades) are usually singletons as they sit a layer above your domain model and provide an inteface for your client code.
If your BookmarkManager has state maybe it shouldn't be called BookmarkManager. Maybe just Bookmark? Alan ________________________________ From: Jared Rypka-Hauer <[email protected]> To: [email protected] Sent: Wednesday, February 18, 2009 5:46:36 AM Subject: [CFCDEV] Re: OO question, how should I model this? What's state got to do with Singleons? In fact as much as not that's exactly what Singletons are good for. How else are you going to have one-and-only-one-instance of a class for your application? Having more than one instance of your BookmarkManager up at at a time is going to be be really bad for your application, especially if it supports tabbed browsing or MDI (there's a term I haven't seen in a long time - multiple document interface). Otherwise when you add a bookmark, BookmarkManager has to synchronize itself with all the other instances of BookmarkManager. There's no reason to have more than one instance of each (unless your app demands it, which I dunno because you haven't given a lot of detail). Go read up: http://en.wikipedia.org/wiki/Singleton_pattern On Feb 17, 2009, at 5:53 PM 2/17/09, Henry wrote: > > BookmarkManager cannot be Singleton because it has states (i.e. a > collection of links, more specifically it shall be a Tree). > > Imagine there's a Browser table, and one row of it represents a > Browser. There's a field calls bookmarks (since a browser has > bookmarks), and it is a JSON representation of the collection of > links. > > That was the reason why I had BookmarkManager in Browser at the first > place. ... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
