<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Code Beast</title>
	<atom:link href="http://mullr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mullr.wordpress.com</link>
	<description>fixing bugs, taking names</description>
	<lastBuildDate>Mon, 19 Sep 2011 16:50:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mullr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Code Beast</title>
		<link>http://mullr.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mullr.wordpress.com/osd.xml" title="Code Beast" />
	<atom:link rel='hub' href='http://mullr.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ActiveRecord mappings for the Japanese WordNet</title>
		<link>http://mullr.wordpress.com/2011/06/09/activerecord-mappings-for-the-japanese-wordnet/</link>
		<comments>http://mullr.wordpress.com/2011/06/09/activerecord-mappings-for-the-japanese-wordnet/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 01:45:45 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordnet]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/2011/06/09/activerecord-mappings-for-the-japanese-wordnet/</guid>
		<description><![CDATA[I found myself playing with the Japanese WordNet database the other day and thought it would be nice to be able to use it from a ruby program. ActiveRecord made this pretty easy. So in the spirit of Release Early, &#8230; <a href="http://mullr.wordpress.com/2011/06/09/activerecord-mappings-for-the-japanese-wordnet/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=67&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found myself playing with the Japanese WordNet database the other day and thought it would be nice to be able to use it from a ruby program.  ActiveRecord made this pretty easy. </p>
<p>So in the spirit of Release Early, Release Often: https://github.com/mullr/WordnetJapanActiveRecord</p>
<p>Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=67&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2011/06/09/activerecord-mappings-for-the-japanese-wordnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>Git screencast: splitting old commits</title>
		<link>http://mullr.wordpress.com/2011/06/09/git-screencast-splitting-old-commits/</link>
		<comments>http://mullr.wordpress.com/2011/06/09/git-screencast-splitting-old-commits/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 01:35:21 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[screencast]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=62</guid>
		<description><![CDATA[I made this for some people at work, but maybe the rest of the world will find it useful as well.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=62&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made this for some people at work, but maybe the rest of the world will find it useful as well.<br />
<span style="text-align:center; display: block;"><a href="http://mullr.wordpress.com/2011/06/09/git-screencast-splitting-old-commits/"><img src="http://img.youtube.com/vi/nQPLVdu_L0M/2.jpg" alt="" /></a></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=62&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2011/06/09/git-screencast-splitting-old-commits/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>TwitConc, a twitter concordancer</title>
		<link>http://mullr.wordpress.com/2010/07/22/twitconc-a-twitter-concordancer/</link>
		<comments>http://mullr.wordpress.com/2010/07/22/twitconc-a-twitter-concordancer/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 16:36:33 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=59</guid>
		<description><![CDATA[I made a little program to make it easy to, given a word you want to learn, find example sentences for it on twitter. It barely works, but it&#8217;s already useful. I really like the flashcards I&#8217;ve made from twitter, &#8230; <a href="http://mullr.wordpress.com/2010/07/22/twitconc-a-twitter-concordancer/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=59&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made a little program to make it easy to, given a word you want to learn, find example sentences for it on twitter.  It barely works, but it&#8217;s already useful.  I really like the flashcards I&#8217;ve made from twitter, they have a nice&#8230; flavor?  </p>
<p><a href="http://digitalartificer.com/TwitConc/">http://digitalartificer.com/TwitConc/</a></p>
<p>And if you want the source: <a href="http://github.com/mullr/TwitConc">http://github.com/mullr/TwitConc</a></p>
<p>If it&#8217;s broken for you, let me know how and I&#8217;ll try to fix it. I&#8217;ve tested on my mac only.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=59&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2010/07/22/twitconc-a-twitter-concordancer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring msysgit for improved awesome</title>
		<link>http://mullr.wordpress.com/2010/06/01/configuring-msysgit-for-improved-awesome/</link>
		<comments>http://mullr.wordpress.com/2010/06/01/configuring-msysgit-for-improved-awesome/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 02:19:30 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=47</guid>
		<description><![CDATA[Git, as many of us know, is pretty great. And it works with great things like github and gerrit. I&#8217;ve been using it for work lately and like it very much. But the windows toolchain leaves something to be desired. &#8230; <a href="http://mullr.wordpress.com/2010/06/01/configuring-msysgit-for-improved-awesome/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=47&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://git-scm.com/">Git</a>, as many of us know, is pretty great.  And it works with great things like <a href="http://github.com/">github</a> and <a href="http://gerrit.googlecode.com/">gerrit</a>.  I&#8217;ve been using it for work lately and like it very much.  But the windows toolchain leaves something to be desired.</p>
<p>It turns out that the first rule of git on windows is <strong>don&#8217;t use cygwin git</strong>.  I didn&#8217;t understand why this was until I started dealing with large repositories and doing a lot of waiting.  <code>git status</code> took 15 seconds to run EVERY TIME.  Luckily I figured it out and started using <a href="http://code.google.com/p/msysgit/">msysgit</a> instead.  msysgit is a pretty good port, but anybody who&#8217;s used a mac or any unix machine with a real terminal emulator will be immediately dismayed to find out that its shell runs inside the regular cmd.exe window.  Which is crap.</p>
<p>This is how to make it not crap.</p>
<p><strong>1.  Configure the console</strong><br />
Did you know you can make cmd.exe not suck?  I didn&#8217;t.  It&#8217;s pretty easy.<br />
<img class="alignnone size-full wp-image-48" src="http://mullr.files.wordpress.com/2010/06/menu.png?w=150&#038;h=238" alt="" width="150" height="238" /></p>
<p><img class="alignnone size-full wp-image-48" src="http://mullr.files.wordpress.com/2010/06/options.png?w=500" /><br />
The most important setting is &#8220;QuickEdit Mode&#8221;, which lets you select text directly without doing the brain-damaged menu selection thing.  Then you can hit enter to copy it.  The right mouse button pastes.  Double click selects a word, just like you&#8217;d expect; this is really useful when dealing with git, since you can double click a commit hash and hit enter to quickly copy it, then right click to paste it to the command line.  </p>
<p>The other settings I use and recommend are:</p>
<ul>
<li>Font: Consolas 14pt</li>
<li>Window Size: Width=128</li>
<li>Window Position: &#8220;Let system position window&#8221; turned off, set to be the right half of my screen every time.</li>
<li>Colors: I use a light yellow background and dark foreground.  This gives good contrast against the blue you see in so much colored output, unlike the default black background.  BG=255,255,236,  Text=0,0,0.  You should configure your prompt first if you want to do this, so you don&#8217;t get stuck with invisible text.  </li>
</ul>
<p><strong> 2.  Configure your prompt. </strong><br />
The default msysgit prompt settings are kind of crap.  This is what I use in my ~/.bash_profile.  <strong>NB: this is set up for a LIGHT background, so the text is BLACK.</strong> If you use this with the default colors, your text will be <strong>invisible</strong>.</p>
<pre class="brush: cpp;">
function parse_git_branch {
  git branch --no-color 2&gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

function proml {
  local       BLACK=&quot;\[&#092;&#048;33[0;30m\]&quot;
  local        BLUE=&quot;\[&#092;&#048;33[0;34m\]&quot;
  local         RED=&quot;\[&#092;&#048;33[0;31m\]&quot;
  local   LIGHT_RED=&quot;\[&#092;&#048;33[1;31m\]&quot;
  local       GREEN=&quot;\[&#092;&#048;33[0;32m\]&quot;
  local LIGHT_GREEN=&quot;\[&#092;&#048;33[1;32m\]&quot;
  local       WHITE=&quot;\[&#092;&#048;33[1;37m\]&quot;
  local  LIGHT_GRAY=&quot;\[&#092;&#048;33[0;37m\]&quot;
  case $TERM in
    xterm*)
    TITLEBAR='\[&#092;&#048;33]0;\w&#092;&#048;07\]'
    ;;
    *)
    TITLEBAR=&quot;&quot;
    ;;
  esac

PS1=&quot;${TITLEBAR}\
$BLACK\w$GREEN\$(parse_git_branch)\
$BLACK\$ &quot;
PS2='&gt; '
PS4='+ '
}
proml
</pre>
<p>You can easily adjust the colors to be how you like.  Note that the last color here will override the text color you set in the prefs window; that confused me at first.  Also make sure your profile file is executable (chmod +x ~/.bash_profile) and starts with #!/usr/bin/bash, if you&#8217;re having any troubles. </p>
<p><strong>3.  Configure git a little</strong><br />
This isn&#8217;t specific to windows, but it makes my git experience so much smoother.  I found the &#8216;lg&#8217; alias on the internet and forgot where.  Sorry, guy who made this first.</p>
<pre class="brush: plain;">
[merge]
        tool = winmerge
[mergetool &quot;winmerge&quot;]
        cmd = 'C:/Program Files/WinMerge/WinMergeU.exe' \&quot;$MERGED\&quot;
[color]
        diff = auto
        status = auto
        branch = auto
[alias]
        lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&amp;lt;%an&amp;gt;%Creset' --abbrev-commit --date=relative
        anchor = tag -f anchor
        s = status
</pre>
<p>&#8216;git lg&#8217; will now give you a nice colored log summary.  I use &#8216;git anchor&#8217; frequently before trying out something I may mess up or want to quickly revert; it makes it easy to get back to where I was without having to inspect the reflog.  And finally, I use &#8216;git status&#8217; so much that I just abbreviate it to &#8216;git s&#8217;.</p>
<p><strong>4.  RTFM</strong><br />
There are incredible amounts of excellent information about git on the web.  Read them.  You can look at my bookmarks over at <a href="http://delicious.com/mullr/git">del.icio.us</a> for a starting point if you want.  </p>
<p>Although there are a number of windows guis around, in various states of incompletion, you&#8217;ll be much better off if you learn to use git from the command line.  Yes, this means editing commit logs in vi, if you stick with the defaults.  If you can&#8217;t do this already, you should learn how.  The GUI tools, as they are today, simply hide too much important stuff from you.  The real power in git is understanding how the commit graph works and how it changes when you do various operations; this is something that should in your face, not hidden away.  At most, &#8216;git gui&#8217; is acceptable for staging things for commit.  &#8216;gitk&#8217; is alright as well.  But I haven&#8217;t yet seen any windows-specific guis that do a good job.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=47&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2010/06/01/configuring-msysgit-for-improved-awesome/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>

		<media:content url="http://mullr.files.wordpress.com/2010/06/menu.png" medium="image" />

		<media:content url="http://mullr.files.wordpress.com/2010/06/options.png" medium="image" />
	</item>
		<item>
		<title>C# techniques: simulating stack unwinding and block syntax</title>
		<link>http://mullr.wordpress.com/2008/10/02/csharp-techniques-simulating-blocks/</link>
		<comments>http://mullr.wordpress.com/2008/10/02/csharp-techniques-simulating-blocks/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 18:43:54 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=36</guid>
		<description><![CDATA[One of my favorite things about C++ was its predictable stack unwinding.  This could be combined with anonymous scopes for some powerful techniques.  (I learned all about this from Steve) For example, I might want to hold onto a lock &#8230; <a href="http://mullr.wordpress.com/2008/10/02/csharp-techniques-simulating-blocks/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=36&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of my favorite things about C++ was its predictable stack unwinding.  This could be combined with anonymous scopes for some powerful techniques.  (I learned all about this from <a href="http://www.1060.org/blogxter/publish/5">Steve</a>)  For example, I might want to hold onto a lock to something for a particular time.  I could simply make an object which allocates the lock in its constructor and releases it in its destructor.</p>
<p>// Anonymous scope for lock<br />
{<br />
    ResourceLock lock;<br />
    //&#8230;<br />
}</p>
<p>ResourceLock allocates the resource it its constructor.  It lives on the stack until the local block is exited, whereupon its destructor is called and the lock is released.  </p>
<p>The really great thing about this technique, especially for things like locks, is that it&#8217;s entirely exception safe.  Can we do something similar in C#?</p>
<p><strong>Method 1: IDisposable/using</strong><br />
The C# way of doing predictable allocation is IDisposable.  And since we have a bit of syntax sugar in the &#8216;using&#8217; block to make it exception safe, we may as well use it for this purpose. </p>
<p>class ResourceLock: IDisposable<br />
{<br />
    public ResourceLock()<br />
    {<br />
        // allocate the lock<br />
    }</p>
<p>    public Dispose()<br />
    {<br />
        // release the lock<br />
    }<br />
}</p>
<p>// usage example<br />
using(new ResourceLock())<br />
{<br />
    // the lock is held here&#8230;<br />
}<br />
// &#8230; and released here</p>
<p>Hopefully the usage is pretty obvious.  I like this method because the usage syntax is pretty good.  In fact I don&#8217;t know of another method for things like locks.  But there are other scenarios where you might want to do a bit more.</p>
<p><strong>Method 2: Delegate passing</strong><br />
You&#8217;ll be familiar with this technique if you&#8217;ve ever used Ruby or Smalltalk.  Those languages (and others) have native support for blocks.  It&#8217;s not quite as nice in C# but still usable. </p>
<p>Let&#8217;s take the example of data binding.  There are often cases where you need to do a batch of operations on a class which can throw change events.  While it&#8217;s not strictly incorrect to throw an event after each operation, it can be a big performance problem.  So we want disable change notification while the operations are in progress and throw a single change event when they&#8217;re done.  Think of it as a kind of data-binding transaction.  </p>
<p>We&#8217;ll implement the Transaction method using a Delegate parameter:</p>
<pre class="brush: csharp;">
// A class which is observable in some way
class DataBindingClass
{
    public void Transaction(Action a)
    {
        try
        {
            SuspendChangeNotification();
            a();
        }
        finally
        {
            ResumeChangeNotification();
            NotifyObserversOfChange();
        }
    }
}
</pre>
<p>By passing an anonymous delegate to this method, we get an acceptable (but not great) syntax. </p>
<pre class="brush: csharp;">
public void DoStuff(DataBindingClass db)
{
    db.Transaction(delegate()
    {
        // do some stuff
    });
}
</pre>
<p>Don&#8217;t forget that you can pull in variables from the surrounding scope via closure.  That&#8217;s really the only reason this technique is worth bothering with.  </p>
<p><strong>Method 3: IEnumerable/yield return/continuations</strong><br />
Okay, we&#8217;ve now stepped clearly into the realm of abuse.  Please don&#8217;t do this in your code.  But in the interest of completeness&#8230;</p>
<p>Since the yield return syntax is really a form of continuation, we can get the same general scoping effect with a little bit of creativity.  </p>
<pre class="brush: csharp;">
// A class which is observable in some way
class DataBindingClass
{
    public IEnumerable&lt;int&gt; Transaction()
    {
        try
        {
            SuspendChangeNotification();
            yield return 42;
        }
        finally
        {
            ResumeChangeNotification();
            NotifyObserversOfChange();
        }
    }
}

// usage example
public void DoStuff(DataBindingClass db)
{
    foreach(var i in db.Transaction())
    {
        // do some stuff
    }
}
</pre>
<p>As you can see, we abuse the ability of foreach to iterate over any IEnumerable to simulate a block syntax.  In this case the block is only called once, so the loop only runs one time.  The particular value we yield out Transaction() is completely arbitrary, as is the type.  It&#8217;s only there to fool the loop into running.  </p>
<p><strong>In summary</strong><br />
C# gives us some reasonable tools here.  I recommend method 2 (delegate passing) for most cases  &#8211; it&#8217;s very flexible and the syntax is reasonable.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=36&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2008/10/02/csharp-techniques-simulating-blocks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>Trick-hot command pattern in C#</title>
		<link>http://mullr.wordpress.com/2008/09/17/trick-hot-command-pattern-in-csharp/</link>
		<comments>http://mullr.wordpress.com/2008/09/17/trick-hot-command-pattern-in-csharp/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 20:57:04 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=31</guid>
		<description><![CDATA[I&#8217;m working on some code that needs an undo feature, so naturally I turned to the command pattern.  I pulled out GoF to glance at their naming conventions and started to type, all the while thinking &#8220;there has to be &#8230; <a href="http://mullr.wordpress.com/2008/09/17/trick-hot-command-pattern-in-csharp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=31&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on some code that needs an undo feature, so naturally I turned to the command pattern.  I pulled out GoF to glance at their naming conventions and started to type, all the while thinking &#8220;there has to be a better way to do this.&#8221; Here&#8217;s what I think is a better way.</p>
<p>Recall that the command pattern specifies an abstract &#8220;Command&#8221; type with an Exceute method.  This is only needed in languages without first-class functions: C# gives us delegates, which are pretty much equivalent in this case.  So we&#8217;ll skip the custom class and just use them.</p>
<p>But the extended, more useful form of the pattern also has an UnExecute method, used for undo.  This lets you push the commands onto a stack after executing them.  Undo is then simply a matter of popping the most recent command off the stack and UnExecute()ing it.  The command instance retains enough state information to undo what it had previously done.</p>
<p>We can do all that through the clever application of closures.  I&#8217;ve chosen to implement the commands as static methods, but they could also be implemented as regular methods, even virtual if you&#8217;d like to be able to route around to different implementations.  Here&#8217;s a fictitious example:</p>
<pre class="brush: csharp;">
static class Commands
{
    public static Action HAlign(Item stationary, Item movable)
    {
        int oldX = movable.X;
        movable.X = stationary.X;

        return delegate()
        {
            movable.X = oldX;
        };
    }
}
</pre>
<p>Executing the command is just a method call, and enabling undo is as simple as pushing the returned Action (just a delegate with no parameters or return type) onto an undo stack. (Stack&lt;Action&gt; will do nicely)  The returned delegate captures, via closure, all the state in needs for undo to work properly.</p>
<p>That&#8217;s it!  There are a few small land-mines in the details of how closures work (especially w.r.t. non-local or iteration variables), but the general technique is very simple.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mullr.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mullr.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=31&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2008/09/17/trick-hot-command-pattern-in-csharp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>Two cool things (cappuccino, github)</title>
		<link>http://mullr.wordpress.com/2008/09/14/two-cool-things-cappuccino-github/</link>
		<comments>http://mullr.wordpress.com/2008/09/14/two-cool-things-cappuccino-github/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 20:31:28 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=28</guid>
		<description><![CDATA[Cool thing 1: Cappuccino.  I&#8217;m sure this is well known by most by now.  I&#8217;ve been playing with it in my copius free time and continue to be impressed.  I&#8217;m excited to be able to use Objective-C in the browser &#8230; <a href="http://mullr.wordpress.com/2008/09/14/two-cool-things-cappuccino-github/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=28&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Cool thing 1: Cappuccino.  I&#8217;m sure this is well known by most by now.  I&#8217;ve been playing with it in my copius free time and continue to be impressed.  I&#8217;m excited to be able to use Objective-C in the browser &#8211; I&#8217;ve always thought it was a nice language, despite my lack of experience with it.  In particular, dynamic message dispatch is a perfect fit for GUI programming.</p>
<p>Cool thing 2: github.  While playing with cappuccino, I thought I&#8217;d fix a few bugs.  So I made a github account and cloned the full repo.  The clone took about a half second.  Really.  The collaboration model on github just decimates all the commercial systems I&#8217;ve used, not to mention cvs and svn.  This is what sourceforge always should have been.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mullr.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mullr.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=28&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2008/09/14/two-cool-things-cappuccino-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>org-mode</title>
		<link>http://mullr.wordpress.com/2008/06/14/org-mode/</link>
		<comments>http://mullr.wordpress.com/2008/06/14/org-mode/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 15:58:06 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=27</guid>
		<description><![CDATA[As things have been heating up at work lately, I&#8217;ve found myself returning to GTD as a way of keeping things more sane.  I thought that I&#8217;d look for a tool.  I tried a complicated one that modeled out the &#8230; <a href="http://mullr.wordpress.com/2008/06/14/org-mode/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=27&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As things have been heating up at work lately, I&#8217;ve found myself returning to <a href="http://en.wikipedia.org/wiki/Getting_Things_Done">GTD</a> as a way of keeping things more sane.  I thought that I&#8217;d look for a tool.  I tried a complicated one that modeled out the whole system, but I ended up with emacs <a href="http://orgmode.org/">org-mode</a>.</p>
<p>It&#8217;s awesome.</p>
<p>Really, it&#8217;s just a fancy outline editor at its core.  I know there a lot more things that I haven&#8217;t learned about yet, but the surface is very useful.  I can mark things as todo/done, collapse subtrees, and easily move things around.  That&#8217;s about all I need, really.  And it works much better for me than the complex one because I can easily customize the view onto my data.  It&#8217;s just a tree in a text file, after all.  It also lets me easily morph the system into whatever I need it to be at the time, rather than being rigid.  I suppose that&#8217;s good for some people, but ad-hocish is good for me.</p>
<p>And plus it means I get to use emacs more.  Which makes me feel very l33t.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mullr.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mullr.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=27&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2008/06/14/org-mode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>My Bookshelf</title>
		<link>http://mullr.wordpress.com/2008/02/08/my-bookshelf/</link>
		<comments>http://mullr.wordpress.com/2008/02/08/my-bookshelf/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 18:53:31 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/?p=24</guid>
		<description><![CDATA[These are the books I have at work, which mostly reflect the various projects I&#8217;ve worked on over the years.  Some are useful, some are not. General Books: Design Patterns, GoF: Recommended, but first read Head First Design Patterns.  These &#8230; <a href="http://mullr.wordpress.com/2008/02/08/my-bookshelf/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=24&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>These are the books I have at work, which mostly reflect the various projects I&#8217;ve worked on over the years.  Some are useful, some are not.</p>
<p>General Books:</p>
<ol>
<li>Design Patterns, GoF: Recommended, but first read Head First Design Patterns.  These two books togther kicked my brain into being able to think critically about design decisions.</li>
<li>The Pragmatic Programmer:  I like it, though I think it&#8217;s worth less now in the light of robust discussion of these topics on blogs.</li>
<li>Peer Reviews In Software: Haven&#8217;t opened it.  Got it from a mandatory training class that didn&#8217;t impress me.</li>
<li>Lean Software Development / Implementing Lean Software Development: Barely cracked them. Put on my desk by my boss, but I think this particular movement (in our organization, anyway) is going to pass before I need to care too much about it.</li>
<li>Extreme Programming Explained: Barely cracked, though I bought it myself.  Once I started reading it, I realized I already learned the content on the web.</li>
</ol>
<p>Technology-specific books:</p>
<ol>
<li> The C++ Programming Lanuage: Essential if you&#8217;re using the language.</li>
<li>Effective C++/More Effective C++/Effective STL: Also essential if you&#8217;re using the language.  Other books tell you how to write code, but these books tell you how to right GOOD code.</li>
<li>Effective C#: Doesn&#8217;t live up to its namesake.  Perhaps there are fewer gotchas in C#?</li>
<li>Java Performance Tuning: I got this for $5 and learned one or two things from it.  But I think it&#8217;s about Java 1.1, so it&#8217;s more than a little out of date.</li>
<li>Interprocess Communication in Linux: useful when I needed it, but I no longer need it.</li>
<li>Programming .Net components: This is a bit of a weird one.  I was hoping it would explain the mysterious System.ComponentModel namespace, but I never got into it enough to fully understand what&#8217;s going on.  I could probably learn a lot from this book if I got into it, but I&#8217;m not motivated to do it anymore.</li>
<li>Java development with Ant: I like this one.  Useful whenever I need to do ant, which is more often than one might think.  And my copy is autographed!</li>
<li>Applications=Code+Markup: Meh.  Not that impressed.  If you want a WPF book, get:</li>
<li>Windows Presentation Foundation Unleashed: This is the one you want.  It&#8217;s smaller than the previous book, but it has better explanations about the things that matter.</li>
<li>Debugging Microsoft .NET 2.0 Applications: This book has saved my ass on multiple occasions.  If you&#8217;re developing for .NET, you need to know how to use your debugging tools.</li>
</ol>
<p>What does your bookshelf look like?  Are there any bacon-saving books you&#8217;d recommend?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mullr.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mullr.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=24&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2008/02/08/my-bookshelf/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
		<item>
		<title>Secrets of WPF Memory Allocation</title>
		<link>http://mullr.wordpress.com/2007/11/13/secrets-of-wpf-memory-allocation/</link>
		<comments>http://mullr.wordpress.com/2007/11/13/secrets-of-wpf-memory-allocation/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 23:26:01 +0000</pubDate>
		<dc:creator>mullr</dc:creator>
				<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://mullr.wordpress.com/2007/11/13/secrets-of-wpf-memory-allocation/</guid>
		<description><![CDATA[The way WPF manages memory is a bit of a mystery. It all appears to be nicely garbage collected and everything, but I know there are unmanaged resources under there. How does it know when to garbage collect them? This &#8230; <a href="http://mullr.wordpress.com/2007/11/13/secrets-of-wpf-memory-allocation/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=23&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The way WPF manages memory is a bit of a mystery.  It all appears to be nicely garbage collected and everything, but I know there are unmanaged resources under there.  How does it know when to garbage collect them?</p>
<p>This is especially important for my application, since I have to manage MANY photos on the screen at once.  I&#8217;m pretty comfortable with the Dispose() idiom &#8211; I kind of like knowing where the memory is going when I&#8217;m using such large chunks.  But with WPF it&#8217;s been a mystery.</p>
<p>Enter: <a href="http://www.aisto.com/roeder/dotnet/">.Net Reflector</a>!  Not that I would use such a thing.  But supposing I did. (Incidentally, I think I owe Lutz Roeder several beers because of this program)</p>
<p>For those that don&#8217;t know, there&#8217;s a native code library called &#8216;milcore&#8217; that WPF is built upon.  It has a number of handle types.  These are wrapped in .NET by subclasses of SafeMILHandle.  This is where things become clear &#8211; each of these handle wrappers manually puts pressure on the garbage collector according to the estimated size of the object in question.  It uses something called MemoryPresssure.Add() to do this.</p>
<p>Which, it turns out, is not actually a way to influence the garbage collector.  It&#8217;s in PresentationCore.dll: MS.Internal.MemoryPressure.  It uses a funny time/size based heuristic to manually call GC.Collect, which we all know and love.  So, depending on what you&#8217;re doing with MIL Handles and how you&#8217;re doing it, WPF will force garbage collection when it feels like it.</p>
<p>Now, I don&#8217;t know a whole lot about garbage collectors, but&#8230; how can this possibly work?  It seems fine in simple cases (allocate a whole ton of memory, null out your references, repeat).  But doesn&#8217;t it break the useful heuristics that makes gc perform well?  For the case of bitmaps especially, it seems that it&#8217;s important for GC to know that these are large objects that should be released as soon as possible.  More bang for the buck there.  (The large object heap comes to mind, but I think that&#8217;s to prevent heap fragmentation)</p>
<p>It&#8217;s interesting to observe that the base SafeHandle class *does* implement IDisposable.  But the MIL handles themselves aren&#8217;t publicly accessible, so they can&#8217;t be directly used.  But an adventurous/insane person might use reflection to pull the MIL Handle out, replace it with null at the source, type it as an IDisposable, and dispose it manually.  I may resort to such measures if this memory pressure thing turns out to be as fishy as it smells.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mullr.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mullr.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mullr.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mullr.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mullr.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mullr.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mullr.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mullr.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mullr.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mullr.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mullr.wordpress.com&amp;blog=193892&amp;post=23&amp;subd=mullr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mullr.wordpress.com/2007/11/13/secrets-of-wpf-memory-allocation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86790ddd55c56e34926c5ff1d9ce39d3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mullr</media:title>
		</media:content>
	</item>
	</channel>
</rss>
