Re: Singleton Considered Harmful?
Posted: Aug 28, 2007 8:21 AM
> This paragraph shows some confusion between a concept
> pt (singleton) and its implementation. Classloaders and
> JVM are valid only in the Java world. Singletons may be
> used (correctly or incorrectly) in applications using any
> type of technology: Java, C++, C#, Ruby, and so on. In
> every case except Java, the discussion of classloaders
> becomes meaningless. (Is there a message there for the
> Java designers? Why do classloaders even exist? Why should
> I, as a developer, even know of the existence of
> classloaders? I am not satisfied with the common
> explanations provided.)
You are correct that classloaders only apply to Java, but other technologies have their own gotchas in this area. In .NET if your application spans multiple AppDomains you will have the same problem (I think, some .NET person might tell me I am wrong). If you are using C++ and an application framework like Tuxedo, business components can be distributed across a number of separate processes, which will also give you multiple instances of a Singleton. Therefore the problem of understanding the impact that deployment has on your design does not go away if you move away from Java.