This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Well, thanks for thr reply. My application is a complex one in JADE where I am developing a multi agent system. So, I can't really create a new class that binds everyhting togther (although its the ideal way to do it).
But how do I solve my problem?
Class RecruitmentOfficer creates an object of JobsDB. JobsDB has a hashmap.(the only hashmap for the whle application).
OperationsManager agent wants to access this hashmap and make some searches in it. How can OperationsManager get a hold of the Hashmap?
author and iconoclast
Well, although I think the Singleton pattern is overused, that's really what you're asking for here. If there's ever only supposed to be one JobsDB, then make it a static member of its own class, and put a static method in the JobsDB class which retrieves that one object. Now, you said another class creates that one instance, but perhaps you could let the JobsDB class create it itself?
Now any class that wants to get ahold of that one JobsDB instance just has to call "JobsDB.get()" to get it. JobsDB is a "Singleton class."
Joined: Jan 19, 2004
Thats interesting. I did study the Singleton pattern but this thought never occurred to me. Thanks a lot. I'll try it out right away.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com