<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.NET</title>
        <link>http://geekswithblogs.net/pvidler/category/14.aspx</link>
        <description>.NET</description>
        <language>en-GB</language>
        <copyright>Pete Vidler</copyright>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Why No Dispose Event?</title>
            <link>http://geekswithblogs.net/pvidler/archive/2003/10/20/227.aspx</link>
            <description>&lt;p&gt;We all know about resource management in .NET (and Windows Form in particular). I'm talking about &lt;font face="Courier New" size="2"&gt;using&lt;/font&gt;, &lt;font face="Courier New" size="2"&gt;IDisposable&lt;/font&gt;, etc. These constructs work well when you own all the objects that you keep references to, as you simply dispose of each of them from your own &lt;font face="Courier New" size="2"&gt;Dispose&lt;/font&gt; method.&lt;/p&gt;
&lt;p&gt;But what if you have an object that wraps another object (similar to the &lt;a href="http://www.dofactory.com/Patterns/PatternDecorator.aspx"&gt;decorator pattern&lt;/a&gt;)? A &lt;font face="Courier New" size="2"&gt;Decorator&lt;/font&gt; must contain a reference to a &lt;font face="Courier New" size="2"&gt;ConcreteComponent&lt;/font&gt;, but what happens when the &lt;font face="Courier New" size="2"&gt;ConcreteComponent&lt;/font&gt; must be &lt;font face="Courier New" size="2"&gt;Dispose&lt;/font&gt;d? Surely we would want &lt;font face="Courier New" size="2"&gt;Decorator&lt;/font&gt;'s lifetime to be tied to that of &lt;font face="Courier New" size="2"&gt;ConcreteComponent&lt;/font&gt;? How does &lt;font face="Courier New" size="2"&gt;Decorator&lt;/font&gt; get disposed? There wouldn't be a problem if we could guarantee that &lt;font face="Courier New" size="2"&gt;Dispose&lt;/font&gt; would be called on &lt;font face="Courier New" size="2"&gt;Decorator&lt;/font&gt;, but what if we want to be able to remove the &lt;font face="Courier New" size="2"&gt;Decorator&lt;/font&gt; and keep the &lt;font face="Courier New" size="2"&gt;ConcreteComponent&lt;/font&gt; alive?&lt;/p&gt;
&lt;p&gt;If we had a "Dispose" event, &lt;font face="Courier New" size="2"&gt;Decorator&lt;/font&gt; could just handle it and dispose of itself when necessary. But we don't. Why not -- we have events for everything else don't we?&lt;/p&gt;
&lt;p&gt;As a more concrete example, consider my recent posting about &lt;a href="http://geekswithblogs.net/pvidler/posts/201.aspx"&gt;Tablet PC support&lt;/a&gt;. It's quite easy to derive from &lt;font face="Courier New" size="2"&gt;Panel&lt;/font&gt; and add Inking to it, but it's not so easy to add that support from outside the class. In order to do this you could write a separate class (which will contain the &lt;font face="Courier New" size="2"&gt;InkOverlay&lt;/font&gt;) and pass a &lt;font face="Courier New" size="2"&gt;Panel&lt;/font&gt; object to it's constructor (like in decorator). The problem here is that, from my new class I have no way of knowing when Panel has been disposed of -- which would be nice as the &lt;font face="Courier New" size="2"&gt;InkOverlay&lt;/font&gt; object implements &lt;font face="Courier New" size="2"&gt;IDisposable&lt;/font&gt; itself.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=227"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=227" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/227.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2003/10/20/227.aspx</guid>
            <pubDate>Mon, 20 Oct 2003 17:32:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/227.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2003/10/20/227.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/227.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/227.aspx</trackback:ping>
        </item>
        <item>
            <title>Syntax Colouring of Posted Code</title>
            <link>http://geekswithblogs.net/pvidler/archive/2003/10/18/212.aspx</link>
            <description>&lt;p&gt;In case anyone was wondering, I've been using &lt;a href="http://weblogs.asp.net/jkey/"&gt;Jeff Key&lt;/a&gt;'s excellent &lt;a href="http://www.sliver.com/dotnet/SnippetCompiler/"&gt;SnippetCompiler&lt;/a&gt; to write all the code in this blog. The big advantage with this approach is that I can just select "Export-&amp;gt;Html Page..." and copy-paste the resulting HTML.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=212"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=212" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/212.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2003/10/18/212.aspx</guid>
            <pubDate>Sat, 18 Oct 2003 15:04:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/212.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2003/10/18/212.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/212.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/212.aspx</trackback:ping>
        </item>
        <item>
            <title>Exceptions</title>
            <link>http://geekswithblogs.net/pvidler/archive/2003/10/14/179.aspx</link>
            <description>&lt;p&gt;Looks like it's the season for talking about exceptions. &lt;a href="http://blogs.gotdotnet.com/brada/"&gt;Brad Abrams&lt;/a&gt; discusses them &lt;a href="http://blogs.gotdotnet.com/brada/PermaLink.aspx/c9c61dbf-62a9-474f-a5fe-c171cdedb4f6"&gt;at some length&lt;/a&gt;, and now &lt;a href="http://www.joelonsoftware.com/index.html"&gt;Joel Spolsky&lt;/a&gt; does &lt;a href="http://www.joelonsoftware.com/items/2003/10/13.html"&gt;the same&lt;/a&gt; (and with almost the exact opposite opinion).&lt;/p&gt;
&lt;p&gt;I seem to be cursed with the ability to see both sides of this issue. On the one hand, I like being able to throw an exception whenever an impossible condition comes up in running code (you know, when that if-statement you put in "just in case" goes off completely unexpectedly). On the other hand, I hate having to deal with exceptions being thrown... trying to make my code completely exception safe is very annoying.&lt;/p&gt;
&lt;p&gt;And there's nothing exceptional about calling &lt;font face="Courier New" size="2"&gt;File.Open&lt;/font&gt; with a non-existent file.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=179"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=179" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/pvidler/aggbug/179.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Pete Vidler</dc:creator>
            <guid>http://geekswithblogs.net/pvidler/archive/2003/10/14/179.aspx</guid>
            <pubDate>Tue, 14 Oct 2003 18:18:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/pvidler/comments/179.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/pvidler/archive/2003/10/14/179.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/pvidler/comments/commentRss/179.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/pvidler/services/trackbacks/179.aspx</trackback:ping>
        </item>
    </channel>
</rss>