title: Are Singletons really that bad?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons">What is so bad about Singletons?</a>  </p>
  </blockquote>
  
  
  
  <p>It's understandable that many design patterns can in some cases be abused, and like mom always said: "<em>Too much of a good thing isn't always good!</em>"</p>
  
  <p>I'm noticing that these days, I'm using Singletons a lot, and I'm worried that I might be abusing the design pattern myself, and running deeper and deeper into a bad-practice kind of habit.</p>
  
  <p>We're developing a Flex application that has a quite a large hierarchical data structure kept in memory while the user works on it. The user can load, save, change and refresh the data on demand.</p>
  
  <p>This data is centralized by means of a Singleton class, which aggregates a couple of ArrayCollections, Arrays, value objects and some other native member variables exposed via getters and setters.</p>
  
  <p>To get a reference to our data from anywhere in the application, we do the whole Model.getInstance() method type of thing, that I'm sure everyone is familiar with. This ensures that we always get our hands on the same copy of data, since when we designed, we said that only once instance is allowed to exist during the application lifetime.</p>
  
  <p>From this central data repository, it's then easy for us to for example, dispatch property changed events, and can have multiple UI components that reference the central data, update their displays to reflect the data changes that have occurred.</p>
  
  <p>So far, this approach has been effective and proven very practical to our circumstances.</p>
  
  <p>I'm finding however, that I'm a little overeager when creating new classes. Questions like should a class be a Singleton, or should it rather be managed some other way, like maybe using a factory for example, tend to sometimes become a bit difficult, with a bit of uncertainty.</p>
  
  <p>Where do I draw the line with singletons? Is there a good guideline for deciding when to use Singletons and when to stay away from them.</p>
  
  <p>Also, can anyone recommend a good book on design patterns?</p>