Head First Design Patterns
(Picturefrom Amazon)

Sometime you just write code without fully understanding the meaning. Like design pattern, maybe you already know part of them even use them very well. “Head First Design Patterns” is a good book, it use a story to let you know why you must use this pattern (some of us may not know forever).

As this chapter “Singleton pattern”, I have already used it in my code everywhere. But I can not get fully understand why we have to use this, how to use this and how to prevent other this in multiple threading programming.

I list a example fot singleton implementation.

class CSingleton { public:  static CSingleton * getInstance(); public:   void f1();  void f2();  void f3(); > > private:  virtual ~CSingleton();  CSingleton(); > > private:  static CSingleton *m_uniInstance; }; > >

Buy Me A Coffee


Attitude is everything