There are already quite a few posts about Singleton-Pattern, but I would like to start another one on this topic, since I would like to know if Factory -Pattern would be the right approach to remove this "anti -pattern".
In the past, I used singleton quite a lot, as well as my fellow colleagues, as it is so easy to use. For example, the Eclipse IDE or better its workplace model also makes great use of singletones. This was due to some reports of E4 (the next big version of Eclipse) that made me start rethinking singleton.
The bottom line is that due to these singleton dependencies in Eclipse 3.x are closely related.
Suppose I want to completely get rid of all singletones and use factories instead.
My thoughts were as follows:
- hide difficulty
- less connection
- I have control over how many instances are created (just save the link I have a private factory field)
- mock factory for testing (with Injection Dependency) when it is behind the interface
- In some cases, factories may have more than one singleton outdated (logical / component composition depending on the business)
It makes sense? If not, indicate why you think so. An alternative solution is also being evaluated.
thanks
Mark
source share