How to create a manager class without global variables nor singletons?

Posted by Omega on Programmers See other posts from Programmers or by Omega
Published on 2012-12-17T19:13:54Z Indexed on 2012/12/17 23:13 UTC
Read the original article Hit count: 116

Filed under:
|
|

I would like to implement some kind of manager class in my application. It will be in charge of loading textures, processing them, distributing them etc...

At first, I wanted to make a global variable that simply contains an instance of my manager class. I found this question: http://stackoverflow.com/questions/4646577/global-variables-in-java. However, the users there seem to recommend to never use global variables.

Fine then, I once heard about Singletons, so I though I could use that instead. I mean, creating just one instance of my manager class sounds good. However, I found this other question: When is Singleton appropriate?, which basically tells me that Singletons are, in most scenarios, some kind of anti-pattern.

Now I am a bit lost - what other approach can I take to create my manager class, whose only requirement is to be accessible from anywhere?

© Programmers or respective owner

Related posts about java

Related posts about design-patterns