[ACCEPTED]-MVVM ViewModels Singleton-mvvm

Accepted answer
Score: 11

Yes because singletons are evil.

You will probably run into 5 issues where the VMs are holding onto state 4 which could be out of sync with your database 3 and lead to excessive memory consumption. It 2 will be much harder to unit test due to 1 the state being persisted.

Score: 5


  • make testing harder
  • give you problems later if you do need more than one of them
  • are hard to control where they are created

So only use the singleton pattern 2 if you have a very good reason to do so - "because 1 you can" is not a good reason.

Score: 2


First, you may very well be putting yourself 9 in a corner for any extensibility, depending 8 on the singleton implementation. Second, the 7 design probably won't be very clean referring 6 to static singletons everywhere. Third, unit 5 testing will either be difficult or it won't 4 replicate actual class usage, or both. Forth, do 3 having singletons solve any design problems 2 for you? If you are simply trying to save 1 on resources then I would just forget it.

More Related questions