<?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>Over It. &#187; C#</title>
	<atom:link href="http://jason.diamond.name/weblog/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://jason.diamond.name/weblog</link>
	<description>(a Weblog by Jason Diamond)</description>
	<lastBuildDate>Fri, 03 Sep 2010 23:59:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>One-line lazy initialization</title>
		<link>http://jason.diamond.name/weblog/2010/02/23/one-line-lazy-initialization/</link>
		<comments>http://jason.diamond.name/weblog/2010/02/23/one-line-lazy-initialization/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 22:54:19 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=91</guid>
		<description><![CDATA[Is this too obscure? public class MyObject { private MyExpensiveObject _myExpensiveObject; public MyExpensiveObject ExpensiveObject { get { return _myExpensiveObject ?? (_myExpensiveObject = new MyExpensiveObject()); } } }]]></description>
			<content:encoded><![CDATA[<p>Is this too obscure?</p>
<pre class="brush:csharp">public class MyObject
{
    private MyExpensiveObject _myExpensiveObject;

    public MyExpensiveObject ExpensiveObject
    {
        get { return _myExpensiveObject ??
                     (_myExpensiveObject = new MyExpensiveObject()); }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2010/02/23/one-line-lazy-initialization/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RogueSharp</title>
		<link>http://jason.diamond.name/weblog/2010/02/15/roguesharp/</link>
		<comments>http://jason.diamond.name/weblog/2010/02/15/roguesharp/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 02:49:44 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Rogue]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=86</guid>
		<description><![CDATA[I just pushed a pet project of mine up to GitHub today. It&#8217;s a port of the original game of Rogue from C to C#. It&#8217;s not complete&#8211;it doesn&#8217;t save your progress and let you continue on later, but it is playable. Now that the actual port is done, I plan on cleaning up the [...]]]></description>
			<content:encoded><![CDATA[<p>I just pushed a pet project of mine up to GitHub today. It&#8217;s a port of the original game of <a href="http://en.wikipedia.org/wiki/Rogue_(computer_game)">Rogue</a> from C to C#. It&#8217;s not complete&#8211;it doesn&#8217;t save your progress and let you continue on later, but it is playable.</p>
<p>Now that the actual port is done, I plan on cleaning up the code. Like most software written in C in the 80s, it relies on way too many global variables, uses an abundance of switch statements on object types, and has no abstraction between the game logic and the UI. Since it&#8217;s on GitHub, that should leave a nice history of the refactorings I try to apply to it. Of course, before I can try to do any refactoring, I need to get some tests in place. That should be fun considering how much it relies on direct access to the <a href="http://en.wikipedia.org/wiki/Curses_(programming_library)">curses</a> library and a random number generator.</p>
<p>The repository is <a href="http://github.com/jdiamond/rogue-sharp">here</a>. Feel free to fork it to help out if you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2010/02/15/roguesharp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Splitting CamelCase With Regular Expressions</title>
		<link>http://jason.diamond.name/weblog/2009/08/15/splitting-camelcase-with-regular-expressions/</link>
		<comments>http://jason.diamond.name/weblog/2009/08/15/splitting-camelcase-with-regular-expressions/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 22:22:40 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=27</guid>
		<description><![CDATA[On my new project, I needed to split a method name up into its constituent parts. For Ruby programmers, this is easy: just split on underscores. For us .NET programmers, we need something a little fancier since we like to SquashOurMethodNamesTogetherLikeThis. Here&#8217;s a little regular expression that can do exactly that: (?&#60;!^)(?=[A-Z]) That basically says [...]]]></description>
			<content:encoded><![CDATA[<p>On my new project, I needed to split a method name up into its constituent parts.</p>
<p>For Ruby programmers, this is easy: just split on underscores. For us .NET programmers, we need something a little fancier since we like to <code>SquashOurMethodNamesTogetherLikeThis</code>.</p>
<p>Here&#8217;s a little regular expression that can do exactly that:</p>
<pre>(?&lt;!^)(?=[A-Z])</pre>
<p>That basically says to match right before every capital letter unless the capital letter is at the beginning of the string.</p>
<p>You can use the Regex.Split method to do the actual work of turning the method name into a string array:</p>
<pre class="brush:csharp">
Regex splitter = new Regex(@"(?&lt;!^)(?=[A-Z])");
string[] words = splitter.Split(methodName);
</pre>
<p>My friend, <a href="http://www.michaelckennedy.net/">Michael Kennedy</a>, demoed in class recently how to use <a href="http://www.linqpad.net/">LINQPad</a> to test regular expressions. It came in really handy while working on this:</p>
<p><img src="http://jason.diamond.name/weblog/wp-content/uploads/2009/08/linqpad-with-regex.png" alt="linqpad-with-regex" title="linqpad-with-regex" width="667" height="362" class="alignnone size-full wp-image-32" /></p>
<p>I really need to click that &#8220;Activate Autocompletion&#8221; button so I can give <a href="http://www.albahari.com/">Joseph Albahari</a> the money he deserves for creating such a useful tool.</p>
<p>By the way, I used to think that &#8220;camel case&#8221; was for words like &#8220;camelCase&#8221; and &#8220;pascal case&#8221; was for words like &#8220;PascalCase&#8221;, but <a href="http://en.wikipedia.org/wiki/PascalCase">Wikipedia</a> doesn&#8217;t make that distinction.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2009/08/15/splitting-camelcase-with-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My UnWordify Extension Method</title>
		<link>http://jason.diamond.name/weblog/2009/08/09/my-unwordify-extension-method/</link>
		<comments>http://jason.diamond.name/weblog/2009/08/09/my-unwordify-extension-method/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 04:41:55 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=8</guid>
		<description><![CDATA[Tim Barcz is looking for a solution to an interesting problem in his Coding Contest: Create a Programming Pearl post. I decided to challenge myself by writing my solution as a single &#8220;line&#8221; of code: public static class StringExtensions { private static Dictionary&#60;char, char> _charMap = new Dictionary&#60;char, char> { { (char)8208, (char)45 }, { [...]]]></description>
			<content:encoded><![CDATA[<p>Tim Barcz is looking for a solution to an interesting problem in his <a href="http://devlicio.us/blogs/tim_barcz/archive/2009/08/09/coding-contest-create-a-programming-pearl.aspx">Coding Contest: Create a Programming Pearl</a> post.</p>
<p>I decided to challenge myself by writing my solution as a single &#8220;line&#8221; of code:</p>
<pre class="brush:csharp">public static class StringExtensions
{
    private static Dictionary&lt;char, char> _charMap = new Dictionary&lt;char, char>
    {
        { (char)8208,  (char)45 },
        { (char)8211,  (char)45 },
        { (char)8212,  (char)45 },
        { (char)8722,  (char)45 },
        { (char)173,   (char)45 },
        { (char)8209,  (char)45 },
        { (char)8259,  (char)45 },
        { (char)96,    (char)39 },
        { (char)8216,  (char)39 },
        { (char)8217,  (char)39 },
        { (char)8242,  (char)39 },
        { (char)769,   (char)39 },
        { (char)768,   (char)39 },
        { (char)8220,  (char)34 },
        { (char)8221,  (char)34 },
        { (char)8243,  (char)34 },
        { (char)12291, (char)34 },
        { (char)160,   (char)32 },
        { (char)8195,  (char)32 },
        { (char)8194,  (char)32 }
    };

    public static string UnWordify(this string value)
    {
        return new string((from c in value
                           select _charMap.ContainsKey(c) ? _charMap[c] : c)
                          .ToArray());
    }
}</pre>
<p>OK, so I cheated and used a dictionary to create my map from the bad characters to the good ones, but the actual method <em>is</em> a single statement.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2009/08/09/my-unwordify-extension-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
