« links for 2006-05-26 | 回到主頁面 | links for 2006-05-29 »

May 29, 2006

Head first design pattern--"Singleton pattern"


將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati

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;
};




VC6相關問題

由 Evan 發表於 May 29, 2006 將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati
引用
本文的引用網址:


以下是前來引用的連結 'Head first design pattern--"Singleton pattern"' 來自 Blog E
迴響
發表迴響









記住我的資訊?




(請輸入以下的驗證碼)