Singletons and other design issues
Posted
by
Ahmed Saleh
on Stack Overflow
See other posts from Stack Overflow
or by Ahmed Saleh
Published on 2013-10-21T09:43:23Z
Indexed on
2013/10/21
9:54 UTC
Read the original article
Hit count: 250
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.
© Stack Overflow or respective owner