The Singleton pattern might be a good idea at first, but be cautious about maintainability in the future. Accessing a Singleton is much like accessing a global variable and introduces many of the same problems.
For example, it can be difficult or tricky to unit test a class that loads a Singleton dependency on it's own. Instead, you'll want to inject that dependency using the constructor or a setter method. Singletons, like global variables, also introduce "hidden" dependencies. In other words, it's not obvious the class Foo depends on Singleton class Bar without looking through the source of Foo. This can make maintenance and reuse difficult. Generally I try to avoid singletons like the plague for the reasons above. To avoid creating duplicate instances, create it once (usually in a controller or, better yet, using an action helper) and inject it into whatever objects will need it. I hope this helps :) -- Hector Virgen Sent from my Droid X On Nov 29, 2010 6:28 AM, "Serkan Temizel" <serkantemi...@gmail.com> wrote: > Do you think is it a good idea making models singleton? > > On my project I need *users *model object many times. I call it in the > controller, in some plugins and in some view helpers. > > Making it singletone, I think will improve performance but can't figure out > drawbacks. > > Thanks