<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Danny Thorpe &#187; Programming</title>
	<atom:link href="http://dannythorpe.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://dannythorpe.com</link>
	<description>Dream &#38; Deliver</description>
	<lastBuildDate>Tue, 07 Feb 2012 17:50:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Calculating Browser Client Height</title>
		<link>http://dannythorpe.com/2009/10/02/calculating-browser-client-height/</link>
		<comments>http://dannythorpe.com/2009/10/02/calculating-browser-client-height/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 22:14:04 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[web app]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2009/10/02/calculating-browser-client-height/</guid>
		<description><![CDATA[When you&#8217;re writing a rich Internet application (RIA) in HTML and JavaScript, sometimes you need to programatically place a DOM element relative to the right or bottom edge of the visible browser window. For example, if you want to popup a help balloon near an item of interest, you probably want to make sure that <a href='http://dannythorpe.com/2009/10/02/calculating-browser-client-height/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re writing a rich Internet application (RIA) in HTML and JavaScript, sometimes you need to programatically place a DOM element relative to the right or bottom edge of the visible browser window. For example, if you want to popup a help balloon near an item of interest, you probably want to make sure that the balloon is fully visible on the screen &#8211; not hanging off the edge of the screen, partially obscured.  I haven&#8217;t found a CSS way to accomplish that, but here are some tidbits I have found:</p>
<p>A quick web search on calculating browser window height reveals that different browsers have different ways to find the browser&#8217;s window client height.  In Netscape / Mozilla browsers, you can use window.innerHeight.  For IE, some sources suggest using document.body.offsetHeight, but I&#8217;ve found this falls short when the HTML content does not completely fill the browser window.  document.documentElement.clientHeight returns the actual window client height in IE.</p>
<p>The jQuery JavaScript library has some handy functions for calculating an element&#8217;s pixel location and pixel width and height, with or without consideration for borders, padding and margin.  $(&#8220;.myclass&#8221;).outerHeight() will give you the pixel height of the first element with a CSS class of &#8220;myclass&#8221;, including borders and margins.</p>
<p>$(&#8220;body&#8221;).outerHeight() returns the same value as document.body.offsetHeight, which will be less than the window height in a short HTML document and could be much larger than client height in a scrolling window.</p>
<div style="text-align:center;width:100%;"><div style="margin:0px 0px 0px 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-0861479594738165";
/* End of Post */
google_ad_slot = "6510912161";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2009/10/02/calculating-browser-client-height/" data-text="Calculating Browser Client Height"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2009/10/02/calculating-browser-client-height/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2009/10/02/calculating-browser-client-height/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2009%2F10%2F02%2Fcalculating-browser-client-height%2F&amp;title=Calculating%20Browser%20Client%20Height" id="wpa2a_4">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2009/10/02/calculating-browser-client-height/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software as Literature</title>
		<link>http://dannythorpe.com/2009/06/29/software-as-literature/</link>
		<comments>http://dannythorpe.com/2009/06/29/software-as-literature/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 19:18:15 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Glimpses]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[humor]]></category>
		<category><![CDATA[literature]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2009/06/29/software-as-literature/</guid>
		<description><![CDATA[If software programming logic and statements were viewed as literature, what form of literature would yours be? Novel: multiple independent story lines that you hope will eventually converge to make a point. Short story: a limited number of characters with only one point to make Essay: tell &#8216;em what you&#8217;re going to say, say it, <a href='http://dannythorpe.com/2009/06/29/software-as-literature/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>If software programming logic and statements were viewed as literature, what form of literature would yours be?</p>
<ul>
<li><strong>Novel</strong>: multiple independent story lines that you hope will eventually converge to make a point.</li>
<li><strong>Short story</strong>: a limited number of characters with only one point to make</li>
<li><strong>Essay</strong>: tell &#8216;em what you&#8217;re going to say, say it, then tell &#8216;em what you said</li>
<li><strong>Tragedy</strong>: everything that can go wrong usually does</li>
<li><strong>Sonnet</strong>: ornately crafted for no particular reason</li>
<li><strong>Ode</strong>: behold my skillz, and despair!</li>
<li><strong>Thriller</strong>: I&#8217;ve got a  bad feeling about this&#8230;</li>
<li><strong>Murder Mystery</strong>: when things go wrong, top priority is on placing blame</li>
<li><strong>Self-Help</strong>: You can do it!  Please do.</li>
<li><strong>Epic Saga</strong>: &#8220;Help! I can&#8217;t stop writing!&#8221;</li>
<li><strong>Technical Documentation</strong>: Useful bits hidden in a sea of jargon, surrounded by a narcoleptic field</li>
<li><strong>Government Bulletin</strong>: Technical docs sans useful bits</li>
<li><strong>Billboard</strong>: all flash, no substance</li>
</ul>
<p>Since I come from the school of &#8220;simple elegance&#8221;, I&#8217;d have to say that my ideal software&#8217;s literary equivalent would be</p>
<p><strong>Comedy</strong>: If you have to explain it, it&#8217;s not very good.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2009/06/29/software-as-literature/" data-text="Software as Literature"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2009/06/29/software-as-literature/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2009/06/29/software-as-literature/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2009%2F06%2F29%2Fsoftware-as-literature%2F&amp;title=Software%20as%20Literature" id="wpa2a_8">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2009/06/29/software-as-literature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Between EventHandler and EventHandler</title>
		<link>http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/</link>
		<comments>http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 20:36:24 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EventHandler]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/</guid>
		<description><![CDATA[Have you ever run into a situation where you need to bridge between code that uses the old custom EventHandler pattern for events and code that wants to use the new parameterized EventHandler&#60;&#62; code style? EventHandler style delegates are not assignment compatible with EventHandler&#60;&#62; delegates.  You&#8217;ll run into this if you&#8217;re writing a new API <a href='http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Have you ever run into a situation where you need to bridge between code that uses the old custom EventHandler pattern for events and code that wants to use the new parameterized EventHandler&lt;&gt; code style? EventHandler style delegates are not assignment compatible with EventHandler&lt;&gt; delegates.  You&#8217;ll run into this if you&#8217;re writing a new API that sits on top of older code.  You probably want to expose events in your new API using the newer EventHandler&lt;&gt; pattern, but you can&#8217;t easily wire up events from the old lower level code to fire events in your new API.</p>
<p>You could create an event handler method to catch each of the old style events fired by the old code and turn around and fire the corresponding new style event in your API, but who wants to write all that mind numbingly repetitive code?</p>
<p>There is a simpler way.  The two incompatible event patterns do have one thing in common:  the Invoke method.</p>
<p>But first, some background.</p>
<h3>Custom EventHandler Types, 1.0 Style</h3>
<p>In .NET 1.0 the pattern to define an event property was to define an EventArgs class to carry the arguments of your event and define an EventHandler delegate type which uses that EventArgs class as its args parameter.  Like this:</p>
<pre class="brush: csharp; title: ; notranslate">    public class ActivityCompletedEventArgs : EventArgs
    {
        public ActivityCompletedEventArgs(int resultCode, string result)
        {
            ResultCode = resultCode;
            Result = result;
        }

        public int ResultCode { get; private set; }
        public string Result { get; private set; }
    }

    public delegate void ActivityCompletedEventHandler(object sender,
                                                       ActivityCompletedEventArgs e);

    class Bar
    {
        public event ActivityCompletedEventHandler Completed;
    }</pre>
<h3>Generic EventHandler&lt;&gt; Types, 2.0 Style</h3>
<p>With the advent of generic types in .NET 2.0, the generic EventHandler&lt;&gt; parameterized type was born.  This parameterized EventHandler&lt;&gt; delegate type simplifies how you declare and use event handlers &#8211; you don&#8217;t have to declare a custom event handler delegate type to match your event args class every time you create a new kind of event.  This is exactly the kind of thing that parameterized types (aka generics) were created to solve. Like this:</p>
<pre class="brush: csharp; title: ; notranslate">    public class ActivityCompletedEventArgs : EventArgs
    {
        public ActivityCompletedEventArgs(int resultCode, string result)
        {
            ResultCode = resultCode;
            Result = result;
        }

        public int ResultCode { get; private set; }
        public string Result { get; private set; }
    }

    class Bar
    {
        public event EventHandler&amp;lt;ActivityCompletedEventArgs&amp;gt; Completed;
    }</pre>
<p>However, the downside is that EventHandler&lt;&gt; delegates are not assignment compatible with the old style non-generic EventHandler style delegates.</p>
<h3>The Invoke Bridge</h3>
<p>Both styles of event delegate have an Invoke method with a signature of (Object sender, EventArgs args), where EventArgs is the arguments class specific to this particular event.  You can use this point of commonality to convert between event styles without too much trouble.  The trick is to use the .Invoke method in one style of event as the callback method registered in the other style of event:</p>
<pre class="brush: csharp; title: ; notranslate">    class OldStyleClass
    {
        public event ActivityCompletedEventHandler OldStyleEvent;
    }

    class NewStyleClass
    {
        public event EventHandler&amp;lt;ActivityCompletedEventArgs&amp;gt; Completed;

        public void blah()
        {
            var obj = new OldStyleClass();
            obj.OldStyleEvent += new ActivityCompletedEventHandler(Completed.Invoke);
        }
    }</pre>
<p>The code above hooks up the events so that when OldStyleClass.OldStyleEvent fires, it will fire the NewStyleClass.Completed event.</p>
<p>The main catch to this technique (in C#) is that the reference to the event&#8217;s .Invoke method must be made from within the context of the class that defines the event. C# doesn&#8217;t allow access to the members of an event delegate outside of the class that defines the event. The rules may be different in other .NET languages.</p>
<p>If you want to use this technique in the opposite direction (to have a new style event fire an old style event), you will need to be able to modify the source code of the old style class that defines the old style event. This is much less common than making old style code to fire new style events.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/" data-text="Converting Between EventHandler and EventHandler"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2009%2F04%2F15%2Fconverting-between-eventhandler-and-eventhandler%2F&amp;title=Converting%20Between%20EventHandler%20and%20EventHandler" id="wpa2a_12">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Live Framework Webcast Monday December 8, 2008</title>
		<link>http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/</link>
		<comments>http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 18:53:33 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[Live Framework]]></category>
		<category><![CDATA[Live Services]]></category>
		<category><![CDATA[Mesh]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[webcast]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/</guid>
		<description><![CDATA[The Live Services team will be hosting a live webcast to discuss and demo Live Frameworks development topics next Monday December 8, 2008 from 8am to 10am PST (12am &#8211; 2am GMT).  This will be a great opportunity to listen in on technical topics on developing applications with Live Frameworks, both standalone desktop apps as well <a href='http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The Live Services team will be hosting a live webcast to discuss and demo Live Frameworks development topics next Monday December 8, 2008 from 8am to 10am PST (12am &#8211; 2am GMT). </p>
<p>This will be a great opportunity to listen in on technical topics on developing applications with Live Frameworks, both standalone desktop apps as well as mesh-enabled web apps. A large chunk of the webcast time has been set aside for Q&amp;A, but the best way to get your specific questions answered is to send them to us prior to the event so they can be worked into the presentation schedule.  Post your questions to <a href="http://social.msdn.microsoft.com/Forums/en-US/liveframework/thread/c47ca578-daf9-49f7-8ab7-da5fbab7c60c">this thread</a> in the Live Framework discussion forum.</p>
<p>To join the webcast, visit this link:  <a href="https://www.livemeeting.com/cc/microsoft/join?id=LiveFx_Dec8&amp;role=attend">https://www.livemeeting.com/cc/microsoft/join?id=LiveFx_Dec8&amp;role=attend</a></p>
<p>For more information and agenda, see the <a href="http://social.msdn.microsoft.com/Forums/en-US/liveframework/thread/c47ca578-daf9-49f7-8ab7-da5fbab7c60c">announcement on the Live Frameworks forum</a>.</p>
<p>See you there!</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/" data-text="Live Framework Webcast Monday December 8, 2008"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2008%2F12%2F01%2Flive-framework-webcast-monday-december-8-2008%2F&amp;title=Live%20Framework%20Webcast%20Monday%20December%208%2C%202008" id="wpa2a_16">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2008/12/01/live-framework-webcast-monday-december-8-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-Browser Dynamic JavaScript Loading</title>
		<link>http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/</link>
		<comments>http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 18:16:34 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/</guid>
		<description><![CDATA[Stoyan Stefanov writes about Non-Blocking JavaScript Downloads on the Yahoo User Interface Blog.  Good content all around, but I&#8217;d like to add a note on an item he somewhat casually skimmed over. In the &#8220;Dependencies&#8221; section of the article, Stefanov describes using the onLoad or onReadyStateChange events of the dynamically generated script tag to receive <a href='http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Stoyan Stefanov writes about <a href="http://yuiblog.com/blog/2008/07/22/non-blocking-scripts/">Non-Blocking JavaScript Downloads</a> on the <a href="http://yuiblog.com/blog/">Yahoo User Interface Blog</a>.  Good content all around, but I&#8217;d like to add a note on an item he somewhat casually skimmed over.</p>
<p>In the &#8220;Dependencies&#8221; section of the article, Stefanov describes using the onLoad or onReadyStateChange events of the dynamically generated script tag to receive notification when that script has been loaded by the browser.  Once you know it&#8217;s loaded, then you know it&#8217;s safe to begin using the code it contains.</p>
<p>This works great for Firefox and IE, but fails completely in the Safari browser.  Safari doesn&#8217;t implement onLoad notifications for script tags.  This forces you to abandon the onLoad technique and instead use the technique of embedding something at the end of each script file to signal when the file has been loaded. </p>
<p>The script libraries for the Windows Live sites use this technique &#8211; every source file contains a function call at the bottom that tells a central notifier that it has been loaded.  Other code can ask the notifier to signal them when a file or set of files have been loaded.  This works in all browsers without relying on diverging browser idiosyncracies. </p>
<p>Unfortunately, this also requires that all the JavaScript you want to load dynamically (using this technique) knows about your particular load notification pattern.  If you want to dynamically load JavaScript from multiple libraries or authors, you will either end up with multiple notification systems (which should coexist peacefully) or you&#8217;ll have to modify those files to use your load notifier.  This is bad from a design standpoint because it requires that all your code modules have carnal knowledge of your application - erodes the modularity of the source files &#8211; or require that all your code modules follow the design patterns of a particular JavaScript toolkit, like DoJo or Prototype or YUI.  The latter isn&#8217;t a terrible tradeoff except that it limits your options.</p>
<p> Discovered via a note by <a href="http://www.stevetrefethen.com/blog/">Steve Trefethen</a> on <a href="http://www.friendfeed.com">FriendFeed</a>.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/" data-text="Cross-Browser Dynamic JavaScript Loading"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2008%2F07%2F23%2Fcross-browser-dynamic-javascript-loading%2F&amp;title=Cross-Browser%20Dynamic%20JavaScript%20Loading" id="wpa2a_20">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2008/07/23/cross-browser-dynamic-javascript-loading/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  dannythorpe.com/tag/programming/feed/ ) in 0.68794 seconds, on May 21st, 2012 at 6:34 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 21st, 2012 at 7:34 pm UTC -->
