<?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>Making the Complex Simple &#187; Cool Stuff</title>
	<atom:link href="http://simpleprogrammer.com/category/cool-stuff/feed/" rel="self" type="application/rss+xml" />
	<link>http://simpleprogrammer.com</link>
	<description>Software Development from John Sonmez&#039;s Perspective</description>
	<lastBuildDate>Tue, 07 Feb 2012 17:47:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='simpleprogrammer.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Making the Complex Simple &#187; Cool Stuff</title>
		<link>http://simpleprogrammer.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://simpleprogrammer.com/osd.xml" title="Making the Complex Simple" />
	<atom:link rel='hub' href='http://simpleprogrammer.com/?pushpress=hub'/>
		<item>
		<title>The Most Complex Program of All Time</title>
		<link>http://simpleprogrammer.com/2011/04/25/the-most-complex-program-of-all-time/</link>
		<comments>http://simpleprogrammer.com/2011/04/25/the-most-complex-program-of-all-time/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 23:40:09 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1322</guid>
		<description><![CDATA[What if I told you that there is a program so complicated that is the source responsible for all other programs ever created? Give me your most complex program and I will trump it by presenting you with the program that was responsible for creating the human who created that program. If you haven’t figured [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1322&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What if I told you that there is a program so complicated that is the source responsible for all other programs ever created?</p>
<p>Give me your most complex program and I will trump it by presenting you with the program that was responsible for creating the human who created that program.</p>
<p>If you haven’t figured it out by now that program is human DNA and that masterful programmer is the Creator Himself.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/04/dna_500.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="dna_500" border="0" alt="dna_500" src="http://complextosimple.files.wordpress.com/2011/04/dna_500_thumb.jpg?w=474&#038;h=308" width="474" height="308" /></a></p>
<h2>Doesn’t matter what religion you are</h2>
<p>It is pretty difficult to fail to recognize that a program as complex as a human being’s genetic code was created, not randomly assimilated.</p>
<p>As programmers we have a unique perspective in life.&#160; We are able to truly understand God’s masterwork in the creation of human life.&#160; We are able to grasp loosely the ungraspable magnificence of a program so complicated, yet executed so simply.</p>
<p>We also have the unique position of fundamentally understanding that complex programs could never be created by random chance, regardless of time.&#160; We can look at a piece of code or functioning computer program and we can understand that its creation required an intelligent creator.&#160; Other people and professionals do not have this insight that so many of us are fortunate to have.</p>
<h2></h2>
<h2>Qualities of the code</h2>
<p>We’ve been treating data like code recently in C# with the introduction of Lambda expressions and other languages have been doing it for much longer, but the ultimate example of this practice is right there in our own DNA.</p>
<p>DNA is data, a message, and code all together at once.&#160; Just like a data structure in the memory of a computer executing a program, it lacks meaning without the context of the cell that it is in.&#160; Amazingly though, this data is recombined in different ways that are dictated by two separate and different instances of itself to produce a third separate instance of itself that still makes sense.</p>
<p>Just to give you an idea of how insanely complex that idea is (despite the simple execution of it), it would be like if you wrote a webserver that could spawn new instances of itself by contacting another, but different copy of your webserver and getting 1/2 the source code payload from itself and the contacted server, then actually combining that code to create a new copy that is different, yet still passes all of your unit and integration tests.</p>
<p>One of the qualities we often look at for our code is the size of the code in relation to what it can accomplish.</p>
<p><a href="http://www.utheguru.com/fun-science-how-many-megabytes-in-the-human-body">A decent estimate</a> is that the human genome is about .35 gigabytes of data.&#160; That data is stored on such a small space that we can’t even see it with the naked eye.&#160; There is no more compact form of data in the universe that we know of.</p>
<p>Not only is this data compact, but consider how much functionality is built into this small .35 gigabyte package?&#160; If you had to write acceptance tests for the human body, you might spend several lifetimes doing it.&#160; If you had to write acceptance tests for just a single cell in your body, that feat itself could take years and still not be complete.&#160; Imagine trying to write a program that took up .35 gigabytes of data, yet contained millions of acceptance tests worth of functionality.</p>
<p>We certainly could go on and on about the qualities of the human code, but I want to point out what perhaps is one of the most unique and amazing… the ability for the code to create its own hardware.</p>
<p>In actuality the code and that hardware are much the same.&#160; DNA replicates by a chemical reaction that causes the entire molecule to unwind and split.&#160; RNA inside a cell is created from specific portions of the DNA in order to create different protein chains which are used to construct little machines that will replicate the DNA and cells and in turn create machines capable of doing the same.</p>
<p>The process is very complex and not wholly understood, but in effect the end result is that DNA contains the instructions inside of a cell to create the machinery to host another copy of itself and execute that code.</p>
<h2>Easter eggs</h2>
<p>Let’s not forget the little Easter eggs that have been thrown in by the designer of our codebase.</p>
<p>How about a hiccup or a tear?</p>
<p>Sadness or laughter?</p>
<p>There are some “evolutionary theories” as to why these things exist, but in reality they serve no specific purpose for either our survival or well being.</p>
<p>In my mind these are clearly Easter eggs left by the designer to show His handiwork.</p>
<h2>Why am I writing this post now?</h2>
<p>I didn’t want to go completely off subject and boast about my wonderful daughter that was born on April 17th 2011 at 2:33 PM, since this is a professional blog.&#160; </p>
<p><a href="http://complextosimple.files.wordpress.com/2011/04/0417sophiasonmez-favs-16.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="0417sophiasonmez-favs-16" border="0" alt="0417sophiasonmez-favs-16" src="http://complextosimple.files.wordpress.com/2011/04/0417sophiasonmez-favs-16_thumb.jpg?w=489&#038;h=732" width="489" height="732" /></a></p>
<p>But, there you have it.</p>
<p>The amazing birth of my first child reminded my of the incredibly complex code that keeps us all breathing, procreating and living life that we seem to take for granted each and every day.</p>
<p>Welcome to the world Sophia Grace!</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1322/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1322/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1322/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1322&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/04/25/the-most-complex-program-of-all-time/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/04/dna_500_thumb.jpg" medium="image">
			<media:title type="html">dna_500</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/04/0417sophiasonmez-favs-16_thumb.jpg" medium="image">
			<media:title type="html">0417sophiasonmez-favs-16</media:title>
		</media:content>
	</item>
		<item>
		<title>Published My First Course on Pluralsight</title>
		<link>http://simpleprogrammer.com/2011/04/12/published-my-first-course-on-pluralsight/</link>
		<comments>http://simpleprogrammer.com/2011/04/12/published-my-first-course-on-pluralsight/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 04:27:51 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1305</guid>
		<description><![CDATA[My number of blog posts in the last couple of months has definitely been a little lower than I like, but I have a pretty good reason. I just got my first course published on Pluralsight! The course is called Android Development for .NET Developers and it covers most of the basic knowledge you would [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1305&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My number of blog posts in the last couple of months has definitely been a little lower than I like, but I have a pretty good reason.</p>
<p>I just got my first course published on <a href="http://www.pluralsight-training.net/microsoft/">Pluralsight</a>!</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/04/logomedium1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="logomedium" src="http://complextosimple.files.wordpress.com/2011/04/logomedium_thumb.png?w=233&#038;h=56" border="0" alt="logomedium" width="233" height="56" /></a></p>
<p>The course is called <a href="http://www.pluralsight-training.net/microsoft/OLT/Course/Toc.aspx?n=android-intro">Android Development for .NET Developers</a> and it covers most of the basic knowledge you would need to go from knowing nothing about Android development to being able to create a fairly simple application and publish that application to the Android Market.</p>
<p>If you haven’t checked out <a href="http://www.pluralsight-training.net/microsoft/">Pluralsight</a>, it is a really good site for a wide variety of developer training videos.  They really managed to get some very good content on the site and there are videos on just about every .NET topic you can think of.</p>
<p>I have also really enjoyed working with the guys that run Pluralsight, they are all very friendly and very knowledgeable.  Thanks to <a href="http://twitter.com/elegantcoder">David Starr</a> and <a href="http://twitter.com/fritzonion">Fritz Onion</a> for all their help getting my course ready and published.</p>
<h2>You never really learn something till you teach it</h2>
<p><a href="http://complextosimple.files.wordpress.com/2011/04/teacher-point.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="teacher-point" src="http://complextosimple.files.wordpress.com/2011/04/teacher-point_thumb.gif?w=462&#038;h=425" border="0" alt="teacher-point" width="462" height="425" /></a></p>
<p>This simple truth became more apparent to me than ever during the process of making this course.</p>
<p>I thought I had a pretty good understanding of the Android fundamentals, having published a fairly complex application, <a href="http://simpleprogrammer.com/2011/01/04/introducing-pacemaker-for-android/">PaceMaker</a>.</p>
<p>What I became quickly aware of is that there is a huge difference between having knowledge and having understanding.</p>
<p>I equate knowledge as possessing a formula to be able to do something, but lacking knowing why or how to make modifications to the process.</p>
<p>Cooking provides an excellent example of this.  There are many people in the world who know how to cook a large number of dishes.  But many of these people only have the knowledge of cooking.  They have a large collection of recipes which they can follow to produce the desired result.</p>
<p>A professional chef on the other hand, has a true understanding of cooking.  This person might have knowledge of many recipes, but they also understand why the particular ingredients are used and can make modifications to those ingredients and steps.  They may even create something without preset steps because they understand what they are doing, not just have knowledge about it.</p>
<p>It was great to have the experience of creating these videos because I was able to acquire an in-depth understanding of Android development, not just a knowledge of what to do.</p>
<p>If you ever have the opportunity to teach, I definitely recommend you take that opportunity.  Even if you don’t think you are qualified to teach a subject, by the time you have prepared what you are going to teach, you will be qualified.  Trial by fire perhaps, but well worth the outcome.  Plus you’ll be helping others in the process.</p>
<h2>Much harder than I thought</h2>
<p>I do have to admit though, recording training videos is definitely much harder than I had originally anticipated.</p>
<p>In order to get 40 minutes of video, it might take 6 hours worth of work or even more depending on the prep work involved and how much editing after getting the raw footage.</p>
<p>I really expected that it would take about as much time as it takes to record something to produce that something, but I definitely learned that is not the case.</p>
<p>I often found that I had to draw a line and stop trying to refine a video because you can literally spend an unlimited amount of time editing and tweaking a video.</p>
<p>Another revelation that might be apparent to everyone else, but was quite an epiphany to me was that you can edit “umms” out of video very easily.  You can’t even notice where they are cut out!  My first video, I didn’t even realize I could edit anything, and I ended up taking like 50 cuts until I could get it right.</p>
<h2>Overall though, great experience, lots of fun</h2>
<p>I felt like I&#8217;ve been stretched in a different direction, as I had never done any video or audio recording before and had never really spent much time in a room talking to myself pretending to talk to other people, but it was a good kind of stretching.</p>
<p>I really actually enjoyed the process and I will definitely be doing more of this kind of work in the future.  Probably going to take a bit of a break before I start my next course though.  I want to make sure I take some time to get a good retrospective of the process and sharpen my saw a bit so my next videos can be even better.</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.  Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1305&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/04/12/published-my-first-course-on-pluralsight/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/04/logomedium_thumb.png" medium="image">
			<media:title type="html">logomedium</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/04/teacher-point_thumb.gif" medium="image">
			<media:title type="html">teacher-point</media:title>
		</media:content>
	</item>
		<item>
		<title>Objective-C Here I Come!</title>
		<link>http://simpleprogrammer.com/2011/02/01/objective-c-here-i-come/</link>
		<comments>http://simpleprogrammer.com/2011/02/01/objective-c-here-i-come/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 02:39:50 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1244</guid>
		<description><![CDATA[Have I blabbed enough about the PaceMaker app I released for Android yet? First month of sales are over, and it was much better than I had expected.  About 75 purchases in the first 30 days.  Not a huge amount, but that is almost with no advertising, most people who found the app found it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1244&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have I blabbed enough about the <a href="http://simpleprogrammer.com/2011/01/04/introducing-pacemaker-for-android/">PaceMaker</a> app I released for Android yet?</p>
<p>First month of sales are over, and it was much better than I had expected.  About 75 purchases in the first 30 days.  Not a huge amount, but that is almost with no advertising, most people who found the app found it in the market.</p>
<p>So what is the next step for PaceMaker?</p>
<p>Well, with the <a href="http://support.vzw.com/faqs/iphone/iphone_faq.html">iPhone coming to Verizon this month</a>, I think it is pretty obvious that it is time for the iPhone version.</p>
<p>Only problem is…</p>
<h2>I know nothing about iPhone development!</h2>
<p>Well I didn’t last week, but I am slowly learning.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/02/iphone.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="iphone" src="http://complextosimple.files.wordpress.com/2011/02/iphone_thumb.jpg?w=204&#038;h=370" border="0" alt="iphone" width="204" height="370" /></a></p>
<p>I bought my first Mac ever last week, a <a href="http://www.amazon.com/gp/product/B00487X27O?ie=UTF8&amp;tag=makithecompsi-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B00487X27O">MacBook Air</a>.</p>
<p>I have to say, the operating system on Macs has come a long way since I last used one.  (Did I mention I also don’t even know how to properly run a Mac?  But I know Unix, so I should be ok.)</p>
<p>I feel like the Mac interface is so much more polished and uniform than Windows, but it is pretty scary inside when you consider all the low level C and Objective C code.</p>
<p>Then again you have to consider that the wonderful .NET CLR is written right on top of a really crusty win32 API layer which is a bunch of scary C code that is about 20 years old.</p>
<p>So I am setting out on a brave new quest to learn Mac, iPhone and Objective-C and somehow port my application over to the platform.</p>
<h2>Objective-C is kind of like an alternate universe</h2>
<p>I was trying to think how I would describe Objective-C and here is what I came up with:</p>
<blockquote><p>Objective-C is like one of those movies where there is an alternate universe where the same people exist as in this universe, but in some areas their technology is really advanced, but in others it’s really ancient.  Like a bunch of people flying around in flying cars, but their weapons are still bows and arrows.</p></blockquote>
<p>I used to be a C++ programmer, so not too many things scare me, but some of the magical constructs in Objective-C are very frightening indeed.</p>
<p>I was just reading about a strange construct today that allow you to basically create the equivalent of a C# interface, but in Objective-C it is called a “Protocol.”  This seems fine and normal until I read the paragraph that says you can define some of the methods as “Optional.”  What?</p>
<p>Let me put it in C# terms so you can understand it.  In C# it would look like this:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:60464cb2-395c-47e9-9ed3-a55df9c8a2e5" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
public interface ILovePuppies
{
   private void HugThem();
   private void SqueezeThem();

   perhaps Corpse KillThem(); // Implement this one
                              //only if you feel like it.

}
</pre></p>
</div>
<p>This is not a joke.  I still can’t quite figure out what this is for, but it is kind of interesting.</p>
<p>Another thing I found interesting is Objective-C has this thing called a “Selector.”  It is not a function pointer, it is a variable that references the name of a method.</p>
<p>How is this different than a function pointer?</p>
<p>It is actually the name of the method being referenced.  So if you have a class Dog that has a method “Wag” and you have a class WildGuesser who has a method “Wag”, passing them the “Wag” selector will cause very different results.  How bizarre.</p>
<h2>It’s weird to get sucked into the Mac world</h2>
<p>It’s actually kind of funny.  Here were all us Java and C# programmers off basically doing the same thing; creating our interfaces and arguing about dependency injection and mocking our unit tests and these Mac geeks with their bow ties and designer jeans were going a totally different direction.</p>
<p>It was only by random chance that our two parallel universes should violently collide.  The iPhone came out and suddenly all these strange “Mac boys” were teaching us this new old language and reminding us to free up own memory again.</p>
<p>FOR GOD&#8217;S SAKE I JUST IMPORTED A C HEADER FILE FOR THE FIRST TIME IN 10 YEARS!  THIS IS CRAZY!</p>
<p>But, I have to admit it is actually kind of fun.</p>
<h2>Sometimes a change of pace is refreshing</h2>
<p>I don’t mean my harsh language to be derogatory towards you Mac heads out there.  You know you are cool, your boy Steve is leading this century&#8217;s computing revolution.</p>
<p>I honestly mean that.  Good job guys, you may just take over the world.</p>
<p>I’m actually enjoying this experience and beginning to think that if I come out alive, I will have gained some very valuable insights into programming in C# and Java.  It is good sometimes to view something from a totally completely different perspective.</p>
<p>Who knows maybe I’ll get to write that Objective-C vs Java vs C# post I&#8217;ve been dreaming of.</p>
<p>But what about…</p>
<h2>MonoTouch?</h2>
<p>Meh.  If I am going to program for a platform, I am going to program for that platform.  I’m not going to half learn how to program for the iPhone and learn on the C# crutch.  I didn’t do that for Android and I’m not going to do it for iPhone either.</p>
<p>Why?</p>
<p>Because I am stubborn and cranky?  Partially, but I actually have a few sensible reasons also:</p>
<ol>
<li><a href="http://monodroid.net/">MonoDroid</a> and <a href="http://monotouch.net/">MonoTouch</a> both implement another layer over the phone’s framework.  Adding this additional layer makes it harder to do low level stuff, and with something as low level as a phone, doing low level stuff is often important.</li>
<li>You are still using the underlying framework for either Android or iPhone.  It is not like using C# code behind the scenes allows you to write a Silverlight UI that you can use on any of the mobile platforms.  You still have to learn the entire phone development framework, which dovetails into point three…</li>
<li>It is much easier to get help and find resources for raw Android or iPhone development than for MonoX development.  Not trying to bash the Mono projects here, but most of mobile programming is spent googling for how to do things.  By sticking with C# you are really limiting yourself in terms of finding answers.</li>
<li>Change and learning different things is good.  I’m not sure you can fully appreciate the design of a framework or platform unless you develop against it the way it was designed.  I could be wrong, but I think there is a potential “lost in translation” problem in using C# on the iPhone or Android platforms.</li>
</ol>
<p>After I learn iPhone development, I might try MonoTouch and see if it makes my life easier, but I need a good baseline first.</p>
<p>Well, I’m off on my journey.  Going to head on to the back of the wardrobe in the “Spare-Oom.”  I have to meet Mr. Tumnus, we are having tea with Mr. Wozniak and Mr. Jobs.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/02/mrtumnus.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="mrtumnus" src="http://complextosimple.files.wordpress.com/2011/02/mrtumnus_thumb.jpg?w=462&#038;h=478" border="0" alt="mrtumnus" width="462" height="478" /></a></p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.  Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1244/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1244&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/02/01/objective-c-here-i-come/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/02/iphone_thumb.jpg" medium="image">
			<media:title type="html">iphone</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/02/mrtumnus_thumb.jpg" medium="image">
			<media:title type="html">mrtumnus</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Var + As, a Neat Little Trick</title>
		<link>http://simpleprogrammer.com/2010/12/16/using-var-as-a-neat-little-trick/</link>
		<comments>http://simpleprogrammer.com/2010/12/16/using-var-as-a-neat-little-trick/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 03:30:18 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2010/12/16/using-var-as-a-neat-little-trick/</guid>
		<description><![CDATA[Perhaps this is something everyone already knew about, but I recently came across this little C# combo that solves one of my major outstanding issues with the var keyword. I consider var to actually be quite a useful language feature to reduce repetition and make your code slightly more flexible for refactoring, but I’ve always [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1199&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Perhaps this is something everyone already knew about, but I recently came across this little C# combo that solves one of my major outstanding issues with the <em>var</em> keyword.</p>
<p>I consider <em>var</em> to actually be <a href="http://simpleprogrammer.com/2010/05/05/do-you-have-a-case-of-var-guilt/">quite a useful language feature</a> to reduce repetition and make your code slightly more flexible for refactoring, but I’ve always had one little problem with it.</p>
<h2>What if I want a base class type or interface?</h2>
<p>I most often run into this problem when I am working with lists.</p>
<p>Have you ever written some code like this?</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:2be1658f-6da3-40e8-a163-bb81d2e549da" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp; pad-line-numbers: true;">
var myList = new List&lt;int&gt;();
</pre>
</pre>
</div>
<p>&#160;</p>
<p>The problem with this code is that we are stuck with the concrete <em>List</em> implementation for our variable <em>myList</em>, because we don’t have a way of specifying that we actually want an <em>IEnumerable</em> to be our reference type.</p>
<p>The solution is so simple that I am a bit surprised I didn’t think of it earlier.</p>
<p>I had always assumed that I just couldn’t use <em>var</em> there and would have to declare the type like so:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:1f27219b-7100-45b5-ba1c-e6d63af31551" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp;">
IEnumerable&lt;int&gt; myList = new List&lt;int&gt;();
</pre>
</pre>
</div>
<p>&#160;</p>
<p>But we can actually just use <em>as</em> to keep our <em>var</em> in place if we want to.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:eb2c46c5-7822-4728-8f43-197216f5946a" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp;">
var myList = new List&lt;int&gt; as IEnumerable&lt;int&gt;
</pre>
</pre>
</div>
<p>&#160;</p>
<p>So it’s actually a little more verbose, but I think it is a bit more clear, and it is more consistent if you are using <em>var</em> everywhere else.</p>
<h2>There has to be a better use</h2>
<p>I’ve been racking my brain trying to come up with more useful ways to use this little combo, but I can’t really seem to come up with anything.</p>
<p>It seems like there has to be something else you could use this combo for.</p>
<p>What do you think?&#160; Any ideas?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1199/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1199/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1199/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1199&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/12/16/using-var-as-a-neat-little-trick/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>A Simple Wrapper To Make Things More Fluent</title>
		<link>http://simpleprogrammer.com/2010/10/12/a-simple-wrapper-to-make-things-more-fluent/</link>
		<comments>http://simpleprogrammer.com/2010/10/12/a-simple-wrapper-to-make-things-more-fluent/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 15:52:35 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Refactoring]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2010/10/12/a-simple-wrapper-to-make-things-more-fluent/</guid>
		<description><![CDATA[This post is really a continuation from my last post on using a method that takes an Action to address cross cutting concerns, like logging, without having to go to a full blown AOP implementation. Someone mentioned in the comments that it wasn’t very clear exactly what was going on with the final code.&#160; I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1135&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post is really a continuation from my <a href="http://simpleprogrammer.com/2010/10/09/aspect-oriented-programming-with-action/">last post</a> on using a method that takes an <em>Action</em> to address cross cutting concerns, like logging, without having to go to a full blown AOP implementation.</p>
<p>Someone mentioned in the comments that it wasn’t very clear exactly what was going on with the final code.&#160; I tend to agree that this:</p>
<p><strong>LogOnError(_riceCooker.Cook);</strong></p>
<p>… is not very clear.</p>
<p>Really, there are two problems with this code that I can see.</p>
<ol>
<li>It is not clear what this is going to do or whether or not <em>LogOnError</em> or <em>Cook</em> is the method we are concerned about.</li>
<li>It’s not very self-discoverable at all.&#160; If we had a library of useful wrapper methods like these, we wouldn’t have a good intellisense way to know what they are.</li>
</ol>
<p>I can solve both of those issues, but doing so starts to move us into a weird zone where I am not quite sure I feel comfortable.&#160; But, nevertheless, in the name of science…</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/10/wrapped.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="wrapped" border="0" alt="wrapped" src="http://complextosimple.files.wordpress.com/2010/10/wrapped_thumb.jpg?w=478&#038;h=327" width="478" height="327" /></a></p>
<h2>Let’s start backwards</h2>
<p>Liking fluent interfaces, here is the kind of syntax that I would prefer to be able to use:</p>
<p><strong>Wrapper.Wrap(_riceCooker.Cook).With.LogOnError();</strong></p>
<p>It is a little bit longer syntax, but I like it for a few reasons:</p>
<ol>
<li>It clearly indicates what is going on here.&#160; We are wrapping a method call using a wrapper.&#160; We are wrapping with a method called <em>LogOnError</em>.</li>
<li>You get intellisense all the way.&#160; The correct implementation of this, should let me Type <em>With</em> + ‘.’ and then see a list of all the possible wrapping methods I have implemented.&#160; This makes the wrapping set of methods self-discoverable.</li>
</ol>
<p>I really like the idea of being able to easily change the functionality of the wrapping just by changing the last part of the line.&#160; For example, if we had implemented a wrapping method that was <em>LogAndAbortOnError(),</em> we could change our code to use that pretty easily.</p>
<p><strong>Wrapper.Wrap(_riceCooker.Cook).With.LogAndAbortOnError();</strong></p>
<p>If we implement this correctly, intellisense will give us our options.</p>
<h2>Making it so</h2>
<p>Creating a fluent syntax in C# can often involve quite a bit of magic and voodoo.&#160; I always like to gather my reagents before embarking on such a journey.</p>
<p>So grab a live chicken, a stapler, and a sharp knife and let’s go!</p>
<p>First step, let’s simplify this.&#160; The <em>With</em> is nice, but it is just for flow, we don’t really need it.&#160; So let’s figure out how to implement our syntax without the <em>With</em> and add it in afterwards.</p>
<p><strong>Wrapper.Wrap(_riceCooker.Cook).LogOnError();</strong></p>
<p>First the easy way.</p>
<ol>
<li>Create a static <em>Wrapper</em> class with a <em>Wrap</em> method that takes an <em>Action</em> and returns an <em>Action</em>.&#160; (We’ll use this to convert whatever we pass in to an <em>Action</em>, so that we can use a Lambda expression or any method call there.)</li>
<li>Create a static extension method that operates on an <em>Action</em>.&#160; Call it <em>LogOnError</em>.</li>
</ol>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:c1efd5ff-3981-41d4-ac9f-e6cba38cbda6" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp; pad-line-numbers: true;">
public static class Wrapper
{
    public static Action Wrap(Action action)
    {
        return action;
    }
        
    public static void LogOnError(this Action action)
    {
        try
        {
            action();
        }
        catch (Exception exception)
        {
            // Log the exception here
        }
    }
}
</pre>
</pre>
</div>
<p>&#160;</p>
<p>Not too bad.&#160; Not a large amount of magic going on here.&#160; Just using an extension method.</p>
<p>But, we already have a problem.&#160; Using a plain old <em>Action</em> is going to give us too many choices in the intellisense drop down.&#160; It could make it hard to know what our real options are and when we try and add the <em>With</em> syntax later, we will need to use a property off of an object we return from the <em>Wrap</em> method.</p>
<h2></h2>
<h2></h2>
<h2></h2>
<h2>Making it better</h2>
<p>We can fix this by actually wrapping the <em>Action</em> with a custom type that we can add our methods to.</p>
<p>Instead of <em>Wrap</em> returning an <em>Action</em>, it will return a <em>WrappedAction</em>.</p>
<p><div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:bb8046ee-1e26-44d7-88bd-a474ed8d1273" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp;">
public static class Wrapper
{
    public static WrappedAction Wrap(Action action)
    {
        return new WrappedAction() {Action = action};
    }
        
    public static void LogOnError(this WrappedAction wrappedAction)
    {
        try
        {
            wrappedAction.Action();
        }
        catch (Exception exception)
        {
            // Log the exception here
        }
    }

    public class WrappedAction
    {
        public Action Action { get; set; }
    }
}
</pre>
</pre>
</div>
<p>Looking better.&#160; Now when we put a ‘.’ at the end of our <em>Wrap</em> call we only see <em>LogOnError</em> as an option.</p>
<p>We can be sure now that if we create an extension method for a <em>WrappedAction</em>, we will make sure that method is self-discoverable.&#160; Before, the generic <em>Action</em> extension&#160; method could make our method show up places that we don’t want it to and can get lost in the other methods on <em>Action</em>.</p>
<h2></h2>
<h2>Making it done</h2>
<p>The last thing we need to do is add the <em>With</em>.</p>
<p>Ideally, when we hit the ‘.’ on the end of the <em>Wrap</em> method, we want to see <em>With</em> as an option.&#160; When we hit the ‘.’ on the end of the <em>With</em> property, we want to see <em>LogOnError</em> as an option.</p>
<p>In order to accomplish this we need to:</p>
<ol>
<li>Add a <em>With</em> property to the <em>WrappedAction</em>.</li>
<li>Have the <em>With</em> property be of a new type (<em>WrappedActionTarget</em>) so that we can add our extension methods for that new type.</li>
<li>Change the extension method to operate on the new type.</li>
</ol>
<p>Here is what we end up with:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:2c3a8ddf-389d-40bb-bc75-56c4aeb0ed07" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp;">
public static class Wrapper
{
    public static WrappedAction Wrap(Action action)
    {
        return new WrappedAction() { Action = action };
    }

    public static void LogOnError(this WrapperMethodTarget target)
    {
        try
        {
            target.WrappedAction.Action();
        }
        catch (Exception)
        {
            Console.Write(&quot;Logging this error&quot;);
        }
    }
}

public class WrapperMethodTarget
{
    public WrappedAction WrappedAction { get; set; }
}

public class WrappedAction
{
    public Action Action { get; set; }

    public WrapperMethodTarget With
    {
        get
        {
            return new WrapperMethodTarget() { WrappedAction = this };
        }
    }
}
</pre>
</pre>
</div>
<p>&#160;</p>
<p>Now we can use the syntax of:</p>
<p><strong>Wrapper.Wrap(_riceCooker.Cook).With.LogOnError();</strong></p>
<p>We can move that <em>LogOnError</em> method out to another class, or create new extension methods somewhere else.&#160; I just put it in there to avoid creating another class.</p>
<h2>Is this really practical?</h2>
<p>I don’t know.&#160; To be honest, I was playing around with creating extension methods that work on Actions and I came up with this way to use them.</p>
<p>I could see making a wrapping library that had different kinds of ways you would wrap method calls built into it.&#160; It could allow you to specify how you log in a configuration and then you would get all of this common stuff automatically.</p>
<p>Even if it is not practical, it’s pretty fun, and it demonstrates the power of <em>Action</em>, or rather functional programming in general.</p>
<h6><strong>As always, you can subscribe to this </strong><a href="http://feeds.feedburner.com/MakingTheComplexSimple"><strong>RSS feed</strong></a><strong> to follow my posts on Making the Complex Simple.&#160; Feel free to check out </strong><a href="http://elegantcode.com/"><strong>ElegantCode.com</strong></a><strong> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter </strong><a href="http://twitter.com/jsonmez"><strong>here</strong></a><strong>.</strong></h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1135&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/10/12/a-simple-wrapper-to-make-things-more-fluent/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/10/wrapped_thumb.jpg" medium="image">
			<media:title type="html">wrapped</media:title>
		</media:content>
	</item>
		<item>
		<title>Aspect Oriented Programming with Action&lt;&gt;</title>
		<link>http://simpleprogrammer.com/2010/10/09/aspect-oriented-programming-with-action/</link>
		<comments>http://simpleprogrammer.com/2010/10/09/aspect-oriented-programming-with-action/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 19:42:06 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2010/10/09/aspect-oriented-programming-with-action/</guid>
		<description><![CDATA[Aspect Oriented Programming (AOP) is a pretty great concept. It is a little difficult to implement though. To be honest, I don’t think I’ve ever really seen it successfully implemented.  I mean sure, I’ve seen examples of how you could use it for “cross-cutting” concerns like logging. The problem is it is usually pretty difficult [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1131&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect Oriented Programming</a> (AOP) is a pretty great concept.</p>
<p>It is a little difficult to implement though.</p>
<p>To be honest, I don’t think I’ve ever really seen it successfully implemented.  I mean sure, I’ve seen examples of how you could use it for “cross-cutting” concerns like logging.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/10/mad_scientist.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Mad_scientist" src="http://complextosimple.files.wordpress.com/2010/10/mad_scientist_thumb.gif?w=464&#038;h=617" border="0" alt="Mad_scientist" width="464" height="617" /></a></p>
<p>The problem is it is usually pretty difficult to use, and the only real practical application I can ever come up with is logging.  I know, it is probably just my lack of knowledge in the area, but if you bear with me I’ll show you a neat little trick you can use to address cross-cutting concerns by doing something similar to what AOP does using Action&lt;&gt;.</p>
<h2>Putting it all in one place</h2>
<p>The main problem AOP tries to solve is taking aspects of your software that exist in many different places and condensing them into one place for you to maintain.</p>
<p>Exception handling and logging tend to be the most infamous of these cross-cutting concerns.  Many places in your code you no doubt have many instances where you catch an exception and the only thing you can really do is log it.</p>
<p>I’m going to show you a little easy way to do that using Action&lt;&gt;.</p>
<p>Giving credit where credit is due, I got this idea from some code that a coworker of mine, Subha Tarafdar, wrote.  (He is a genius.)</p>
<p>He wrote some code to basically do what I am going to show you, but with retrying database queries.  He was able to reduce many places in the code base where we had repeated logic to retry executing database queries when getting a deadlock or timeout.</p>
<h2>Does this code belong to you?</h2>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:f2d7eb61-812a-4fd5-8561-9629ccd7d142" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
public void MakeRice()
{
    try
    {
        _riceCooker.Cook();
    }
    catch (Exception exception)
    {
        // Don't care if this fails,
        // there is nothing we can do about it.
        Logger.Log(exception.Message);
    }
}
</pre></p>
</div>
<p>&nbsp;</p>
<p>Ignore that I am catching a general exception here.  It is a bad practice, but sometimes all you are going to do is log whatever bad thing happens and move on.</p>
<p>It’s pretty common to do something in a try block and catch an exception only to log it.</p>
<p>Think about how many times this code or something similar to it might be sprinkled throughout your code base.</p>
<h2>Action&lt;&gt; to the rescue</h2>
<p>If you’re not familiar with Action&lt;&gt; take a look at <a href="http://simpleprogrammer.com/2010/09/24/explaining-what-action-and-func-are/">this post</a> I did that gives a very simple explanation for how it works.</p>
<p>We can take the logic of the try, catch, and log exceptions and put it into a method that only varies by what action we do.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:a2364bb0-20c6-4565-9562-ea07d996bc33" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public static void LogOnFailure(Action action)
{
    try
    {
        action();
    }
    catch (Exception exception)
    {
        Logger.Log(exception.Message);
    }
}
</pre></p>
</div>
<p>&nbsp;</p>
<p><a href="http://simpleprogrammer.com/2010/01/29/static-methods-will-shock-you/">I’m not a big fan</a> of static methods but in certain cases they make sense.  The alternative is to have all of this code sprinkled throughout your code base.</p>
<p>Now that we have this method, we can do anything we want and know that if there is an error it will be logged.</p>
<p>Check this out:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:75210c50-8eaa-4d5b-805c-8e172cc97c60" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
LogOnFailure(_riceCooker.Cook);
LogOnFailure(KickACat);
LogOnFailure(() =&gt;
                    {
                        Wakeup();
                        SmellTheRoses();
                    }
            );
</pre></p>
</div>
<p>&nbsp;</p>
<p>And if you decide you want to change how you log the error or what you do on it, you can change it all in one place.</p>
<h2>Not just for logging</h2>
<p>You can apply this kind of solution in many places where you have cross cutting concerns in your code base.</p>
<p>Here are a few suggestions for places you might consider this kind of a solution:</p>
<ul>
<li>Retrying on failure logic</li>
<li>Using an alternative service for a failure (web service “A” failed, but we can use web service “B”)</li>
<li>Database connection and connection closing logic.  (Open connection, do something, close connection.)</li>
</ul>
<h6><strong>As always, you can subscribe to this </strong><a href="http://feeds.feedburner.com/MakingTheComplexSimple"><strong>RSS feed</strong></a><strong> to follow my posts on Making the Complex Simple.  Feel free to check out </strong><a href="http://elegantcode.com/"><strong>ElegantCode.com</strong></a><strong> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter </strong><a href="http://twitter.com/jsonmez"><strong>here</strong></a><strong>.</strong></h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1131&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/10/09/aspect-oriented-programming-with-action/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/10/mad_scientist_thumb.gif" medium="image">
			<media:title type="html">Mad_scientist</media:title>
		</media:content>
	</item>
		<item>
		<title>The Power of Func&lt;&gt;</title>
		<link>http://simpleprogrammer.com/2010/06/18/the-power-of-func/</link>
		<comments>http://simpleprogrammer.com/2010/06/18/the-power-of-func/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 21:35:12 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=949</guid>
		<description><![CDATA[I remember why I love C#. After spending the last two years or so writing mainly Java code, getting back into Visual Studio felt a little awkward and painful. Where did all my keyboard shortcuts go?  Why can’t I navigate to members in a class?  Oh, yes Resharper&#8230; ah that’s better. But then it happened. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=949&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>I remember why I love C#.</strong></p>
<p>After spending the last two years or so writing mainly Java code, getting back into Visual Studio felt a little awkward and painful.</p>
<p>Where did all my keyboard shortcuts go?  Why can’t I navigate to members in a class?  Oh, yes <strong>Resharper</strong>&#8230; ah that’s better.</p>
<p>But then it happened.</p>
<p>I was minding my own business writing some code… la la la</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:757d2684-4b1c-4de7-a7dc-27c9ff9695f4" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public bool IsYummy()
{
    if(!areOverridesLoaded)
    {
        LoadOverrides();  // loads the override from the database into this.theOverride
    }

    if(this.theOverride != null)
    {
        return theOverride.IsYummy.GetValueOrDefault(food.IsYummy);
    }

    return food.IsYummy;
}

public bool IsFruit()
{
    if(!areOverridesLoaded)
    {
        LoadOverrides();
    }

    if(this.theOverride != null)
    {
        return theOverride.IsFruit.GetValueOrDefault(food.IsFruit);
    }

    return food.IsFruit;
}

public bool IsVegetable()
{
    if(!areOverridesLoaded)
    {
        LoadOverrides();
    }

    if(this.theOverride != null)
    {
        return theOverride.IsVegetable.GetValueOrDefault(food.IsVegetable);
    }

    return food.IsVegetable;
}
</pre></p>
</div>
<p>Oh my, repeated code!  What ever shall I do?</p>
<p>Hmm… It varies by property names only.</p>
<p>Surely I can refactor out the override loading code.  Can’t put it in the constructor, because the goal is to lazy load the overrides from the database.</p>
<h2>Func&lt;&gt; to the rescue!</h2>
<p>This is the power of Func.  Of delegates really.  You can’t do this in Java folks… Hold on to your chair.  Here we go…. Whee…..</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:7a0c67b7-3009-4e63-aade-40c1f1757c2d" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
private bool ReturnValueOrDefault(Func&lt;Food, bool?&gt; FoodProperty, bool defaultValue)
{
    if (!areOverridesLoaded)
    {
        LoadOverrides();
    }

    if (this.theOverride != null)
    {
        return foodProperty(this.theOverride).GetValueOrDefault(defaultValue);
    }

    return defaultValue;
}

public bool IsYummy()
{
    ReturnValueOrDefault(o =&gt; o.IsYummy, food.IsYummy);
}

public bool IsFruit()
{
    ReturnValueOrDefault(o =&gt; o.IsFruit, food.IsFruit);
}

public bool IsVegetable()
{
   ReturnValueOrDefault(o =&gt; o.IsVegetable, food.IsVegetable);
}
</pre></p>
</div>
<p>Good has won…</p>
<p>Evil has been defeated…</p>
<p>Code has been <a href="http://elegantcode.com/2010/06/06/the-best-code-you-will-ever-write/">deleted</a>…</p>
<p>Thank you Func&lt;&gt;</p>
<p>Don’t forget the <a href="http://simpleprogrammer.com/2010/02/25/super-combo-map-function-pointer/">Super Combo</a>!</p>
<p>Also, check out the <a href="http://simpleprogrammer.com/how-to-build-agile-software/">new page</a> I created, a compilation of useful posts I have written about building software in an Agile way.</p>
<p><strong>As always, you can subscribe to this </strong><a href="http://feeds.feedburner.com/MakingTheComplexSimple"><strong>RSS feed</strong></a><strong> to follow my posts on Making the Complex Simple.  Feel free to check out </strong><a href="http://elegantcode.com/"><strong>ElegantCode.com</strong></a><strong> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter </strong><a href="http://twitter.com/jsonmez"><strong>here</strong></a><strong>.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/949/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/949/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/949/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/949/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/949/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/949/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/949/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/949/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=949&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/06/18/the-power-of-func/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>Merge In&#8230; Merge Out&#8230;</title>
		<link>http://simpleprogrammer.com/2010/06/02/merge-in-merge-out/</link>
		<comments>http://simpleprogrammer.com/2010/06/02/merge-in-merge-out/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 15:54:39 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Process Improvement]]></category>
		<category><![CDATA[Source Control]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=898</guid>
		<description><![CDATA[Merging is source control Kung-Fu. I’ve seen many people get taken to the mat when trying to merge.  Today, I’m going to give you a simple technique that can help save you the embarrassment of your favorite source control program kicking you right in the head. Bring the plate to the food Often as a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=898&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Merging is source control Kung-Fu.</p>
<p>I’ve seen many people get taken to the mat when trying to merge.  Today, I’m going to give you a simple technique that can help save you the embarrassment of your favorite source control program kicking you right in the head.</p>
<h2>Bring the plate to the food</h2>
<p>Often as a kid, the table would be set and dinner would be ready.  I would try and take some food from the kitchen over to my plate on the table.  (Grab the hamburger and carry it over to the plate.)</p>
<p>My dad would often tell me,  “Bring the plate to the food.”</p>
<p>Which would mean that I would have to take the plate from the table.  Bring it to the kitchen.  Put the food on the plate.  Bring the plate back to the table.  Oh, what a hassle.</p>
<p>Less food ended up on the floor that way.  Now it seems obvious to me.  But, back then it didn’t.</p>
<h2>So it is with merging</h2>
<p>It is exactly the same way with merging.</p>
<p>Wise-man once say:</p>
<blockquote><p>If you want to merge to a location, you must first merge from the location</p></blockquote>
<p>Anytime you are about to merge to some branch, always merge from that branch first.</p>
<p>Let’s say that you created a branch off of your trunk.  You started working in that branch and you are done with whatever you are doing there.  You are ready to merge it back up to trunk.</p>
<ul>
<li>First merge trunk to your branch</li>
<li>Resolve any conflicts</li>
<li>Test on your branch</li>
<li>Then merge your branch (that has the trunk changes already) into trunk</li>
</ul>
<h2>Why can’t I just merge to the destination, why merge in first?</h2>
<p>It may seem like a bunch of overhead, but if you’ve ever merged to trunk or a release branch and broke it for everyone, then scrambled to try and fix it, you’ll probably see the benefit in making sure that all merges to release branches or trunk are trivial.</p>
<p>A trivial merge is a merge that can be automatically done by your source control.  It doesn’t require human interaction.</p>
<p>If you merge in, and then merge out, the merge out will always be a trivial merge.  So in reality you&#8217;re not really adding any overhead at all.  You are just handling the possibly difficult merge on your branch as opposed to the trunk or release branch.</p>
<p>Another important reason is that you want to be able to test your changes with the other changes that have happened in the system since you branched off.  Most of the time other changes will be happening at the same time you are making changes.</p>
<p>The only way to know what the interactions will be is to test them.  The best place to test them is on your local branch so that you don’t interfere with everyone else.</p>
<p><a href="http://www.lostechies.com/blogs/derickbailey/default.aspx">Derick Bailey</a> provides an excellent detailed description of what I am talking about in <a href="http://www.lostechies.com/blogs/derickbailey/archive/2009/07/21/branch-per-feature-source-control-part-2-how-theory.aspx">his post on merging</a>.  He calls it the merge dance.</p>
<h2>My dev cave</h2>
<p>Without further adieu, here are the pictures of my dev cave I set up for my new job.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/06/devcave1.jpg"><img style="display:inline;border-width:0;" title="devcave1" src="http://complextosimple.files.wordpress.com/2010/06/devcave1_thumb.jpg?w=481&#038;h=360" border="0" alt="devcave1" width="481" height="360" /></a></p>
<p><a href="http://complextosimple.files.wordpress.com/2010/06/devcave2.jpg"><img style="display:inline;border-width:0;" title="devcave2" src="http://complextosimple.files.wordpress.com/2010/06/devcave2_thumb.jpg?w=489&#038;h=366" border="0" alt="devcave2" width="489" height="366" /></a></p>
<p><strong>As always, you can subscribe to this </strong><a href="http://feeds.feedburner.com/MakingTheComplexSimple"><strong>RSS feed</strong></a><strong> to follow my posts on Making the Complex Simple.  Feel free to check out </strong><a href="http://elegantcode.com/"><strong>ElegantCode.com</strong></a><strong> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter </strong><a href="http://twitter.com/jsonmez"><strong>here</strong></a><strong>.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/898/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=898&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/06/02/merge-in-merge-out/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/06/devcave1_thumb.jpg" medium="image">
			<media:title type="html">devcave1</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/06/devcave2_thumb.jpg" medium="image">
			<media:title type="html">devcave2</media:title>
		</media:content>
	</item>
		<item>
		<title>Book Review: The Definitive Antlr Reference: Building Domain-Specific Languages</title>
		<link>http://simpleprogrammer.com/2010/04/16/book-review-the-definitive-antlr-reference-building-domain-specific-languages/</link>
		<comments>http://simpleprogrammer.com/2010/04/16/book-review-the-definitive-antlr-reference-building-domain-specific-languages/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 16:15:59 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=687</guid>
		<description><![CDATA[Took me awhile, but I finally finished reading: The Definitive Antlr Reference: Building Domain-Specific Languages (Pragmatic Programmers) It is hard to separate reviewing ANTLR from reviewing this book, which is written by the author of ANTLR.  ANTLR is a fantastic tool, which really opened my eyes to the capabilities of creating DSLs to solve what otherwise [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=687&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://complextosimple.files.wordpress.com/2010/04/antlrbook.jpg"><img class="alignnone size-full wp-image-688" title="antlrbook" src="http://complextosimple.files.wordpress.com/2010/04/antlrbook.jpg?w=500" alt=""   /></a></p>
<p>Took me awhile, but I finally finished reading: <a href="http://www.amazon.com/gp/product/0978739256?ie=UTF8&amp;tag=makithecompsi-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0978739256">The Definitive Antlr Reference: Building Domain-Specific Languages (Pragmatic Programmers)</a><img style="border:none!important;margin:0!important;" src="http://www.assoc-amazon.com/e/ir?t=makithecompsi-20&amp;l=as2&amp;o=1&amp;a=0978739256" border="0" alt="" width="1" height="1" /></p>
<p>It is hard to separate reviewing ANTLR from reviewing this book, which is written by the author of ANTLR.  ANTLR is a fantastic tool, which really opened my eyes to the capabilities of creating DSLs to solve what otherwise would be very difficult problems.   I looked up many resources on ANTLR, and by far this book is the best resource available.  If you are going to try to learn to use ANTLR buy this book.</p>
<p><strong>Good:</strong></p>
<ul>
<li>First few chapters start out very simple and easy to understand.</li>
<li>Very good examples of how to use ANTLR with real code and real programming languages.</li>
<li>Excellent coverage of each feature of the tool, and why it was built that way.</li>
<li>Builds on concepts of language parsing while introducing ANTLR features.</li>
</ul>
<p><strong>Bad:</strong></p>
<ul>
<li>Gets a bit complicated near the end of the book.  Some of the examples and concepts get pretty deep into complex language parsing, although there is a warning about it.</li>
<li>Missing information on best practices for using ANTLR.  (Would have liked to see a chapter dedicated to that subject.)</li>
</ul>
<p><strong>What I learned:</strong></p>
<p>I had no idea that <a href="http://simpleprogrammer.com/2010/03/10/internal-dsl-becomes-external-dsl/">creating a DSL could be so easy</a>.  Language parsing really is not that hard.  It is intimidating to think about creating a DSL, but with the right tools, it is not really very difficult at all.</p>
<p>I learned how to use ANTLR, and got most of my questions answered about how to accomplish pretty much anything I would need to do in ANTLR.</p>
<p>There was a topic about using string templates, that made me realize how useful it is to not hard code the code generation into the tree parsing when creating a language.  By separating out the code generation into templates, it is possible to target several different languages easily.</p>
<p>I got a much better understanding about general language parsing and design, as well as a good understanding of Abstract Syntax Trees (ASTs), why you would use them, and how to use them effectively.  I got a good understanding of why you would need a multi-pass parser for parsing a language.</p>
<p>This book will change the way I look at many problems.  I feel pretty confident in implementing DSLs to solve the right kind of problems after reading this book.</p>
<p>I have implemented hand written language parsers in the past, but after reading this book, will never do that again and would highly recommend reading this book and checking out DSLs in general.  It is easier than you think.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/687/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=687&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/04/16/book-review-the-definitive-antlr-reference-building-domain-specific-languages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/04/antlrbook.jpg" medium="image">
			<media:title type="html">antlrbook</media:title>
		</media:content>

		<media:content url="http://www.assoc-amazon.com/e/ir?t=makithecompsi-20&#38;l=as2&#38;o=1&#38;a=0978739256" medium="image" />
	</item>
		<item>
		<title>iPad is Punching Your Kindle and Netbook in the Stomach</title>
		<link>http://simpleprogrammer.com/2010/04/05/ipad-is-punching-your-kindle-and-netbook-in-the-stomach/</link>
		<comments>http://simpleprogrammer.com/2010/04/05/ipad-is-punching-your-kindle-and-netbook-in-the-stomach/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 01:58:53 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=606</guid>
		<description><![CDATA[I&#8217;m not exactly and Apple enthusiast. I don&#8217;t own a mac for the sole purpose of running Windows in a virtual machine so that I can actually do my work. In fact, I bought a Droid. But I bought an iPad on Saturday anyway!  Why? Well, like any good software developer, I don&#8217;t like duplication. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=606&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not exactly and Apple enthusiast.</p>
<p>I don&#8217;t own a mac for the sole purpose of running Windows in a virtual machine so that I can actually do my work.</p>
<p>In fact, <a href="http://simpleprogrammer.com/2010/01/07/i-am-assimilated-to-the-google-collective-droid/">I bought a Droid</a>.</p>
<h2>But I bought an <a href="http://store.apple.com/us/browse/home/shop_ipad/family/ipad?afid=p219|GOUS&amp;amp;cid=OAS-US-KWG-iPad-US">iPad</a> on Saturday anyway!  Why?</h2>
<p><a href="http://complextosimple.files.wordpress.com/2010/04/product-wifi.jpg"><img class="alignnone size-full wp-image-610" title="product-wifi" src="http://complextosimple.files.wordpress.com/2010/04/product-wifi.jpg?w=500" alt=""   /></a></p>
<p>Well, like any good software developer, I don&#8217;t like duplication.  I don&#8217;t like two devices of similar size taking up space and having to be charged.</p>
<p>Sometime last week, I realized that my Kindle DX and my netbook, could both be replaced by an iPad.  (At least I realized my Kindle DX could be, and once I actually used the iPad, realized the netbook also can be.)</p>
<p>I bought the device expecting it to be basically a replacement for my Kindle DX with color.  I thought that for almost the same price, I might as well get a device that is color, since I am really using the Kindle DX for mainly reading PDFs.</p>
<p>Even with just that functionality, it is a very good bargain. Both the iBooks application and Kindle&#8217;s own iPad application provide a better user experience than the Kindle or any other eReader that I know of.  There is just something about being able to turn pages, and have color images in your books, that makes it feel so much more like a real book.  You don&#8217;t really realize how much better the eReader experience can be until you try an iPad.</p>
<p>In addition, I have been pretty impressed with other aspects of the iPad that I had scoffed at before the release.  Perhaps the most impressive thing about an iPad is the screen.  It really does feel &#8220;magical&#8221;.  It is hard to explain, but the viewing angle, combined with the crisp colors and very responsive refresh are like nothing I have ever seen before.</p>
<p>Browsing the web and typing are much easier than I would have expected.  I can actually hold the iPad landscape and thumb type.  (Which might not be possible for some.)</p>
<h2>I spent a good amount of time this weekend staring at my netbook, trying to figure out why I would not put it on Ebay.</h2>
<p>I didn&#8217;t come up with a good answer.  There were some things that I might want to do on a laptop, that I couldn&#8217;t do on an iPad, but for pretty much everything I would want to do on a netbook, I could do it easier on an iPad.</p>
<p>One of the really important features of the iPad that makes it smack down netbooks is that it turns on instantly.  Having to boot up the netbook is enough of a deterrent to make it sit over in the corner unused, unless it is worth waiting 20 seconds to boot.  (Which most uses of it are not.)  The iPad is also another device that you don&#8217;t really have to manage configuration on.  If you are like me and have a home PC and a laptop, you probably aren&#8217;t thrilled with managing configuration on a netbook on top of all that.  The iPad just works.</p>
<p>After seeing how good <a href="http://www.popcap.com/games/pvz?mid=pvz_pc_en_full">Plant&#8217;s vs. Zombies</a> runs on the iPad, and how nice it looks, it may turn out to be a good gaming platform also.  Time will tell.</p>
<p>All in all, I haven&#8217;t had the iPad for more than 2 days so far, but I am liking it.  I intend to give a more in depth comparison between Android OS and iPhone OS, now that I have a device running each.  I highly recommend at least going out and demo-ing one, because it is kind of difficult to understand why the device is so neat until you&#8217;ve actually played with it yourself.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/04/fight_stomach_punch2_00-quick-e-mail-view.jpg"><img class="alignnone size-full wp-image-612" title="fight_stomach_punch2_00-quick-e-mail-view" src="http://complextosimple.files.wordpress.com/2010/04/fight_stomach_punch2_00-quick-e-mail-view.jpg?w=500&#038;h=603" alt="" width="500" height="603" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/606/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=606&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/04/05/ipad-is-punching-your-kindle-and-netbook-in-the-stomach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/04/product-wifi.jpg" medium="image">
			<media:title type="html">product-wifi</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/04/fight_stomach_punch2_00-quick-e-mail-view.jpg" medium="image">
			<media:title type="html">fight_stomach_punch2_00-quick-e-mail-view</media:title>
		</media:content>
	</item>
	</channel>
</rss>
