Abiola_Lapite's photos More of Abiola_Lapite's photos

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

October 29, 2005


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.


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

design patterns explained

The comments to this entry are closed.

Notes for Readers