Finalizer, Dispose, Close

Designing .NET Class Libraries: Designing for a Managed Memory WorldDesigning .NET Class Libraries is very good place that I am used to go here and study something anout .NET Framework. I also like Brad Abrams very much, because hi usually use very simple example to explain such hard thing like “dispose”, “finalizer”, “Manage code”, “CLR” … . In the speechDesigning for a Managed Memory WorldBrad Abrams focus on “Gabage Colloection”, and talking about finalizer (seems he like this word more than destructor) , dispose( I think dispose is new concept in .NET framework, but it really hard to use it well).

He also talk about try {} ,excption{} and_ finally {}_ to manage the memory well. Nested use try{} finally {} can make exception more clear and can handle more condition even we don’t think it will happen.

static void CopyFile(file sourcdeFile, file destFile){ > > try { > >     OpensourceFile(sourcdeFile); > >    try { OpensourceFile(destFile);  } > >    finally { CloseFile(destFile); } > >    } > >  finally { CloseFile(sourcdeFile); } > > } > >

Important concept about GC (Gabage Collection) is when dispose, close, finalize call? The anwser is use code to call dispose and close; but GC will call finalize when this object should be collection back.

The scope bug of “for loop”

Route 64 - Kang Su Gatlin talks about 64-bit對於for loop的使用,相信大家跟我一樣,總是習慣去撰寫

for(int i=0; i<5; ++i) { > > ....... > > } > > cout << i ; > >

但是,若是根據以上的程式,利用VC6或是BCB會看到哪樣的ouput i?很簡單~~就是 i = 5,但是正常來說,i 的scope 在哪裡??

i 應該是在for 之內的,所以他的生命週期(scope)應該也是在其中,但是由於VC++與BCB的錯誤,此得i 的scope 變成了for 之外,造成許多程式的問題。

解決方式: #define for   if(0); else for

參考網站: BBS文章,參照侯捷老師上課內容

Interesting bug in VC6

Route 64 - Kang Su Gatlin talks about 64-bit最近在做VC6轉換VC7的時候,倒是慢慢發現VC6的一些bug,舉例來說,看一下下面的範例程式:

 if (int i)  {     i = 1;  } > >

在VC6只會得到一個warnning:

warning C4700: local variable 'i' used without having been initialized > >

但是由於Constructor 通常不會有回傳值(return value),所以基本上在if() 不應該有變數的起始。所以這樣的code在GNU C++會發現是無法compiler過的~~~

當然VC7 修掉了這個嚴重的bug,你可以看到出現:

error C2059: syntax error : ')' > >

蠻有趣的bug,不過~~~ 若有人這樣寫code 可就慘了,因為雖然constructor沒有回傳值(return value),但是在VC6中, if (int i)卻是判斷為true~~~ 這樣可能是與原來的想法會有點出入~

所以有時候利用VC7來compiler一下現在的code,也是一個好主意。

SomeTools for Visual Studio .NET

Designing .NET Class Libraries: API Usability由於工作上的關係,最近有許多機會可以接觸到.NET Framework的相關開發工具與書籍,再此先介紹一本可以了解.NET Framework概觀的書籍(Applied Microsoft .NET Framework Programming)。

搜尋網路上的一些相關資料,MSDN也提供了一些Visual Studio.NET Framework開發上的工具,當然如果對於反組譯有興趣可以查看反組譯的文章,也可以查看ILDASM is Your New Best Friend 或是Ildasm.exe 教學課程

遠端偵錯方面,檔案在 C:Program FilesMicrosoft Visual Studio .NET 2003Common7PackagesDebugger下可以找到,但是遠端連線軟體,mcvcmon 似乎一定要 mcvcmon.exe -anyuse -tcpip 才能正確執行,詳細可以查看使用遠端偵錯監視器進行遠端偵錯

Google Maps vs MSN Maps

Go to Google Maps Home

Google在最近也提出了地圖的服務(Google Maps),當然很久之前MSN也提供了相似的服務(MSN Maps),比較一下兩者在地圖上面的服務比較。我比較喜歡Google Maps比較直覺性的查詢方式,你可以利用滑鼠上、下、左、右移動著地圖(順便一提,Google Maps的顯示速度相當快速),並且在上面的Search bar 內填入你想尋找的keyword,他就會根據你現在顯示的地圖裡面,找出你想找的地點,加以標示起來。比起MSN Maps我認為Google Maps提供了更直覺性的方式來找地圖,希望很快滴~也有美國以外的地圖可以提供~~~~

**參考網址:
**Curiosity is bliss他的文章Maps.google.com beta有很多值得一看的內容。

Yahoo Blog 360 degree

Yahoo!

令人驚喜的,Yahoo也推出了他們的Blog功能– Yahoo! 360°。號稱整合Yahoo Messager、網路相本與網路收音機的功能,除了這些功能以外~~~~~

**他需要被邀請才能試用~~** > >

沒錯! Gmail 這套,Yahoo也學會了,你必須上Yahoo! 360°的網站,打入自己帳號之後,申請Waiting List~~~

而我~~ 也在等待之中~~~~ 反正很少的東西,等到了~~才有價值嘛!

如果等到會發給各位邀請函,就請各位幫我祈禱吧~~~