Skip to main content

Timeline for Do I need a singleton here?

Current License: CC BY-SA 3.0

4 events
when toggle format what by license comment
Dec 1, 2015 at 19:41 vote accept AGML
Nov 29, 2015 at 23:08 comment added Mats Petersson Then pass in the same object. My point is that a singleton can only ever be one - there's nothing preventing you from using ONE object always, even if it's stored as a reference in a dozen places. I had a similar issue when I created my Parser object in my compiler - I thought I only ever needed one, but I then needed to implement "Modules", which requires a "fresh" Parser. So sometimes, being able to create a second, third, fourth instance is helpful, and storing a reference to an instance typically costs less than calling a function that returns a static instance.
Nov 29, 2015 at 22:57 comment added AGML The problem with this is that multiple instances of the calculation might need the same matrix. Or is there a way around that?
Nov 29, 2015 at 22:17 history answered Mats Petersson CC BY-SA 3.0