posted 20 years ago
Among other things, the ServiceLocator holds "home" objects for various remote services. Part of the idea is to create only one home object for a given service saving a little time & memory compared to making new ones all the time. If you had multiple ServiceLocators, they would probably each hold one home for a given service, back to wasting that little bit of time & memory. So Singleton is a way to have ONE container that holds a reference to each home.
Plenty of people think singletons are rarely or never necessary and are badly overused. That could be true, but I like them for situations like this where you want to have exactly one of something. (Caution: we might get one per JVM or per class loader or something else not precisely equal to one, but it should be CLOSE and better than say a million of em.) ServiceLocator might have worked just as well with all static variables and static methods instead of a singleton mechanism.
Hope that made sense! Let us know if not!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi