<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Functional Refactoring and "You Can't Get There From Here"</title>
    <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Functional Refactoring and &amp;quot;You Can't Get There From Here&amp;quot;</title>
      <description>&lt;p&gt;I&#8217;ve been working in Haskell recently, and I find myself doing much less refactoring.  In fact, I rewrite more than I refactor.  
&lt;p&gt;I&#8217;m not talking about massive refactoring, but rather the sort of micro-refactoring that I do to move from one algorithm to another.  If you are working in an imperative language, you can often make micro waypoints &amp;#8211; little testable steps along the way as you change your code from one shape to another.  You can add a variable, confident that behavior won&#8217;t change because you haven&#8217;t used it yet, and you can move one statement down below another, changing the order of a calculation if (again) you are confident that the overall computation is order in variant.  As &lt;span class="caps"&gt;I TDD&lt;/span&gt; my code, I do those sorts of things.  I often refactor by introducing a parallel computation in the same method as the old one, and if the test passes, I knock out the old way of doing things and leave the shiny new one.
&lt;p&gt;In Haskell, however, I don&#8217;t do that, and it reduces the amount of time that I spend refactoring.  Yes, I rename variables, add parameters, and introduce where-clauses, etc. But, refactoring in Haskell seems different, and I think I know why now.  There are two reasons and they sort of intermingle.

&lt;p&gt;Imperative programs are built of little state changing variables, and one of the effects is that you can have lots of little bits changing independently. It&#8217;s rather easy to add mutating state variables and have &#8220;several calculations in the air&#8221; in a method while you are along the way toward reducing it to one. In functional programming, however, you use bigger pieces. Instead of looping, you use map or fold &amp;#8211; you end up with terse code which packs a lot of punch.  
&lt;p&gt;Here&#8217;s a function which determines a position within a document from a column/row coordinate (affectionately named x and y here):
&lt;code&gt;&lt;pre&gt;absPosition :: Buffer -&amp;gt; Int
absPosition (Buffer (x, y) contents) = x + lenPreviousLines contents
  where lenPreviousLines = foldr ((+).length) 0 . take y . terminatedLines
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;The thing to get from this example if you don&#8217;t read Haskell is that it is fully compositional.  Each of the dots in the definition of lenPreviousLines is a composition operation.  We apply the terminatedLines function to a string, and take its output and pass it to the function &#8216;take y&#8217;, then we pass its output to &#8216;foldr ((+).length) 0&#8217;.  The net effect (take my word for it) is that we end up with the sum of the lengths of a set of text lines.
&lt;p&gt;That small piece of code performs a rather large chunk of work.  It takes a string, splits it into lines, appends a newline to each line, takes y of the lines and then sums the count of their characters.  But, to me, that&#8217;s not the interesting part.  The interesting part is that it is tight.  There is no space for a parallel computation, no place where you can perform some computation off to the side and progressively move toward a different algorithm.  If you want to change the algorithm you essentially rewrite it &amp;#8211; you replace some chunk of that code with another chunk of code.
&lt;p&gt;One of the beautiful things about pure functional programming is that it eliminates side effects.  That, by itself, might not impress you, but the thing that it enables is very powerful, when you remove side effects you lose all barriers to composability.  It&#8217;s easy to make little tinker-toy-like parts which you piece together to do your work, and, in fact, that&#8217;s exactly what has happened in Haskell.  Most of the time, you can find a little function which will do what you want.  You don&#8217;t often have to drop down into primitive list operations or recursion.  Instead, you have this substrate of little composable bits.  We don&#8217;t have anything like that in traditional languages.  We drop down to loops, assignment and mutable variables all the time.  
&lt;p&gt;The end result, I think, is that a lot of refactoring in Haskell is more like rewriting, or (to be precise) it is more like the &#8216;Substitute Algorithm&#8217; refactoring in Martin Fowler&#8217;s Refactoring book.  In pure code, there isn&#8217;t any extra bandwidth for building up parallel computations.  The pieces are bigger, so many refactorings are more like leaps than micro-adjustments toward a goal.
&lt;p&gt;Is this good or bad?  I don&#8217;t know.  I think it is just different.  Personally, I&#8217;m happy to have higher level pieces, although, I have to admit, I sometimes miss the fluidity of work with more granular primitives.  It&#8217;s a place you can always drop down to and build back up from.  In Haskell, at the micro-level, you have to fix your sights on a new target and rebuild.</description>
      <pubDate>Wed, 05 Aug 2009 11:18:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0190c2b3-dfec-498a-8439-cf9b701fabef</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here</link>
      <category>Michaels Musings</category>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by Backup iphone sms</title>
      <description>&lt;p&gt;Stop data lose on the mobile.
So you can export the files to HDD.&lt;/p&gt;</description>
      <pubDate>Sat, 07 Jan 2012 06:10:02 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:c3a949cd-d9b0-4d65-aaf6-6b843940f8a9</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-195894</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by tv show</title>
      <description>&lt;p&gt;thanks a lot for sharing.
/danielle&lt;/p&gt;</description>
      <pubDate>Thu, 24 Nov 2011 15:10:22 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:14ca3100-e429-4ebd-a3d5-327340a7d6dc</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-177555</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by Arcteryx Jackets</title>
      <description>&lt;p&gt;&lt;a href="http://www.arcteryxjackets-sale.com" rel="nofollow"&gt;http://www.arcteryxjackets-sale.com&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 20 Nov 2011 21:55:03 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:634316db-2e59-432e-9824-69c4cac363af</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-176074</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by Spyder Jackets</title>
      <description>&lt;p&gt;&lt;a href="http://www.spyderjackets-outlet.net" rel="nofollow"&gt;http://www.spyderjackets-outlet.net&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 18 Nov 2011 00:50:43 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:aace7b97-6378-4712-aa9d-2a725c88e3e6</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-175237</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by beats by dr dre</title>
      <description>&lt;p&gt;A university student&lt;a href="http://www.drdrebeatsheadphones-australia.com" rel="nofollow"&gt;beats by dr dre&lt;/a&gt; caught by the enemy, the enemy tied him at the poles,&lt;a href="http://www.drdrebeatsheadphones-australia.com/justbeats-solo-purple-onear-headphones-with-controltalk-p-234.html" rel="nofollow"&gt;just beats solo headphones purple&lt;/a&gt; and then asked him: say, where are you? You do not say it electrocuted! S&lt;a href="http://www.drdrebeatsheadphones-australia.com/cheap-drdre-beats-studio-limited-edition-headphones-blackyellow-p-185.html" rel="nofollow"&gt;cheap dr.dre beats studio headphones balck/yellow&lt;/a&gt;tudents back to the enemy a word, the result was electrocuted, he said: I am TVU.&lt;a href="http://www.drdrebeatsheadphones-australia.com/cheap-beats-by-drdre-pro-performance-professional-headphones-white-p-192.html" rel="nofollow"&gt;Hot sale beats by dr dre pro  headphones&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 15 Nov 2011 02:51:34 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:55a44ead-8f9c-4f03-bd2d-20731e2ca337</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-173002</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by christian louboutin</title>
      <description>&lt;p&gt;The professional design make you foot more comfortable. Even more tantalizing,this pattern make your legs look as long as you can,it will make you looked more attractive.Moveover,it has reasonable price.If you are a popular woman,do not miss it.&lt;/p&gt;


	&lt;p&gt;Technical details of Christian Louboutin Velours Scrunch Suede Boots Coffee:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;Color: Coffee
Material: Suede
4(100mm) heel
Signature red sole x&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Fashion, delicate, luxurious Christian louboutins shoes on sale, one of its series is Christian Louboutin Tall Boots, is urbanism collocation. This Christian louboutins shoes design makes people new and refreshing. Red soles shoes is personality, your charm will be wonderful performance.&lt;/p&gt;</description>
      <pubDate>Thu, 03 Nov 2011 10:01:49 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d5d1e7f6-23f2-471c-a686-9581fddc4cc9</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-167645</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by ysbearing/yisong@1stbearing.com</title>
      <description>&lt;p&gt;Slewing bearing called slewing ring bearings, is a comprehensive load to bear a large bearing, can bear large axial, radial load and overturning moment. &lt;a href="http://www.1stbearing.com" rel="nofollow"&gt;http://www.1stbearing.com&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 19 Oct 2011 02:01:27 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:eef18d4f-16c9-48e2-8a40-a2fcf5a8e416</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-159360</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by Ashley Bowling</title>
      <description>&lt;p&gt;Cleanliness is next to godliness
