Flickr

  • www.flickr.com
    Abiola_Lapite's photos More of Abiola_Lapite's photos

« HapMap Hype and Reality | Main | Adventures of a Japanese School Teacher »

October 29, 2005

Comments

Dan Phillips

[a lack of awareness of this issue is yet another pointer that most of those who use this pattern don't know what the hell they're doing]

Further to that point, even the code in the updated link has problems. In order to avoid performance problems when getting the instance of the Singleton, he develops some fancy, lazy versions. But they lack understandability. They contain implicit assumptions about the virtual machine. It's hard to tell what is going on in them just by looking at them.

Abiola Lapite

Yes, you're right about the "performance optimized" versions - they're just begging for some future revision to the CLR to break them. That said, anybody who used them rather than the simple lock before actually bothering to profile their code would be guilty of the even more grievous sin of premature optimization, and I suspect that in most cases where a singleton really is called for, such optimizations won't even be necessary.

Steve

Great post. Totally agree. I just read a great book on patterns - fantastic introduction for newbies regarding patterns...

design patterns explained
http://www.amazon.com/exec/obidos/tg/detail/-/0321247140/qid=1130679339/sr=8-5/ref=sr_8_xs_ap_i5_xgl14/002-6744784-0152863?v=glance&s=books&n=507846

The comments to this entry are closed.

Notes for Readers