Singletons and other design issues
- by Ahmed Saleh
I have worked using different languages like C++/Java and currently AS3. Most applications were computer vision, and small 2D computer games. Most companies that I have worked for, they use Singletons in a language like AS3, to retrieve elements or classes in an easy way. Their problem is basically they needs some variables or to call other functions from other classes. In a language like AS3, there is no private constructor, and they write a hacky code to prevent new instances.
In Java and C++ I also faced the situation that I need to use other classe's members or to call their functions in different classes.
The question is, is there a better or another design, to let other classes interact with each others without using singletons? I feel that composition is the answer, but I need more detailed solutions or design suggestions.