Clothes make the man
Cold hands, warm heart&lt;/p&gt;</description>
      <pubDate>Sat, 15 Oct 2011 15:40:04 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:4811baf3-aa32-4f11-abc0-f3c1d73d967c</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-157208</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by bagsupplyer</title>
      <description>&lt;p&gt;Thank you for posting. Waiting for updating.&lt;a href="http://www.bagsupplyer.com/LV-AAA-n1108/" rel="nofollow"&gt;New fashion women LV purses AAA with best quality for wholesale on line from China free shipping&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 06 Sep 2011 03:53:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8ccb42ec-9231-466b-a686-cb5c9cbef659</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-137415</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by beats by dr   dre</title>
      <description>&lt;p&gt;as looking the same but there was not any proper resource, thanx now i have the link which i was looking for my research.&lt;a href="http://www.drdrebeatsheadphones-australia.com" rel="nofollow"&gt;beats by dr dre&lt;/a&gt;
&lt;a href="http://www.drdrebeatsheadphones-australia.com" rel="nofollow"&gt;beats by dre sale&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 29 Aug 2011 21:43:47 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a7cb094d-e80f-4513-934d-b12300ae645b</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-134055</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by dreamy gift house</title>
      <description>&lt;p&gt;Wow. You can listen to the track right here, and happy divine thoughts about the universe everybody!&lt;/p&gt;</description>
      <pubDate>Thu, 04 Aug 2011 21:25:13 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:aec3088a-adc1-4b7f-a67d-b0b92e7dc352</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-124495</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by deadbeat millionaire review</title>
      <description>&lt;p&gt;Would you like to banckup iphone SMS to mac, macBook, macbookPro as .txt files? Now a software iphone SMS to Mac Backup can help you to realize it.&lt;/p&gt;</description>
      <pubDate>Fri, 17 Jun 2011 12:43:52 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:eb0e133f-b5ac-4718-8c41-5c304edb2105</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-111831</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by cheap supras</title>
      <description>&lt;p&gt;Oh! Good I have read your topic I&#8217;m really super success Written  &lt;a href="http://www.cheapsuprasonsale.com" rel="nofollow"&gt;cheap supras shoes&lt;/a&gt;&#8230;! I believe you&#8217;ve made certain pleasant points in the topic likewise &lt;a href="http://www.newsuprasforsale.com" rel="nofollow"&gt;supras shoes&lt;/a&gt;. I guess you should not stop with this &lt;a href="http://www.newsuprasforsale.com" rel="nofollow"&gt;supras for sale&lt;/a&gt;; I would like to see more of your submissions &lt;a href="http://www.evibramfivefingers.com/" rel="nofollow"&gt;vibram 5 fingers&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Mon, 13 Jun 2011 08:20:28 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:089a7f3c-eb17-4da0-87a1-c43dde3e8249</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-110625</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by &lt;a href="http://www.suprafootwearonsale.com"&gt;supra footwear store&lt;/a&gt;</title>
      <description>&lt;p&gt;&lt;a href="http://www.suprafootwearonsale.com" rel="nofollow"&gt;supra footwear store&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 13 Jun 2011 08:10:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a2183350-5b49-4366-be83-0da6a71523f1</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-110621</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by [URL=http://www.suprafootwearonsale.com]supra footwear store[/URL]</title>
      <description>&lt;p&gt;thanks for the information..It&amp;#8217;s good to see this information in your post, i was looking the same but there was not any proper resource, thanx now i have the link which i was looking for my research.&lt;/p&gt;</description>
      <pubDate>Mon, 13 Jun 2011 08:06:55 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b467a610-7820-4251-9e35-f2a3163ca8c6</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-110620</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by beats by dr dre headphones</title>
      <description>&lt;p&gt;&lt;a href="http://www.drebeatsstudio.com/beats-by-dr-dre-studio-c-3.html" rel="nofollow"&gt;Beats by dr dre studio&lt;/a&gt; with look after talk in white. extra attributes on &lt;a href="http://www.drebeatsstudio.com/monster-beats-by-dr-dre-pro-headphones-black-p-15.html" rel="nofollow"&gt;Monster Beats By Dr. Dre Pro Headphones Black&lt;/a&gt; a specific tri-fold design and design and carrying circumstance which make for compact and uncomplicated safe-keeping when not in use. &lt;a href="http://www.drebeatsstudio.com/beats-by-dr-dre-solo-c-5.html" rel="nofollow"&gt;Beats by dr dre solo&lt;/a&gt; .&lt;/p&gt;</description>
      <pubDate>Wed, 08 Jun 2011 20:56:16 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6b46b2b6-227d-4080-99c6-6cd121bc0c69</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-109186</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by Jewellery</title>
      <description>&lt;p&gt;teri dhadkano ko chulu&lt;/p&gt;</description>
      <pubDate>Sat, 04 Jun 2011 05:53:42 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:09dea96d-2725-43f3-bc38-75be3d1eccaa</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-108052</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by mbt shoes sales</title>
      <description>&lt;p&gt;thank you for posting this SO MUCH.&lt;/p&gt;</description>
      <pubDate>Wed, 18 May 2011 23:38:53 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:37b53a86-9fa8-446c-a100-864747befee4</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-101563</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by f350 leveling kit</title>
      <description>&lt;p&gt;I will always check your website if there is always a new article. Thank you :-)&lt;/p&gt;</description>
      <pubDate>Thu, 12 May 2011 16:48:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:eb91d181-2e5f-49bd-b098-3f8a1b7d96c9</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-98902</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by leveling kit f250</title>
      <description>&lt;p&gt;I love your post. Thank you :-)&lt;/p&gt;</description>
      <pubDate>Thu, 12 May 2011 16:47:43 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:c078fc49-ded7-4691-b826-c2fced47925e</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-98901</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by leveling kit ford</title>
      <description>&lt;p&gt;Your post is informative I love it
