On 19/01/2017 15:51, Siemen Baader wrote:
Wouldn't a class instance variable be better? I want new singletons for every subclass. http://rmod-pharo-mooc.lille.inria.fr/MOOC/Slides/Week3/C019-W3S03-Basic-Var...
I use a class variable because I try to avoid a maximum the use of the Singleton pattern. Most of the time it is wrongly used and it make things harder to maintain in a long time. So I do not want a whole hierarchy of Singleton :) (For some reasons about why Singletons are evil you can easily find articles on internet. I looked quickly and found this for example: https://blogs.msdn.microsoft.com/scottdensmore/2004/05/25/why-singletons-are...)
I would also have used super new, why BasicNew? But my wish to create subclasses seems to answer that already.
When I do Singletons I change the new method to raise an error but I let the developer use #basicNew in order to not forbid him to create a second class if he knows what he's doing. With that we can test the singleton with another instance that the one the application use.
Thanks for your find-grained example, Cyril!
You're welcome :)
Siemen
-- Cyril Ferlicot http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France