Stephan Bergmann wrote:
Frank Schönheit - Sun Microsystems Germany wrote:

But is OfficeResourceLoader a service or a singleton?

It needs to be, since it cashes the obtained resource bundles.


I have state, therefore I am!  :)

Honestly: needs to be what? (Caching might for example be done across multiple service instances, or a service implementation might behave as a singleton, by always returning the same instance for createInstance. "What do we need singletons for in UNO, then?" you might ask. "Well, I have no idea" I would confess.)


I think they were intended to get rid of the old 'single-instance' services, because they have problems of their own. If I ask the system to "create [an] instance" for me, I expect to get an object that was created just for me, which I own and which I should dispose() when I'm done with it. If the service instance is silently shared, then disposing it can break other users, but not disposing it (if it supports XComponent) is likely to leak resources.

(Been there, done that. The configuration service is one example of this problem, uses complicated tricks to get lifetime management half correct now, and I've been thinking about ways to get out of this mess without breaking existing clients for a while.)

Thinking about it: it used to be common practice (at least that is my impression) to name (old style) singletons with "the." However, it was also the case that there always was an old style service Foo together with an old style singleton theFoo of type Foo. With a new style singleton of type XFoo, there no longer is a need for any service Foo, so, yes, why not go forward and no longer prefix new style singletons with "the"---what do others think?


FWIW, I like the 'the', because it expresses the fact that there is this one special instance. And staying with naming conventions is a good idea, even if the technical reason is gone.

-- Jörg


--
Joerg Barfurth           phone: +49 40 23646662 / x66662
Software Engineer        mailto:[EMAIL PROTECTED]
Desktop Technology       http://reserv.ireland/twiki/bin/view/Argus/
Thin Client Software     http://www.sun.com/software/sunray/
Sun Microsystems GmbH    http://www.sun.com/software/javadesktopsystem/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to