Thanks a lot :-)&lt;/p&gt;</description>
      <pubDate>Thu, 12 May 2011 16:47:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f29fbf24-b4d0-47f4-932e-8be8f49053ce</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-98900</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by ford leveling kit</title>
      <description>&lt;p&gt;I love sharing information
Thank you :-)&lt;/p&gt;</description>
      <pubDate>Thu, 12 May 2011 16:46:16 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0928c44c-c6f8-4488-a208-770279c87316</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-98899</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by okey oyunu oyna </title>
      <description>&lt;p&gt;great article.&lt;/p&gt;


	&lt;p&gt;internette g&#246;r&#252;nt&#252;l&#252; olarak &lt;a href="http://www.okeyoyunu-oyna.com" rel="nofollow"&gt;okey oyunu oyna&lt;/a&gt;, ger&#231;ek kisilerle tanis,
 turnuva heyecanini yasa.&lt;/p&gt;</description>
      <pubDate>Thu, 28 Apr 2011 15:13:05 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:63fef7a1-c9ea-45e1-8f5b-3930b71b1e28</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-92793</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by rolex replica watch</title>
      <description>&lt;p&gt;i remember when math was much simpler in early school years where calcualtors had just become very affordable. This seems too complicated.&lt;/p&gt;</description>
      <pubDate>Fri, 22 Apr 2011 05:20:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:719e9111-a173-4eb1-b187-7659e9b10757</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-89539</link>
    </item>
    <item>
      <title>"Functional Refactoring and "You Can't Get There From Here"" by Big pony</title>
      <description>&lt;p&gt;Thank you for sharing,it is very helpful and I really like it!&lt;/p&gt;</description>
      <pubDate>Mon, 11 Apr 2011 07:14:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0610de72-50e1-44a9-a380-e638aebc248a</guid>
      <link>http://blog.objectmentor.com/articles/2009/08/05/functional-refactoring-and-you-cant-get-there-from-here#comment-82876</link>
    </item>
  </channel>
</rss>

