Hi,
I've been searching the forum about this and there are TONS of topics. Yet I somehow can't really decide what is right or wrong.
Let's say I want to use a Facade like in Andrews book. My Data-class implements the interface provided by Sun, but has two worker-classes; one for locking(LockManager) and one for handling the file(FileManager). So in every method in Data.java, I call the appropriate methods in my worker classes. So far so good.
But lets say I want to go with the Singleton approach instead. I've read a lot of topics in here, and to simplify things I think using Singleton is the best approach for me. I want to keep things simple. Now I know I could make the Data-class a Singleton and the have all my logic directly in this class, both filehandling and locking. I would synchronize on the locks(HashMap) and probably the file too(RAF).
But what if I still want to go with the Facade pattern? Should I then make my worker classes Singletons too or is it enough to just make the Data-class a Singleton? I'm puzzled by this and can't really decide what is right or wrong.
Thanks in advance.
[ November 29, 2007: Message edited by: Allan Smith ]
I've been searching the forum about this and there are TONS of topics. Yet I somehow can't really decide what is right or wrong.
Let's say I want to use a Facade like in Andrews book. My Data-class implements the interface provided by Sun, but has two worker-classes; one for locking(LockManager) and one for handling the file(FileManager). So in every method in Data.java, I call the appropriate methods in my worker classes. So far so good.
But lets say I want to go with the Singleton approach instead. I've read a lot of topics in here, and to simplify things I think using Singleton is the best approach for me. I want to keep things simple. Now I know I could make the Data-class a Singleton and the have all my logic directly in this class, both filehandling and locking. I would synchronize on the locks(HashMap) and probably the file too(RAF).
But what if I still want to go with the Facade pattern? Should I then make my worker classes Singletons too or is it enough to just make the Data-class a Singleton? I'm puzzled by this and can't really decide what is right or wrong.
Thanks in advance.
[ November 29, 2007: Message edited by: Allan Smith ]