<?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</title>
	<atom:link href="http://simpleprogrammer.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://simpleprogrammer.com</link>
	<description>Software Development from John Sonmez&#039;s Perspective</description>
	<lastBuildDate>Thu, 17 May 2012 13:24:24 +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</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>Wrapping Callbacks</title>
		<link>http://simpleprogrammer.com/2012/05/06/wrapping-callbacks/</link>
		<comments>http://simpleprogrammer.com/2012/05/06/wrapping-callbacks/#comments</comments>
		<pubDate>Sun, 06 May 2012 16:50:34 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[asynchornous]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[progress dialog]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1528</guid>
		<description><![CDATA[I’ve recently had the problem of trying to display a progress dialog when executing an asynchronous operation and to dismiss that progress dialog when the operation completes. I wanted to build a way to do this that is generic to my application, so that it would work with any asynchronous operation in order to reduce [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1528&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve recently had the problem of trying to display a progress dialog when executing an asynchronous operation and to dismiss that progress dialog when the operation completes.</p>
<p>I wanted to build a way to do this that is generic to my application, so that it would work with any asynchronous operation in order to reduce duplication of writing progress dialog logic everywhere in the code.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/05/11-290x300.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border:0;" title="11-290x300" src="http://complextosimple.files.wordpress.com/2012/05/11-290x300_thumb.jpg?w=422&h=437" alt="11-290x300" width="422" height="437" border="0" /></a></p>
<h2></h2>
<h2>Looking at the problem</h2>
<p>So here is some basic pseudo-code of the problem.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:ec36b40c-e094-4b30-8840-83da5e283f22" class="wlWriterEditableSmartContent" style="margin:0;display:inline;float:none;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
public void DoCall()
{
   ShowProgressDialog();
   RemoteService.DoAsync(CallBackMethod);
}

public void CallBackMethod(Result result)
{
    HideProgressDialog();
    // Process result;
}
</pre></p>
</div>
<p>Now the problem with this code is that it would have to be repeated everywhere I want to make an asynchronous call and display a progress dialog.</p>
<p>If I want to do this in my application every time that I make an asynchronous call, I have to put this kind of code in many places in the application.</p>
<p>You can also see a mixing of responsibilities here.  We are handling UI related showing of a progress dialog split between an initial call and the callback.  It just seems a bit dirty to do things this way.</p>
<h2>Breaking it down</h2>
<p>So how can we solve this problem?</p>
<p>Go ahead and think of some way that you might be able to solve this.</p>
<p>…</p>
<p>One of the best ways that I have found to solve any problem like this is to work backwards.</p>
<p>Let us assume that any syntax we can think of is possible, and then only change the ideal syntax if it proves to not be possible.</p>
<p>What do I mean by this?</p>
<p>Simple, let’s come up with the way we want this code to look and we will worry about implementing it later.</p>
<p>It would be nice to be able to execute an asynchronous method and display a progress dialog with a one-liner, like so:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:77ecb568-e85e-4bf2-bd71-be97ec65e327" class="wlWriterEditableSmartContent" style="margin:0;display:inline;float:none;padding:0;"><pre class="brush: csharp;">
UIServiceCaller.ExecuteAsync(RemoteService.DoAsync, CallBackMethod);
</pre></p>
</div>
<p>If we could just do this wherever we want to make an asynchronous call and automatically have the progress dialog shown and dismissed, life would be wonderful.</p>
<h2>Solving the problem</h2>
<p>In order to solve this problem, we can do something very similar to a <a href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.</p>
<p>We can basically just wrap our callback method with a new callback that adds the functionality of dismissing our progress dialog.</p>
<p>So the idea will be that we will do the following steps in our <em><strong>ExecuteAsync</strong></em> method:</p>
<ol>
<li>Show the progress dialog</li>
<li>Wrap our callback with one that dismisses our dialog and then executes the callback.</li>
<li>Execute our asynchronous operation passing the new wrapped callback as the parameter.</li>
</ol>
<p><a href="http://complextosimple.files.wordpress.com/2012/05/gift-wrap-nature-lovers-easy-style-fabric-wrapping-1211-l.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="gift-wrap-nature-lovers-easy-style-fabric-wrapping-1211-l" src="http://complextosimple.files.wordpress.com/2012/05/gift-wrap-nature-lovers-easy-style-fabric-wrapping-1211-l_thumb.jpg?w=484&h=484" alt="gift-wrap-nature-lovers-easy-style-fabric-wrapping-1211-l" width="484" height="484" border="0" /></a></p>
<p>Here is what this looks like in code:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:dff51209-fb3b-4999-a3f7-efed4e524c52" class="wlWriterEditableSmartContent" style="margin:0;display:inline;float:none;padding:0;"><pre class="brush: csharp; html-script: false; light: false; wrap-lines: true;">
public static void ExecuteAsync(Action&lt;Action&lt;Result&gt;&gt; asyncMethod, Action callback)
{
   ShowProgressDialog();

   Action wrappedCallback = (r =&gt;
   {
      DismissProgressDialog();
      callback(r);
   }

   asyncMethod(wrappedCallback);
}
</pre></p>
</div>
<p>This code actually looks more complicated than it really is.</p>
<p>You will need to understand how Action works though.  If you don’t, check out this post I did <a href="http://simpleprogrammer.com/2010/09/24/explaining-what-action-and-func-are/">explaining Action and Func</a>.</p>
<h2>Understanding the solution</h2>
<p>It can be a bit hard to wrap your head around <em>Action </em>of type <em>Action</em> of type <em>Result.</em></p>
<p>Let me translate this to make it a bit easier.</p>
<p>The first parameter to <strong><em>ExecuteAsync </em></strong>is a method that takes another method as a parameter (the callback,) which takes a Result object as a parameter.</p>
<p>Go ahead and read that over until you get it.</p>
<p>So, the idea here is that we are passing in the method that is going to do the callback as the first parameter to your <strong><em>ExecuteAsync</em></strong> method.</p>
<p>Then we are passing in our actual callback as the 2nd parameter to <strong><em>ExecuteAsync</em>.</strong></p>
<p>The idea is that we are splitting apart the method and the callback it takes, so that we can insert our code to handle the dialog where we need to.</p>
<p>Now we can just call <strong><em>ExecuteAsync </em></strong>and pass it our method and its callback and progress dialog code will automatically be handled for us.</p>
<h2>Building on the idea</h2>
<p>We can expand upon this concept in several ways.</p>
<p>One thing we could do is also apply error handling logic to the callback wrapper method.  We could preprocess the result in some way before passing it to the callback.  This could allow us to display an error message or even retry a number of times before executing the callback.</p>
<p>Another thing we could do is to change the signature of the <strong><em>ExecuteAsync </em></strong>method so that it takes a type T instead of <em>Result; </em>this would allow us to handle any kind of return type and method, and the ExecuteAsync method would work with just about any asynchronous method call.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1528/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1528/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1528/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1528/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1528/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1528/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1528/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1528/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1528&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/05/06/wrapping-callbacks/feed/</wfw:commentRss>
		<slash:comments>2</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/2012/05/11-290x300_thumb.jpg" medium="image">
			<media:title type="html">11-290x300</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/05/gift-wrap-nature-lovers-easy-style-fabric-wrapping-1211-l_thumb.jpg" medium="image">
			<media:title type="html">gift-wrap-nature-lovers-easy-style-fabric-wrapping-1211-l</media:title>
		</media:content>
	</item>
		<item>
		<title>Predicting the Mobile Future</title>
		<link>http://simpleprogrammer.com/2012/04/23/predicting-the-mobile-future/</link>
		<comments>http://simpleprogrammer.com/2012/04/23/predicting-the-mobile-future/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 12:53:34 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1519</guid>
		<description><![CDATA[Many people have been asking me about my predictions for the future as far as the mobile platforms go. I thought I would take a moment to write up a blog post detailing out what I think we will see in the next couple of years for mobile phones and tablets. Windows 8 changes everything [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1519&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many people have been asking me about my predictions for the future as far as the mobile platforms go.</p>
<p>I thought I would take a moment to write up a blog post detailing out what I think we will see in the next couple of years for mobile phones and tablets.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/04/gn-psychic.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="gn-psychic" src="http://complextosimple.files.wordpress.com/2012/04/gn-psychic_thumb.jpg?w=484&h=484" alt="gn-psychic" width="484" height="484" border="0" /></a></p>
<h2>Windows 8 changes everything</h2>
<p>Or at least it has the potential to.</p>
<p>There are quite a few game changers built into Windows 8 that have a huge potential to influence and disrupt the market.</p>
<p><strong>One OS for mobile and desktop</strong></p>
<p>The idea that Windows 8 will essentially run on mobile and desktop is going to force the hand of other platforms.</p>
<p>I really like my iPad, but it could never be a total PC replacement.</p>
<p>Now imagine what happens if I can have an iPad, but it can snap right into a keyboard to make it into a laptop and it is running an OS that can do everything I need.</p>
<p>Suddenly I have to question why I need a separate iPad.</p>
<p>PC manufacturers have been chomping at the bit to break into the tablet market for some time now.  It was a slap in the face for Apple to produce the first generally accepted “good” tablet after so many PC manufacturers had tried and failed for years earlier.</p>
<p><strong>We can learn a lot from a tablet</strong></p>
<p>What makes the iPad so good?</p>
<p>In my opinion, 4 things:</p>
<ol>
<li>Extremely portable and lightweight</li>
<li>Good touchscreen input, so I don’t need a physical keyboard most of the time</li>
<li>App store!</li>
<li>Instant on</li>
</ol>
<p>There isn’t even a need for a Windows 8 tablet.  Instead, I predict we are going to see Windows 8 Ultrabooks with removable keyboards.</p>
<p>As long as this new class of computers can hit the 4 items I like about the iPad, it could really cause some disruption in that market.</p>
<h2></h2>
<h2>What about the cloud?</h2>
<p><a href="http://complextosimple.files.wordpress.com/2012/04/cloud_0.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="cloud_0" src="http://complextosimple.files.wordpress.com/2012/04/cloud_0_thumb.jpg?w=490&h=323" alt="cloud_0" width="490" height="323" border="0" /></a></p>
<p>I see some big things changing and evolving on this front as well.</p>
<p>Apple introduced iCloud and my first real experience with it as a consumer was playing a game on my iPad, then switching to my iPhone and having the game restore me to the exact point I was on the iPad.</p>
<p>This will become the standard.</p>
<p>Regardless of how devices transform, I don’t see us getting away from having some kind of a phone.  We might merge tablet and laptop, but we are going to always have at least two devices.</p>
<p>It is going to be expected that data from one device is available on the other device.  Many applications already support this, but I predict that we will see this get more tightly integrated into the operating system.</p>
<p>Microsoft, Google and Apple are all heavily invested in this area with a few different twists, but I see all the paths eventually merging to cloud based OSes with full app virtualization that streams bits to be executed to the clients and has the clients cache the app code.</p>
<p>What does this mean?</p>
<p>It means your user experience changes so that you log into your phone or tablet and when you do, you see the same thing regardless of device.  You don’t even know you have two different devices, except for the form factor.</p>
<p><strong>It also means that you don’t have the same concept of apps for your phone or tablet anymore.  Instead you purchase an app and it is streamed to you when you want to use it.</strong>  So as a user, you don’t need to worry about downloading the application or managing updates.</p>
<p>Think of it as the web, but instead of HTML you have binary executable code.  <a href="http://spoon.net/">Spoon already does this</a>.</p>
<h2>How about development?</h2>
<p>If you are reading this blog, you are probably more interested in what is going to happen in terms of developing applications for these platforms.</p>
<p>I have some predictions here as well.</p>
<p>Right now it is very difficult to develop an application that will run on multiple platforms.  Trying to target Android, iOS and Windows Phone is a bit of a challenge.</p>
<p>Even with great tools like MonoTouch and Mono for Android or PhoneGap, it is no easy task.</p>
<p>There is a big push to make everything web apps.  Some people believe HTML 5 will be the future, but I am not quite so sure.</p>
<p>I do think that the most successful platform, in the long run, will be the one easiest to develop for.  History tells me this is true.  (Why is Windows so successful?)</p>
<p>Microsoft again has a chance to change the future with Windows 8’s WinRT.  Suddenly web developers can write Javascript to program windows.  Not only that, but they can reuse much of that code to create a web application.</p>
<p>Think about where Windows 8 will run.  Desktop, laptop, tablet, phone.  Suddenly, you can create an application that can run on all of these devices, with pretty much the same code.</p>
<p>So what does this mean for iOS and Google?</p>
<p><strong>I predict that this year Apple will announce a new programming model for iOS which will be based on Javascript.</strong></p>
<p>I wouldn’t be surprised if Google did the same thing for Android.</p>
<p>It really makes sense on the iOS side though.  Apple is going to have to merge iOS with OSX to compete with Windows 8.  In addition, they need a better programming model.</p>
<p>Writing iOS apps in Objective-C is horrible!</p>
<p>Apple is going to have to do something to prevent web developers from flocking to Windows 8.</p>
<p>In the near future, I think we will be able to write applications with the code of the logic in Javascript or another language of choice, which binds against Javascript APIs for each platform.</p>
<h2>Summarizing my predictions</h2>
<p>So in short, here is what I think will happen within 2-3 years.</p>
<ol>
<li>Tablets and laptops merge as Window 8 targets both and iOS merges with OSX.</li>
<li>Cloud based operating systems replace standard OSes and virtualize apps by streaming them to users.</li>
<li>All surviving platforms natively support a Javascript based API.</li>
<li>Decrease in need for web apps, since streaming binary apps replace that niche.</li>
</ol>
<p>I could be wrong, I’ve been wrong many times before, but those are my predictions as of now.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1519/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1519/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1519/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1519&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/04/23/predicting-the-mobile-future/feed/</wfw:commentRss>
		<slash:comments>2</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/2012/04/gn-psychic_thumb.jpg" medium="image">
			<media:title type="html">gn-psychic</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/04/cloud_0_thumb.jpg" medium="image">
			<media:title type="html">cloud_0</media:title>
		</media:content>
	</item>
		<item>
		<title>Validate User Input, Not Developer Input</title>
		<link>http://simpleprogrammer.com/2012/04/16/validate-user-input-not-developer-input/</link>
		<comments>http://simpleprogrammer.com/2012/04/16/validate-user-input-not-developer-input/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 13:49:30 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1513</guid>
		<description><![CDATA[I have a very simple rule, I like to follow that helps to simplify my code. “Don’t validate developer input” This rule simply means that we should not try and validate input that came from a source that is not a user or external system. Another way to put it would be, don’t validate parameters [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1513&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have a very simple rule, I like to follow that helps to simplify my code.</p>
<blockquote><p>“Don’t validate developer input”</p>
</blockquote>
<p>This rule simply means that we should not try and validate input that came from a source that is not a user or external system.</p>
<p>Another way to put it would be, don’t validate parameters you pass around in your own code.</p>
<h2><b>γνῶθι σεαυτόν</b></h2>
<p>(Know thyself)</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/04/knowthyself.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="knowthyself" border="0" alt="knowthyself" src="http://complextosimple.files.wordpress.com/2012/04/knowthyself_thumb.jpg?w=501&h=352" width="501" height="352" /></a></p>
<p>While you can’t guarantee input from another source is valid, you can know that your own code’s input is valid.</p>
<p>When writing a method, we should really strive to know who is calling that method and put the onus on the caller of the method not to pass in junk.</p>
<p>I know this isn’t a popular opinion, because it seems to go against the idea of “defensive programming,” but the idea of defensive programming is misunderstood.</p>
<p>Chuck Norris himself once said:</p>
<blockquote><p>They say the best defense is not to offend.</p>
</blockquote>
<p><a href="http://complextosimple.files.wordpress.com/2012/04/defense.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="defense" border="0" alt="defense" src="http://complextosimple.files.wordpress.com/2012/04/defense_thumb.jpg?w=500&h=681" width="500" height="681" /></a></p>
<p>That slogan applies well here.&#160; Your strategy should be to make sure you always pass valid values into methods rather than trying to code methods to defensively do things with bad input.</p>
<p>(Let’s not be uncivilized!)</p>
<p>Let me give you an example:</p>
<div style="margin:0;display:inline;float:none;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:98977e53-726d-4eac-9190-63518b2b086c" class="wlWriterEditableSmartContent">
<pre style="white-space:normal;">
<pre class="brush: csharp; pad-line-numbers: true;">
var milkShakeMaker = new MilkShakeMaker();
var shake = milkShakeMaker.MakeShake(icecubes, milk, ingredients);

public class MileShakeMaker
{
   public Shake MakeShake(IEnumerable iceCubes,
             IMilk milk, 
             IEnumerable ingredients)
   {
      if(ice == null || milk == null || ingredient == null)
          throw new InvalidArgumentException("You passed in a null, duh");
      if(ice.Count &lt; 1)
          throw new InvalidArgumentException(&quot;You need ice.&quot;);
      if(milk.IsSpoiled)
          throw new SpoiledMilkException();
      foreach(var ice in iceCubes)
      {
          if(ice.IsMelted())
             throw new MeltedIceException();
      }

     if(ingredients.Count &lt; 1)
         throw new InvalidArgumentException(&quot;You need some ingredients.&quot;);

     ...

   }
}
</pre>
</pre>
</div>
<p>&#160;</p>
<p>Doesn’t that code look silly?</p>
<p>This is the exact opposite of what I am suggesting.</p>
<p>Rather than trying to decide which of these checks we should keep, and trying to follow some complex set of rules of when should we validate input like this, I am merely suggesting we <strong>get rid of all of it!</strong></p>
<p><a href="http://elegantcode.com/2010/05/01/say-no-to-null/">I’ve written about not checking nulls before</a>, but I am convinced now that checking any input from code you control is a code smell.</p>
<h2>What can you do?</h2>
<p>Throw an exception at best, at worst, infer what was meant by the caller and corrupt data.</p>
<p>What purpose does throwing an exception there serve?&#160; If you try and dereference a null object, you get an exception anyway.</p>
<p>Are you even going to catch an exception if you throw it?</p>
<p>If so, does that mean you are wrapping every method call you make in a try / catch block?</p>
<p>The big problem with trying to validate input that was passed to you by code you control is that you can’t really do anything useful.&#160; You are just cluttering up your code.</p>
<p>Another question, if you are still gung-ho on validating input on all method calls… Do you even do it?</p>
<p>Do you actually check every parameter, or just when you remember.&#160; Because, if you aren’t applying the checks uniformly, you cannot count on them.</p>
<h2>Context</h2>
<p>One major reason why I advocate validating what you pass into a method rather than what is passed into a method, is context.</p>
<p>If you are inside a method and someone passes you a null, you have no context.</p>
<p>What was going on that cause this parameter to be null?&#160; I don’t know—I can’t know!</p>
<p>But—on the other hand, if I am about to call a method and I am about to pass that method a null, I know why.&#160; I know that the list I got back was null and I could check for that and instead pass in an empty list to the method I was about to call.</p>
<p>Better yet, I can take it one more step further and not ever pass null back from the method that returns the list in the first place.</p>
<p>The point is that you have way more context before you call the method, than you do when you are in the method.&#160; If you are going to validate the input, do it in a place where context will allow you to do something meaningful, rather than just throwing a random exception.</p>
<h2>Better code</h2>
<p>Thinking this way will force you to write better code.&#160; I firmly believe it.&#160; </p>
<p>Most of us don’t really think about what we are passing into methods or whether or we are returning nulls from methods, we instead tend to think about what we are being passed.</p>
<p>By changing things around, it leads us into better coding practices that are less error prone.</p>
<p>We are forced to think about standardizing and <a href="http://elegantcode.com/2010/05/08/the-power-of-enum/">restricting ranges of values</a> for parameters.</p>
<p>We are forced to start considering making our objects immutable, so that if we properly initialize them, they cannot contain null values.</p>
<p>Most importantly, our code becomes cleaner, because it isn’t littered with error checking.&#160; Instead of checking for errors everywhere, we are coding in a way that prevents them from being possible.</p>
<p>So the next time you are thinking about validating parameters passed into your method, by another method you have control over, don’t do it!</p>
<p>If you can’t trust yourself, who can you trust?&#160; (Chuck Norris perhaps?)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1513/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1513&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/04/16/validate-user-input-not-developer-input/feed/</wfw:commentRss>
		<slash:comments>6</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/2012/04/knowthyself_thumb.jpg" medium="image">
			<media:title type="html">knowthyself</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/04/defense_thumb.jpg" medium="image">
			<media:title type="html">defense</media:title>
		</media:content>
	</item>
		<item>
		<title>Deployment Made Simple</title>
		<link>http://simpleprogrammer.com/2012/04/01/deployment-made-simple/</link>
		<comments>http://simpleprogrammer.com/2012/04/01/deployment-made-simple/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 16:47:06 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Process Improvement]]></category>
		<category><![CDATA[building]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1505</guid>
		<description><![CDATA[Deploying software doesn’t have to be that complicated! I’ve seen and built many software building and deployment solutions over my career, and I have come to find that most software deployment can be boiled down to a simple process. I’m not trying to give you a solution for your software deployment automation, nor am I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1505&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Deploying software doesn’t have to be that complicated!</p>
<p>I’ve seen and built many software building and deployment solutions over my career, and I have come to find that most software deployment can be boiled down to a simple process.</p>
<p><strong>I’m not trying to give you a solution for your software deployment automation, nor am I trying to perfectly model your exact process.</strong></p>
<p>What I am trying to do in this post, is to help you to simplify your process.</p>
<p>If you can identify the parts of your deployment process that fit into the simple steps I am going to outline below, it should be much easier for you to automate your deployment process.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/04/prostaglandin_h2_synthase-1_complex.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="PROSTAGLANDIN_H2_SYNTHASE-1_COMPLEX" src="http://complextosimple.files.wordpress.com/2012/04/prostaglandin_h2_synthase-1_complex_thumb.png?w=500&h=373" alt="PROSTAGLANDIN_H2_SYNTHASE-1_COMPLEX" width="500" height="373" border="0" /></a></p>
<h2>The process</h2>
<p>Even though software build processes, infrastructure and components are unique, I have found that most software deployment processes can be simplified into the following steps.</p>
<ol>
<li><strong>Build software without configuration</strong></li>
<li>Create environment specific configuration.</li>
<li>Create a set of database changes.</li>
<li>Bundle software, configuration and database changes.</li>
<li>Apply new software</li>
<li>Apply new configuration</li>
<li>Apply new database changes</li>
<li>Start it back up</li>
</ol>
<p>You might read through these steps and think “well duh.”</p>
<p>You might be tempted to say “my process is more complicated than that.”</p>
<p>I’m not going to argue with you.  You are right, your process is probably more complicated than that.  But, does it need to be?</p>
<p><strong>Can you simplify your process to fit into these steps?</strong></p>
<p>Sure, the implementation of these steps is likely to be fairly complex and vary for each type of software, but if you can distill the process into these steps, you can much more easily automate that process.</p>
<h2></h2>
<h2>Where people go wrong</h2>
<p>The big key to my simple version of deployment is</p>
<blockquote><p><strong>Build software without configuration</strong></p></blockquote>
<p><strong>You MUST do this!</strong>  Departing from this step causes all kinds of pain and complexity.  Please don’t try to build your software and the configuration for an environment at the same time.  These things must be pulled out from the get g or you will have the pain of trying to tease them apart later &#8211; or you will have to create separate builds for each environment.</p>
<p>It is also critical that the <a href="http://simpleprogrammer.com/2010/09/03/one-build-to-rule-them-all/">same bits that were built by your build server</a> are what is deployed to each environment!</p>
<p>I will say that this isn’t the easiest problem to solve.  You may need to have a separate build process that builds up the configuration for an environment.</p>
<p>Separating the two will also force you down the path of building a process to apply that configuration to an environment.</p>
<p>But, if you are willing to accept that this is just a must and bite through this pain, you’ll come out on the other side clean (even though you had to crawl through tunnels of crap.)</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/04/redemption.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="redemption" src="http://complextosimple.files.wordpress.com/2012/04/redemption_thumb.jpg?w=491&h=475" alt="redemption" width="491" height="475" border="0" /></a></p>
<h2></h2>
<h2>The whole story</h2>
<p>Now that I’ve hopefully convinced you to separate your configuration from the building of your software, let’s go over the big picture of a deployment using the simple process outlined above.</p>
<p>It all starts out when you build your software.  Perhaps you have a continuous integration build server setup that is automatically building software on each check-in; perhaps you are manually kicking off a script.</p>
<p>Once you have built your software, you have some bits that you should be able to apply to any environment.  Nothing that you built here should be machine or environment specific in any way.</p>
<p>Now, you kick off another process, or perhaps one was kicked off simultaneously by your continuous integration server. This builds up the configuration for the environment you are going to deploy to.</p>
<p>A similar process is kicked off—also could be simultaneous, for generating a list of database changes that need to be applied to the target environment.</p>
<p>Now that you have your bits, configuration and database changes, you are ready to deploy.</p>
<p>If you are smart, you’ve even built these ahead of time and they are just waiting for when you need them.</p>
<p>Next, gather up the artifacts and move them to the deployment target where you actually apply them.</p>
<p>First, unpack your bits and put the new bits into place.  (You may or may not need to take your application fully offline to do this.)</p>
<p>Then apply the new configuration on top of your newly installed bits for that environment.</p>
<p>Finally, apply database changes for that environment.</p>
<p>Now you should be completely deployed and can start up your application.</p>
<h2>But how do I do it?</h2>
<p>Perhaps you agree with me that the actual process should be what I have outlined and described, but now you are at the point of implementing a solution.</p>
<p>How do you actually automate this stuff?</p>
<p>Good question.  <strong>If you figure out a simple answer, let me know.</strong></p>
<p>This is the point where you might be writing custom tools and scripts to get all this working.  The key is to take it one step at a time.</p>
<p>There are at least two tools out there that I know of that help you do this.  I can’t speak for either of these tools, since I haven’t used them myself, but I have heard good things about them.</p>
<ul>
<li><a href="http://www.octopusdeploy.com/">Octopus</a></li>
<li><a href="https://github.com/chucknorris/dropkick">Dropkick</a></li>
</ul>
<p>One other thing to consider is how you are going to get the right stuff to the right server.  You will want to think about things like:</p>
<ul>
<li>Promoting build products</li>
<li>Preloading promoted products to servers to make deployment faster</li>
<li>Getting through firewalls by having the software or some other process PULL the upgrade to your target, rather than you PUSHING it there.</li>
<li>Rollback, or some kind of mitigation strategy if things go wrong. (My recommendation here is not to get fancy.  I have NEVER seen a successful rollback, only a database restore followed by a manual code restore.  If you mess up bad, just count on restoring the machine and the database.)</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1505/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1505/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1505/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1505&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/04/01/deployment-made-simple/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/2012/04/prostaglandin_h2_synthase-1_complex_thumb.png" medium="image">
			<media:title type="html">PROSTAGLANDIN_H2_SYNTHASE-1_COMPLEX</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/04/redemption_thumb.jpg" medium="image">
			<media:title type="html">redemption</media:title>
		</media:content>
	</item>
		<item>
		<title>Are You Really Sure You Want to Make a Cancel Button?</title>
		<link>http://simpleprogrammer.com/2012/03/25/are-you-really-sure-you-want-to-make-a-cancel-button/</link>
		<comments>http://simpleprogrammer.com/2012/03/25/are-you-really-sure-you-want-to-make-a-cancel-button/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 01:08:35 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Functional]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[cancel]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1495</guid>
		<description><![CDATA[Are you really sure you want to create the cancel button for your application? You know, I might click it. Not only might I click it, I might click it at the most inopportune time. I might click it right in the middle of  that large file that you are copying, right after you spun [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1495&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Are you really sure you want to create the cancel button for your application?</p>
<p>You know, I might click it.</p>
<p><strong>Not only might I click it, I might click it at the most inopportune time.</strong></p>
<p>I might click it right in the middle of  that large file that you are copying, right after you spun up that 2nd thread.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/exploding-earth.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="exploding-earth" src="http://complextosimple.files.wordpress.com/2012/03/exploding-earth_thumb.jpg?w=500&h=500" alt="exploding-earth" width="500" height="500" border="0" /></a></p>
<h2>Cancel is a commitment</h2>
<p>The next time you consider creating a cancel button, I suggest you think of it as a commitment.</p>
<p>In my world the cancel button has two promises.</p>
<ol>
<li>Stop what is currently happening in a non-destructive way.</li>
<li>Stop RIGHT the F NOW!</li>
</ol>
<p>I’ve been encountering a good deal of cancel button which don’t obey the basic laws of cancelling that any user would expect.</p>
<p>I have actually been randomly clicking “cancel” whenever I see it, much to my <a href="https://twitter.com/#!/josh_earl">coworker’s</a> dismay.</p>
<p>I started doing this, because I wanted to see how widespread the cancel cancer is.</p>
<p>And it is pretty widespread.  A majority of cancel buttons I have been testing neither stop right away or prevent destruction.</p>
<p>I found instead that clicking the “cancel” button in most programs is sure to hang that program for an extended period of time, ultimately causing you to kill the process, and it tends to leave processes half done without rolling them back.</p>
<h2>Clearing things up</h2>
<p>Let me be a bit clear here.  I am not talking about cancel buttons you see in an “Ok / Cancel” dialog.  Most of the time those cancel buttons actually work, because they are really operating as “back” buttons, they aren’t actually cancelling a process that is happening live.</p>
<p>I am talking mainly about cancel buttons that cancel an active ongoing activity.  For example, cancel buttons in an installer or during an SVN update.</p>
<p>We could call these kinds of cancel buttons “asynchronous cancel buttons.”</p>
<h2>But, I need to provide a way for the user to cancel</h2>
<p>Good, but don’t lie about it.</p>
<p>There are certain things that just can’t be cancelled.</p>
<p>When I get on a plane, I can cancel my trip when I am sitting there waiting for the door to close.  I can even cancel my trip while the plane is taxing to the runway, if I yell “<strong>I have been RAPED by a BOMB that is on FIRE!</strong>”</p>
<p>But, I can’t cancel my trip, once the plane has lifted off the ground.  If I try to cancel it then… well, bad things would happen.  Very bad things.</p>
<p>So how come when I am installing your software, or your software is updating its database, I have this shiny little cancel button I can click at any time during that process?</p>
<p>Surely I cannot cancel just any time!</p>
<p>Surely there are parts of the process that cancelling would be fatal or it is too late to rollback.</p>
<p>My point is, if the user truly can’t cancel, don’t present a button that says they can.  More specifically, if you can’t obey the laws of cancel 1 and 2 from above, don’t even show a button.  Just say “sorry, you can’t cancel this process at this time.”</p>
<p>I don’t even need to know why I can’t cancel.  I mean, it will make me feel better if you tell me that the Unicorn Glitter Engine is in a critical state and any disruptions could end life as we know it, but I’ll settle for you just greying out that cancel button or not displaying it at all.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/cancel-button.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border:0;" title="cancel-button" src="http://complextosimple.files.wordpress.com/2012/03/cancel-button_thumb.jpg?w=240&h=159" alt="cancel-button" width="240" height="159" border="0" /></a></p>
<h2>Putting back on the developer hat</h2>
<p>I’m guilty of it myself.  I know I have created cancel buttons in the past that have caused pain and anguish.</p>
<p>But what can we do about it as developers?</p>
<p>First off, we should be thinking carefully about breaking a long running process into steps.  At each step of the way we should consider if it is conceivable to cancel that step without destroying data and hanging the application.</p>
<p>In any long running process, we should be able to identify certain parts which are cancellable and those which do not make sense to cancel.</p>
<p>It is your job as the developer to ensure that if you decide to allow for cancelling that the cancel undoes the existing process and work immediately.</p>
<p><strong>I cannot stress this enough!</strong></p>
<p>This is the behavior that most users expect and the very meaning of the word cancel.</p>
<p>To do this might take extra work.  You might have to think a bit more about the threading situation of your application.  You might have to think about rollback situations.  But, if you don’t do it, your cancel button will become just like the boy who cried wolf and no one will believe them.</p>
<p>And if you&#8217;re not willing to go through this effort, at the very least, be kind enough to your users to just remove the cancel button, because you can bet I’ll be clicking it!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1495/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1495/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1495/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1495/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1495/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1495/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1495/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1495/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1495&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/03/25/are-you-really-sure-you-want-to-make-a-cancel-button/feed/</wfw:commentRss>
		<slash:comments>12</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/2012/03/exploding-earth_thumb.jpg" medium="image">
			<media:title type="html">exploding-earth</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/03/cancel-button_thumb.jpg" medium="image">
			<media:title type="html">cancel-button</media:title>
		</media:content>
	</item>
		<item>
		<title>Switching Gears is Grinding Gears</title>
		<link>http://simpleprogrammer.com/2012/03/10/switching-gears-is-grinding-gears/</link>
		<comments>http://simpleprogrammer.com/2012/03/10/switching-gears-is-grinding-gears/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 18:06:56 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Paired Programming]]></category>
		<category><![CDATA[Process Improvement]]></category>
		<category><![CDATA[Psychology]]></category>
		<category><![CDATA[Teams]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[context switching]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[psychology]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1489</guid>
		<description><![CDATA[Pay attention young programmers, this is the most important piece of programming advice you will ever hear. Well perhaps not, but it might be the most important piece of programming advice you hear today. “Switching gears is grinding gears.” I’ve been doing this programming thing for quite a while now, and I have come to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1489&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Pay attention young programmers, this is the most important piece of programming advice you will ever hear.</p>
<p>Well perhaps not, but it might be the most important piece of programming advice you hear today.</p>
<blockquote><p>“Switching gears is grinding gears.”</p>
</blockquote>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/gear-intro.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="gear-intro" border="0" alt="gear-intro" src="http://complextosimple.files.wordpress.com/2012/03/gear-intro_thumb.jpg?w=285&h=361" width="285" height="361" /></a></p>
<p>I’ve been doing this programming thing for quite a while now, and I have come to realize that the biggest thing that saps my productivity is switching gears.</p>
<p>What do I mean by switching gears?</p>
<h2></h2>
<h2>Many different contexts</h2>
<p>Switching gears can apply to a variety of different contexts, but it is basically whenever you are working on some task or technology and have to stop what you are doing and either do something else or change the type of thing you are doing.</p>
<p>This is really a bit different than multi-tasking.&#160; Multi-tasking is really trying to do more than one thing at once.&#160; It usually involves a large amount of rapid context switches, but for this post I am more concerned about the general idea of breaking rhythm.</p>
<p>I think it is easier to speak about this subject if we talk about some specific applications of the idea and why they are harmful.</p>
<h2></h2>
<h2>Switching problems</h2>
<p>In the Agile world of software development today, we often are required to switch from problem domain to problem domain as many of our iterations contain mixes of different features on different parts of the system and bugs to be fixed.</p>
<p>Have you ever been in the situation where you were just beginning to understand how some area of the code base worked, or how to work with a particular customer on a particular problem space and then had to switch to something else and start all over again?</p>
<p>Even when you switch back to the original context you were working with, if enough time goes by, it becomes new again.&#160; You have to relearn much of what you had learned the last time and just when you begin to hit your groove, the cycle begins again.</p>
<p>This form of switching gears is at the very least frustrating, and at the most a complete demotivator and productivity sapper.</p>
<p>Unfortunately for most developers, this problem is out of your immediate control.&#160; But, take note product owners and project managers, there is a reason why iterations should have a goal.</p>
<p>If you are in the precarious position of being a developer pinned against the ropes, try to make some noise and let your management and product owners know that your team will be much more efficient when you aren’t switching gears all the time.</p>
<p>In my experience, the results of replacing this constant context switching with the synergy of a common goal and related features in a segment of time has an astounding effect on productivity that is hard for any serious businessperson to ignore.&#160; So speak up!</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/clss_065.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="Clss_065" border="0" alt="Clss_065" src="http://complextosimple.files.wordpress.com/2012/03/clss_065_thumb.gif?w=198&h=294" width="198" height="294" /></a></p>
<h2>Switching technology</h2>
<p>This is the primary reason why I have a distaste for JavaScript.&#160; It is why even in this abundance of web development, I would still rather program a client application.</p>
<p>Switching technology is painful!</p>
<p>This is one of those things that is unavoidable in todays development environment.&#160; If you are a web developer, you are going to be working with HTML, JavaScript, probably some sort of server side language, and most likely some form of SQL.</p>
<p>It really isn’t worth trying to fight this because you are going to be going against the technology grain to do so.&#160; Although, I do suppose this may be one of the reasons for the recent popularity of Node.js.</p>
<p>What we can try to do is to minimize the context switch as much as possible.&#160; We do this by sticking with a particular way of doing things and not chasing after each new technology of JavaScript framework that comes out each week.</p>
<p>I’m not saying to not learn new things.&#160; It is very important to always be learning.</p>
<p>What I am saying, is to try to find some kind of rhythm with the technology stack you are working with and try not to switch that up.</p>
<p>Technology specific training can really help here as well.&#160; I for one, need to learn JQuery better.&#160; The problem is that when I am working on a web based feature, I am not forced to learn JQuery because I am not in that context long enough.</p>
<p>So what do I do instead?</p>
<p>I waste time Googling for answers.&#160; I know that I have a short coming here and I need to just bite the bullet and spend some dedicated time to really thoroughly learn JQuery, because by Googling for little pieces of it at a time, I am not really making much headway and the context switch ends up stealing what I do learn from my memory.</p>
<p>One more aspect of this is the idea of focused teams.&#160; Many software development groups do not like to specialize their developers onto one focus area.&#160; I agree whole-heartily with the idea of non-specialization.&#160; </p>
<p>But!&#160; There is huge benefit to be gained by keeping the same group of developers working on a specific set of technology or part of the code base for a set period of time.&#160; I’ll talk about this a bit more, towards the end of this post, but the basic idea is that it takes time for people to find their groove.</p>
<p>I think it is optimal to break any large team up into smaller technology area focused teams that regularly rotate every 3 months or so.&#160; The idea here is that you give those teams enough time to get good at what they are doing and actually commit what they have learned to memory, but you rotate them often enough that they don’t end up becoming specialists which are unable to see the whole picture.</p>
<h2>Switching teams</h2>
<p>This one typically isn’t an issue, but it can be depending on the environment that you are working in.</p>
<p>Teams need enough time to go through that forming, storming, and norming set of phases.&#160; If you are constantly interrupting this process by switching around team members, you are never going to get the team to act as an entity of its own.</p>
<p>Teams are generally more efficient than individuals, because they benefit from synergy, when 1 + 1 = more than 2.</p>
<p>But just like a big truck taking some time to get up speed, a team takes time to get going.&#160; Also like a big truck, a team can gain momentum that individual developers seldom can achieve.</p>
<p>A smaller aspect of this is pair programming.&#160; I suppose that many have been successful switching up programming pairs once a day or so, but I suppose that more teams have been successful switching up pairs at longer intervals.</p>
<p>For me, this interval varies.&#160; Sometimes, I feel like I need to stay paired with a teammate for longer than 2 weeks, which is our regular interval, sometimes 2 weeks is fine.&#160; It depends on what you are working on and how much momentum you have.</p>
<p>They key here is to make sure that you are giving teams enough time to take up their own flag and stake their territory.&#160; <a href="http://simpleprogrammer.com/2011/08/01/what-is-a-team/">Teams can take some time to find their common goal.</a>&#160; Self-direction can really help with this.</p>
<h2></h2>
<h2>The groove</h2>
<p>Ever tried to turn a flat head screw with a screwdriver, but it doesn’t quite turn, because you can’t seem to get the head of the screwdriver into the groove of the screw?</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/screwdriver-1.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="This Shutterstock image #2798630 was downloaded on 3-13-07 for HSW: QUICK FIXES FOR YOUR HOME, 730175. " border="0" alt="This Shutterstock image #2798630 was downloaded on 3-13-07 for HSW: QUICK FIXES FOR YOUR HOME, 730175. " src="http://complextosimple.files.wordpress.com/2012/03/screwdriver-1_thumb.jpg?w=484&h=347" width="484" height="347" /></a></p>
<p>You twist that screwdriver around a bit until finally it slips into the groove.&#160; Then when you turn the screwdriver the screw turns with it.</p>
<p><strong>As humans, we tend to be like screwdrivers, we have to find our groove.&#160; We all have this adjustment period where we are fumbling through things.</strong>&#160;</p>
<p>It is very important to make sure that we aren’t switching gears so often that we are not actually turning any screws once we are in the groove.</p>
<p>Regardless of what kind of context switching you are doing—whether it is problem domain, technology or teams—it is important to make sure that you are not spending 90% of your time finding the groove and only 10% of your time “in the groove.”</p>
<p>Depending on what you are doing and what the context switch is, the proper amount of time before switching contexts is going to vary, but I think it is very important be aware of this phenomenon and plan around it.&#160; If you don’t you are going to end up spinning your wheels, which is unfulfilling to say the least.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1489/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1489/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1489/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1489/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1489/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1489/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1489/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1489/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1489&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/03/10/switching-gears-is-grinding-gears/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/2012/03/gear-intro_thumb.jpg" medium="image">
			<media:title type="html">gear-intro</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/03/clss_065_thumb.gif" medium="image">
			<media:title type="html">Clss_065</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/03/screwdriver-1_thumb.jpg" medium="image">
			<media:title type="html">This Shutterstock image #2798630 was downloaded on 3-13-07 for HSW: QUICK FIXES FOR YOUR HOME, 730175. </media:title>
		</media:content>
	</item>
		<item>
		<title>Small Refactorings are OK</title>
		<link>http://simpleprogrammer.com/2012/03/03/small-refactorings-are-ok/</link>
		<comments>http://simpleprogrammer.com/2012/03/03/small-refactorings-are-ok/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 21:37:57 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Psychology]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1477</guid>
		<description><![CDATA[Many programmers seems to get caught up on the idea of refactoring. Most of us are familiar with the Boy Scout rule which says: Always leave code better than when you found it But do you actually apply it in your day to day work? I’ve found that for myself the answer to this question [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1477&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many programmers seems to get caught up on the idea of refactoring.</p>
<p>Most of us are familiar with the Boy Scout rule which says:</p>
<blockquote><p>Always leave code better than when you found it</p></blockquote>
<p>But do you actually apply it in your day to day work?</p>
<p>I’ve found that for myself the answer to this question is sometimes “no.”</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/boyscout.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="boyscout" src="http://complextosimple.files.wordpress.com/2012/03/boyscout_thumb.jpg?w=465&h=492" alt="boyscout" width="465" height="492" border="0" /></a></p>
<h2>Why we don’t follow the rule</h2>
<p align="left">Personally, I know that there are many reasons why I have failed to follow the Boy Scout rule in my own day to day coding activities.</p>
<p align="left">How often do you say to yourself something like:</p>
<p align="left">“Yeah, I’ve just got to get this code checked in.  I don’t have time to clean it up.”</p>
<p align="left">Or</p>
<p align="left">“Refactoring this correctly would take too long, and I want to make sure I do it right.”</p>
<p align="left">At first glance, these seem like perfectly valid <strong>excuses</strong>, but the problem is that the cumulative effect of this kind of thinking is exactly what causes code rot.</p>
<p align="left"><strong>“Code rot” is when code from your application begins to become brittle and hard to maintain.</strong></p>
<p align="left">As software developers we should really strive to prevent code rot, and regularly refactoring and cleaning up code, is like brushing the teeth of our application.</p>
<p align="left">There are definitely a large number of excuses I come up with for not refactoring code, but I would say that the number one mental block is this idea of perfection and needing to do it right.</p>
<h2>Small refactorings are good!</h2>
<p>One thing I try to tell myself is that small refactorings are good and I don’t need to solve the whole problem all at once.</p>
<p>We shouldn’t let the fact that we can’t completely clean up a section of code or refactor it to the final structure we want, prevent us from putting that code on a bus headed that direction.</p>
<p>Many programmers tend to have the perfect solution mindset which requires us to find the 100% best solution to a problem and think that the 95% effective one is no good.</p>
<p><strong>This mindset can be a huge stumbling block</strong> to productivity and it can also be a big hindrance to keeping our campsite clean.</p>
<p>It is often helpful to embrace that a series of small changes can be more beneficial than one large change of the same resulting magnitude, even if the small changes end up requiring more total work.</p>
<p>The reason for this is two-fold:</p>
<ol>
<li>Big changes rarely actually get done, so they are put off</li>
<li>Small changes usually are more natural and evolve the code in an organically correct direction.</li>
</ol>
<h2>Going backwards to go forwards</h2>
<p>I even find that many times I take one step backwards in order to go two forwards.  Refactoring sometimes has to just progress naturally as you make something clearer, only to undue it a bit later with another change that ends up making more sense once you can actually see the problem being solved more clearly.</p>
<p>Think about solving a Rubix Cube.  If you have ever attempted to solve one of these things, you know that sometimes you have to wreck that perfect wall of green in order to start getting the white blocks in place.  Many times it is impossible to solve a Rubix Cube without traversing backwards in the solution first.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/03/rubix.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="rubix" src="http://complextosimple.files.wordpress.com/2012/03/rubix_thumb.jpg?w=492&h=338" alt="rubix" width="492" height="338" border="0" /></a></p>
<p>The point is, don’t be afraid to get out there and make something clearer, or go a direction that seems like it will at least improve the code.</p>
<p>You don’t have to find the perfect design pattern to refactor the code into in order to start making changes.</p>
<ul>
<li>Start by changing this variable name to be a bit more clear.</li>
<li>Extract those lines of code into a method that makes that functionality more clear.</li>
<li>Get rid of some duplication here and there.</li>
</ul>
<h2>The active code reader</h2>
<p>When I am in my “zone” and doing things right, I am even refactoring code while I am reading it.</p>
<p>There is no better way to understand some code than to refactor it.</p>
<p>Think about it, how do we learn?</p>
<p>We read something or are taught it and then we rephrase it differently to confirm understanding.</p>
<p>“Let me get this straight, are you saying… blah blah blah?”</p>
<p>“Oh, now I get it, if I do blah and blah then blah blah?”</p>
<p>Why shouldn’t we do this with code?</p>
<p>I know some of you are really scared by this idea, and you&#8217;re saying “nope, don’t just go touching code you don’t understand, John.  You are not getting anywhere near my code base.”</p>
<p>But, give it a shot, what is the worst that is going to happen?  You are going to refactor yourself into a dead end and have to revert your changes?</p>
<p>More likely than not, you will end up learning the code better and improving it.  Two for one!</p>
<h2>One more analogy then I’m done</h2>
<p>I promise!</p>
<p>Ever solved a crossword puzzle?</p>
<p>Did you sit there and immediately fill in all the answers one by one?</p>
<p>Perhaps you filled in some answers that you knew.  Perhaps the short ones first, then you went back over all the clues again and suddenly found that with some letters filled in you could better guess the clues.</p>
<p>Most likely you made several sweeps like this until you finally solved the puzzle or gave up in disgust wondering why you wasted an hour of your life and who the heck studies books on geography that could actually solve this puzzle.</p>
<p>Do you think it would be any different with code?  Making small refactorings is like filling in the clues you know the answer to in a crossword puzzle.  As you keep refactoring, the answers to other puzzles about the code and which way it should go become clearer and clearer.</p>
<p>Don’t try and solve the whole puzzle one by one in a single pass.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1477/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1477/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1477/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1477&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/03/03/small-refactorings-are-ok/feed/</wfw:commentRss>
		<slash:comments>3</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/2012/03/boyscout_thumb.jpg" medium="image">
			<media:title type="html">boyscout</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/03/rubix_thumb.jpg" medium="image">
			<media:title type="html">rubix</media:title>
		</media:content>
	</item>
		<item>
		<title>Refactoring Switches to Classes</title>
		<link>http://simpleprogrammer.com/2012/02/21/refactoring-switches-to-classes/</link>
		<comments>http://simpleprogrammer.com/2012/02/21/refactoring-switches-to-classes/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 19:55:14 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Legacy Code]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[code switch]]></category>
		<category><![CDATA[switch statement]]></category>
		<category><![CDATA[switch statements]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1466</guid>
		<description><![CDATA[I’ve talked about refactoring switch statements several times before. Switch is Just a Fancy If Else Pulling out the Switch: It’s Time for a Whooping Refactoring Switches Advanced I’ve even created a defaultable dictionary for refactoring a switch statement into a dictionary of actions. This time, I am going to talk about refactoring switches when [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1466&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve talked about refactoring switch statements several times before.</p>
<ul>
<li><a href="http://simpleprogrammer.com/2010/08/12/switch-is-just-a-fancy-if-else/">Switch is Just a Fancy If Else</a></li>
<li><a href="http://simpleprogrammer.com/2010/08/17/pulling-out-the-switch-its-time-for-a-whooping/">Pulling out the Switch: It’s Time for a Whooping</a></li>
<li><a href="http://simpleprogrammer.com/2010/10/19/refactoring-switches-advanced/">Refactoring Switches Advanced</a></li>
</ul>
<p>I’ve even created a <a href="http://simpleprogrammer.com/2011/08/14/making-switch-refactorings-better-defaultable-dictionary/">defaultable dictionary</a> for refactoring a switch statement into a dictionary of actions.</p>
<p>This time, I am going to talk about refactoring switches when you have switch statements operating on the same set of data, but have different actions in different circumstances.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/switch.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="switch" src="http://complextosimple.files.wordpress.com/2012/02/switch_thumb.jpg?w=463&h=463" alt="switch" width="463" height="463" border="0" /></a></p>
<h2></h2>
<h2>First let’s recap</h2>
<p>When I talked about refactoring switches before, we were mainly dealing with a single switch statement somewhere in code.</p>
<p>In the case where you have only a single switch statement, or multiple switch statements that do the same thing based on the data, using a dictionary is still a great way to go.</p>
<p>However, there are going to be circumstances where you are going to be switching on the same data, but in different contexts.  In these cases, you will want to perform different actions.</p>
<p>Let’s look at an example.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:cbc0ce59-95bf-43c0-bcfd-c9b9ccff9156" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
// In fighting code
switch(classType)
{
    case WARRIOR:
          swingSword();
          break;
    case MAGE:
          castSpell();
          break;
    case THIEF:
          backstab():
          break;
}

// In wear armor code
switch(classType)
{
    case WARRIOR:
          return CAN_WEAR;
    case MAGE:
          return isConsideredLightArmor(armor);
    case THIEF:
          if(isSneaking)
              return NOT_NOW;
          return isConsideredLightArmor(armor);
}
</pre></p>
</div>
<p>In this example, we are switching on the same enumeration, but we are doing it in different locations of the code.</p>
<p>Using a dictionary would not work well here because we would need multiple dictionaries.</p>
<p>We still don’t want to leave this as it is though, because the code is pretty messy and fragile.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/mage.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="Mage" src="http://complextosimple.files.wordpress.com/2012/02/mage_thumb.jpg?w=452&h=638" alt="Mage" width="452" height="638" border="0" /></a></p>
<h2>Separation of concerns</h2>
<p>The problem is the code that contains these switch statements has too much responsibility.  It is being asked to handle logic for each one of our character class types.</p>
<p>What we need to do to improve this code is refactor the enumerations into their own classes.  Each switch statement will become a method that will be implemented by our enumeration based class.</p>
<p>If we are using Java, we can use Java’s enumeration implementation that allows for methods on an enumeration.  If we are using a language like C#, we still have to map the enumeration value to each class.</p>
<p>Let’s start by making our classes.</p>
<p>First we need a base class, or interface.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:064e6f4b-c769-471c-abdd-255857a1be3f" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public interface CharacterClass
{
    void Attack();
    ArmorResponse WearArmor(armor);
}
</pre></p>
</div>
<p>Now we can create classes that implement this interface, that contain the logic that was in each switch statement.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:a135f69d-b90d-495b-826a-d6af605fd96b" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public class Warrior : CharacterClass
{
    void Attack()
    {
       swingSword();
    }

    ArmorResponse WearArmor(armor)
    {
       return CAN_WEAR;
    }
}

public class Mage : CharacterClass
{
    void Attack()
    {
       castSpell();
    }

    ArmorResponse WearArmor(armor)
    {
       return isConsideredLightArmor(armor);
    }
}

public class Thief : CharacterClass
{
    void Attack()
    {
       backstab();
    }

    ArmorResponse WearArmor(armor)
    {
       if(isSneaking)
           return NOT_NOW;
       return isConsideredLightArmor(armor);
    }
}
</pre></p>
</div>
<p>Next we can map our enumeration to our class.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:d54fc9cf-d778-4b8e-a232-6d8549f0dbd8" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public Dictionary characterDictionary =
    new Dictionary {
    { WARRIOR, new Warrior() },
    { MAGE, new Mage() },
    { THIEF, new Thief() }
};
</pre></p>
</div>
<p>We could also get rid of the enumeration if we wanted, and just create the appropriate class.  It will depend on what your existing code looks like.</p>
<h2>No more switches!</h2>
<p>Now let’s take a look at what we end up with in the two locations where we had switches.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:4d2f6a2b-53c4-4dfd-9699-a174bf060a51" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
// In fighting code
myCharacter.Attack();

// In wear armor code
var armorResponse =  myCharacter.WearArmor(armor);
</pre></p>
</div>
<p>If we want to add a new character class type, we just add a new class that implements the <em>CharacterClass</em> interface and put a mapping in our dictionary, or in our character initialization code.</p>
<p>If we end up having other places in our logic where different character class types should have different behavior, we just add a method to our <em>CharacterClass</em> interface and implement it in any classes that implement <em>CharacterClass</em>.</p>
<p>Our code is much more maintainable, and easier to understand.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1466/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1466/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1466/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1466&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/02/21/refactoring-switches-to-classes/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/2012/02/switch_thumb.jpg" medium="image">
			<media:title type="html">switch</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/02/mage_thumb.jpg" medium="image">
			<media:title type="html">Mage</media:title>
		</media:content>
	</item>
		<item>
		<title>Pushing Through the Pain</title>
		<link>http://simpleprogrammer.com/2012/02/16/pushing-through-the-pain/</link>
		<comments>http://simpleprogrammer.com/2012/02/16/pushing-through-the-pain/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 22:10:28 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Psychology]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1458</guid>
		<description><![CDATA[Life ain’t easy! It ain’t meant to be easy. Sometimes in life &#8211; if you want to achieve anything of worth – you have to just push through the pain. Yes, this is another post about burnout. There is no such thing as burnout! Do I believe that people, and programmers especially, suffer from the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1458&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Life ain’t easy!</p>
<p>It ain’t meant to be easy.</p>
<p>Sometimes in life &#8211; if you want to achieve anything of worth – you have to just push through the pain.</p>
<p>Yes, this is another post about <strong>burnout</strong>.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/unicorn3.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="unicorn3" border="0" alt="unicorn3" src="http://complextosimple.files.wordpress.com/2012/02/unicorn3_thumb.jpg?w=474&h=356" width="474" height="356" /></a></p>
<h2>There is no such thing as burnout!</h2>
<p>Do I believe that people, and programmers especially, suffer from the symptoms of what is described as burnout?</p>
<p>Yes, absolutely!</p>
<p>The problem is that we tend to batch up these symptoms into one big classification we call burnout.&#160; I’ve written about this topic before, I call it <a href="http://elegantcode.com/2010/09/11/keep-pressing-on-my-friend-when-programming-seems-bleak/">programming lethargy</a>.</p>
<p>I think this topic is so important that it is worth talking about again.</p>
<p>Most advice out there will tell you to step away and refresh yourself.</p>
<p><strong>I’m going to tell you the exact opposite!</strong></p>
<p>Now, I’m not going to suggest you never go on vacation or step away from a problem, but I am going to tell you to…</p>
<h2></h2>
<h2>Push on and push harder!</h2>
<p>Greatness is just on the other side of that wall.&#160; When you hit burnout, you are really hitting a wall.</p>
<p>This wall is caused by interest and motivation dropping when results are relatively flat.</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/chart.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="chart" border="0" alt="chart" src="http://complextosimple.files.wordpress.com/2012/02/chart_thumb.png?w=482&h=319" width="482" height="319" /></a></p>
<p>Imagine that when you first start an activity your interest is very high.&#160; As your start doing that activity your motivation increases quickly.</p>
<p>You get some immediate feedback as you start to gain results.</p>
<p>Over time the new thing become mundane, so your interest starts to drop.&#160; Your results are relatively flat so motivation follows as well.</p>
<p>This is where the wall exists.</p>
<p>You could call it the <a href="http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition">road to competency</a>.</p>
<p>It is pretty hard to push beyond this point, because you have to do it without motivation or interest.</p>
<p>Few people do.&#160; That is why greatness is hard to come by.</p>
<h2>Searching for greatness</h2>
<p>Let’s take a minute to dwell on that idea.</p>
<p>Why do some people achieve such great fame and fortune while others live fairly mediocre lives?</p>
<p>I’m going to pick on a person who I think is pretty famous in the developer community to make my point, <a href="http://www.hanselman.com/blog/">Scott Hanselman</a>.</p>
<p>You probably already know who he is.&#160; <a href="http://www.hanselminutes.com/305/monotouch-and-mono-for-android-with-trainer-john-sonmez">I was on an episode of one of his Podcasts</a> and that was a big deal for me.&#160; So, if being on his show is a big deal, just imagine how big of a deal it is to be Scott Hanselman.</p>
<p>The question is, why is he so successful?</p>
<p>I think we can describe it in one word- <strong>consistent</strong>.</p>
<p>If I had two- <strong>persistent</strong> and <strong>consistent</strong>.</p>
<p>His podcast is on Show #305 at the time of this writing.&#160; Every week Scott puts out a new podcast.&#160; It is a large amount of work.</p>
<p>About 1 to 2 times a week he usually puts out a new blog post, also a large amount of work.</p>
<p>And I am sure he does countless other things that he doesn’t want to do, but he does because he has a goal in mind.</p>
<p>He’s got kids, he has a full time job, and he has the kind of diabetes where he has to give himself insulin shots everyday.</p>
<p>I am pretty sure he wakes up some mornings and says, “Holy Crapola! I don’t feel like writing a blog post and making a podcast.”</p>
<p>But guess what he does that makes him great?</p>
<h2>He does it anyway!</h2>
<p>He doesn’t change gears and go a different direction.</p>
<p>He doesn’t pursue some other interest or look for a new job.</p>
<p>He pushes on and pushes through and therein lies his success.</p>
<p>It can be yours as well.</p>
<p>Ask yourself how long he had to go on being consistent and persistent before he saw results?&#160; I bet it took a pretty long time.&#160; I bet he hit a wall at more than one point along the way.</p>
<h2>Beyond the wall</h2>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/dont-burn-out.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="dont-burn-out" border="0" alt="dont-burn-out" src="http://complextosimple.files.wordpress.com/2012/02/dont-burn-out_thumb.jpg?w=485&h=471" width="485" height="471" /></a></p>
<p>The point is, most people lose their motivation and interest in something and decide to switch gears or take a break or leave a project half finished.</p>
<p><strong>I am the worst of the worst of this kind of person naturally!&#160; Really I am!&#160; I am a “lazy, good for nothing, just hand me the world on a platter kind” of guy.</strong></p>
<p>But somehow I’ve learned to grit my teeth, put one foot in front of the other and walk forward.</p>
<p>Earlier in my career, I switched jobs pretty frequently.&#160; I started projects and left them unfinished.&#160; I sapped away countless hours on things that distracted me from bigger goals and big rewards.&#160; I often sought to cure my burnout by reeling away from the thing causing it.</p>
<p>What I have found recently is that by going directly against all my natural inclinations and pushing on to see things through to success, I have found much more success and much bigger rewards.</p>
<p>Don’t make excuses, don’t call it burnout, don’t give up early, instead push harder, see the bigger picture, and climb the !@#* over that wall!</p>
<p>On the other side of that wall lies success and renewed motivation and interest, you just have to get there.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1458/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1458/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1458/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1458&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/02/16/pushing-through-the-pain/feed/</wfw:commentRss>
		<slash:comments>10</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/2012/02/unicorn3_thumb.jpg" medium="image">
			<media:title type="html">unicorn3</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/02/chart_thumb.png" medium="image">
			<media:title type="html">chart</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/02/dont-burn-out_thumb.jpg" medium="image">
			<media:title type="html">dont-burn-out</media:title>
		</media:content>
	</item>
		<item>
		<title>The Development Pendulum</title>
		<link>http://simpleprogrammer.com/2012/02/09/the-development-pendulum/</link>
		<comments>http://simpleprogrammer.com/2012/02/09/the-development-pendulum/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 05:59:24 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Career]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1447</guid>
		<description><![CDATA[I’ve noticed a rather interesting thing about best practices and trends in software development, they tend to oscillate from one extreme to another over time. So many of the things that are currently trendy or considered “good” are things that a few years back were considered “bad” and even further back were “good.” This cycle [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1447&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve noticed a rather interesting thing about best practices and trends in software development, they tend to oscillate from one extreme to another over time.</p>
<p>So many of the things that are currently trendy or considered “good” are things that a few years back were considered “bad” and even further back were “good.”</p>
<p>This cycle and rule seems to repeat over and over again and is prevalent in almost all areas of software development.</p>
<h2>It has three dimensions</h2>
<p>Don’t misunderstand my point though, we are advancing.  We really have to look at this from a 3 dimensional perspective.</p>
<p>Have you ever seen one of those toys where you rock side to side in order to go forward?</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/snakeboard.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="snakeboard" src="http://complextosimple.files.wordpress.com/2012/02/snakeboard_thumb.jpg?w=489&h=326" alt="snakeboard" width="489" height="326" border="0" /></a></p>
<p>Software development is doing this same thing in many areas.  We keep going back and forth, yet we are going forward.</p>
<p>Let&#8217;s look at some examples and then I’ll tell you why this is important.</p>
<h2>JavaScript!</h2>
<p>Is JavaScript good or bad?</p>
<p>Depends on who you ask, but it is definitely popular right now.</p>
<p>If we go back about 5 years or so, you’ll get a totally different answer.  Most people would suggest to avoid JavaScript.</p>
<p>Now, JavaScript itself hasn’t changed very much in this timespan, <strong>but what has changed is how we use it</strong>.</p>
<p>We learned some tricks and the world changed around us.  We figured out how to solve the biggest problem of all for JavaScript…</p>
<p>Working with the DOM!</p>
<p><a href="http://jquery.com">JQuery</a> made it extremely easy to manipulate the DOM, the pain was removed.</p>
<p>Yet, new pains emerge, hence <a href="http://documentcloud.github.com/backbone/">backbone.js</a> is born.</p>
<h2>Thick client or the web?</h2>
<p>Take a look at how this has changed back and forth so many times.  First the web was a toy and real apps were installed on your machine.</p>
<p>Then it became very uncool to develop a desktop app, everyone was developing web apps.</p>
<p>But soon we ran into a little problem – those darn page refreshes.  Gosh!</p>
<p>So what did we do?  We sort of made the browser a thick client with AJAX.</p>
<p>That created so much of a mess that we really needed clean separation of views from our models and our logic (at least on the .NET side), so we went back to rendering the whole view on the server and sending it down to the client with MVC.  (Yes, you could argue this point, but just pretend like you agree and bear with me.)</p>
<p>Then we decided that we needed to start moving this stuff back to the client so we could do much more cool things with our pages. We started pumping JavaScript into the pages and ended up creating thick clients running in browsers running on JavaScript and HTML5.</p>
<p>And now we are seeing traditional thick clients again with iOS and Android devices and even those will probably eventually migrate to the web.</p>
<h2>Simple data vs descriptive data</h2>
<p>Check out this sine wave!</p>
<p><a href="http://complextosimple.files.wordpress.com/2012/02/sinewave.gif"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="SineWave" src="http://complextosimple.files.wordpress.com/2012/02/sinewave_thumb.gif?w=479&h=304" alt="SineWave" width="479" height="304" border="0" /></a></p>
<p>First we had fixed-length records where we specified the length of each column and exactly what data went there.</p>
<p>Then we moved over to CSV, where we had loose data separated by commas.</p>
<p>Then we thought XML was all the rage and beat people up who didn’t define XSDs, because <strong>data without definition is just noise you know!</strong></p>
<p>Now we are sending around very loosely structured JSON objects and throw-up whenever we see angle brackets.</p>
<h2>So many other examples</h2>
<p>Take a look at this list:</p>
<ul>
<li>Static vs dynamic languages</li>
<li>Web services ease of use vs unambiguity (SOAP and REST)</li>
<li>Design upfront vs Agile (remember when we just wrote code and deployed it, it was kind of like Agile, but different)</li>
<li>Source control, constant collaboration vs branching</li>
<li>Testing and TDD</li>
<li>Databases, stored procs vs inline SQL</li>
<li>&lt;% %&gt; vs Controls</li>
<li>…</li>
</ul>
<p>It goes on forever</p>
<h2>So why is this important?</h2>
<p>It is not just important, as a developer, it is <strong>CRITICAL</strong> for you to understand.</p>
<p>Why?</p>
<p>Because whatever happens to be “cool” right now, whatever happens to be the “right” way to do things right now, will change.</p>
<p><strong>Not only will it change, but it will go the complete opposite direction.</strong></p>
<p>It won’t look exactly the same as it did before – we will learn from our previous mistakes – but it will be the same concepts.</p>
<p>Advancement follows this sine wave pattern.  <strong>Don’t try and fight it so hard.</strong></p>
<p>You have to be balanced.  You have to be able to understand the merits, strengths and weaknesses of both sides of a technology or best practice choice in development.</p>
<p>You have to understand why TDD improved our code until it led us into overuse of IoC and pushed C# and Java developers to the freedom of dynamic languages like Ruby.</p>
<p>You have to understand that eventually the course will correct itself yet again and head back to the direction of the new static language or even an old static language that will be resurrected.</p>
<h2>This is how you will grow</h2>
<p>It is also very important to realize that this is exactly how you will grow.</p>
<p>Just as the technological world around you is in a constant forward progressing pendulum swing, so are you, at a different pace, to a different beat.</p>
<p>I know that through my personal development journey, I have switched sides on a topic countless times.</p>
<p>You might call me a “waffler,” but I call it progress.</p>
<p>Life is a game of overshooting and adjusting.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1447/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&#038;blog=10597120&#038;post=1447&#038;subd=complextosimple&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2012/02/09/the-development-pendulum/feed/</wfw:commentRss>
		<slash:comments>15</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/2012/02/snakeboard_thumb.jpg" medium="image">
			<media:title type="html">snakeboard</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2012/02/sinewave_thumb.gif" medium="image">
			<media:title type="html">SineWave</media:title>
		</media:content>
	</item>
	</channel>
</rss>
