<?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: The Successor Value Pattern</title>
    <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>The Successor Value Pattern</title>
      <description>&lt;p&gt;Functional programming is in the air.  It&amp;#8217;s nearly unavoidable. Even if you haven&#8217;t heard people talk about it or haven&#8217;t read a blog about it, you&#8217;ve probably seen its influence in your project.  People are taking ideas that they learned in functional programming and applying them in straight object-oriented code.  In Java, where there are no closures, today you are much more likely to encounter someone&#8217;s hand-rolled fold or map abstraction, and even if they haven&#8217;t gone that far, you are likely to find attempts to replace mutable data with immutable data.  It&#8217;s part of the learning process, and there are some interesting patterns which occur along the way.
&lt;/p&gt;

&lt;p&gt;OO programmers often think in terms of entities.  They imagine objects with identity and  changeable local state; messages sent to objects alter their local state and trigger further message sends.  Classic OO is intrinsically time-oriented.  How do we pull this into a functional world?  One thing that we can do is choose to see an entity as a series of values over time.  Here&#8217;s one way to do it.  If we have an entity like this:
&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
public class EventDay {
    private LocalDate date;

    ...

    public void advance() {
        do {
            date = RegionalEventCalendar.nextValidDate(date)
        } while (!fitsLocalCalendar(date));
    }

    ...
}

&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;We can change it to this:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
public class EventDay {
    private final LocalDate date;

    ...

    public EventDay next() {
        return new EventDay(prospectiveDay(date));
    }

    ...
}

&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;This is the &lt;i&gt;successor value pattern&lt;/i&gt;.  The notion is that you model state change as a series of value transformations.  Is this good?  Well, successor value is extremely common in functional programming languages.  In Haskell, for instance, you don&#8217;t have mutation so you are always constructing new values.  When Scala and F# are used in a functional style, you do the same thing; but is this a good idea in Java, C#, and C++?  One concern is that the runtimes and libraries of those languages might not be as well tuned for continual reconstruction of value representations of the larger domain objects that we often see in OO designs.  On the surface, however, &lt;i&gt;successor value&lt;/i&gt; is nice; it gives us a mapping to immutable values and a dose of referential transparency.
&lt;/p&gt;

&lt;p&gt;&lt;i&gt;Successor Value&lt;/i&gt; has an interesting quality from a type perspective.  You compute successor values using a function which takes a type to another value of that same type.  In the example above, &lt;code&gt;next&lt;/code&gt; is a function like that.  It maps from &#8216;this&#8217;, which has the type EventDay, to a new EventDay. In category theory, this is called an endomorphism.  It&#8217;s a relationship with some cool characteristics.  One of them is closure. You can chain any number of endomorphic operations and still end up with the type you started with:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
LocalDate next  = date.nextDay().nextWeek().fridayAfter();
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
This is really about as encapsulated as you can get.  Endomorphic chains don&#8217;t betray their representations and they don&#8217;t force users to use new types.  In a way, you can look at an endomorphic chain as a state machine over an entity, spread out over time.
&lt;/p&gt;

&lt;p&gt;If you are used to thinking in terms of entities, you can mechanically translate entities into values and mapping functions.  However, the better thing is to rethink your data types a bit. Sometimes the mapping from entities to values is clean but often with a bit of thought you can end up with representations which are better tuned for functional work.&lt;/p&gt;</description>
      <pubDate>Sun, 22 Mar 2009 11:03:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9069d8ed-dd87-4cb4-8252-180bea0aad4d</guid>
      <author>Michael Feathers</author>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern</link>
      <category>Michaels Musings</category>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Office 2010</title>
      <description>&lt;p&gt;This article is GREAT it can be EXCELLENT JOB and what a great tool!&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jan 2012 20:29:07 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:998a74d1-0a05-494a-b0a6-492586c43cff</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-197755</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by iphone contacts backup</title>
      <description>&lt;p&gt;All-in-one solution to backup iPhone contacts and SMS, transfer iPhone video, songs, ebooks, photo, call list and more to computer or iTunes&lt;/p&gt;</description>
      <pubDate>Sat, 07 Jan 2012 06:53:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3da63c59-9025-4801-8587-0eebea627359</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-195911</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by batterycharger</title>
      <description>&lt;p&gt;Welcome you online shopping for discount and highest quality replacement batteries. We specializing in laptop battery, digital camera battery, camcorder battery, pda battery, cell phone battery, portable DVD battery, two way radio battery, MD Walkman battery, laptop AC adapter, laptop DC adapter, portable DVD player adapter and iPod Accessories.
&lt;a href="http://www.fujifilm-battery-charger.co.uk/Charger/Fujifilm/Fujifilm-NP-45A.html" rel="nofollow"&gt;Fujifilm NP-45A Digital Camera Battery Charger&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 17 Nov 2011 19:49:57 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:c55a1817-64b9-4d4f-a0be-c1f085d5bc43</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-174890</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by marlado</title>
      <description>&lt;p&gt;Nice tuto
&lt;a href="http://cespedartificialpreciosymas.com/" rel="nofollow"&gt;Cesped Artificial Precios&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 08 Nov 2011 13:01:37 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:34218a81-4036-45ef-a0f1-674e2c52f519</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-170009</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Tips For Bowling</title>
      <description>&lt;p&gt;Until the last great war, a general expectation of material improvement was an idea peculiar to Western man. Now war and its aftermath have made economic and social progress a political imperative in every quarter of the globe.&lt;/p&gt;</description>
      <pubDate>Thu, 20 Oct 2011 15:37:49 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:aae24e92-e1d0-4152-8735-7e1ead43253e</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-160269</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by ysbearing</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;/p&gt;</description>
      <pubDate>Wed, 19 Oct 2011 02:56:56 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:79806ff0-63f6-457d-90d2-32398c0a8a7b</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-159423</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by robert.robot369@gmail.com</title>
      <description>&lt;p&gt;. This is really very happy for the great services in this blog. Thanks a lot for using the great info is visible in this blog and the nice services in this blog. &lt;a href="http://programcoordinatorjobdescription.com" rel="nofollow"&gt;Program Coordinator Job Description&lt;/a&gt;|&lt;a href="http://hospitaladministratorjobdescription.com/" rel="nofollow"&gt;Hospital Administrator Job Description&lt;/a&gt;|&lt;a href="http://cookjobdescription.com/" rel="nofollow"&gt;Cook Job Description&lt;/a&gt;|&lt;a href="http://jobdescriptionforregisterednurse.com" rel="nofollow"&gt;Registered Nurse Job Description&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 01 Oct 2011 02:20:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:efe2eb81-ce58-4aa0-81d3-d04796a2588d</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-148860</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by african Mango dr oz</title>
      <description>&lt;p&gt;Corporations are challenging existing business models as they seek ways to speed innovation, focus on their core competencies, and scale to capitalize on opportunities and outpace competitors.&lt;/p&gt;</description>
      <pubDate>Tue, 27 Sep 2011 11:51:11 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:39a3b2be-3d36-4fd1-a22f-bb786f7e4c71</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-146168</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Cookies Gift</title>
      <description>&lt;p&gt;Blog posts about wedding and bridal are always rare to find , at least with great quality,you qualify for a great blog post writer title,kep the great job happening&lt;/p&gt;</description>
      <pubDate>Sun, 19 Jun 2011 11:49:31 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:adfca300-5c62-43cd-9032-354c07e9ec80</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-112528</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by beats by dr dre headphones</title>
      <description>&lt;p&gt;I attempted these &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; out in several genres thinking about which i listen to an eclectic mix &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;. A all natural suit With Solos, you really feel the music, not the &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;.&lt;/p&gt;</description>
      <pubDate>Wed, 08 Jun 2011 20:59:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d4387604-42c0-40c8-8d8c-d086c8112fe8</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-109189</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by okey oyunu oyna </title>
      <description>&lt;p&gt;useful!&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 07:18:33 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:762e357d-4717-452d-9dee-e25b445893eb</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-92691</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Roger Cerrone</title>
      <description>&lt;p&gt;This is great stuff. I have to say i am impressed by your ideas. &lt;a href="http://www.kirkeyroofing.com/" rel="nofollow"&gt;roofing contractor venice&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 14 Apr 2011 08:38:31 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:e795de76-a1bf-4790-8ff7-d82a5ed0bde5</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-84868</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Big pony</title>
      <description>&lt;p&gt;good articles,come on ,you can do better&amp;#8230;.&lt;/p&gt;</description>
      <pubDate>Mon, 11 Apr 2011 07:16:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8dbd88b5-93a9-44d0-b72c-8bda09667f13</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-82883</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by bee</title>
      <description>&lt;p&gt;I was recommended this website by my cousin. I&#8217;m not sure whether this post is written by him as no one else know such detailed about my problem. You are wonderful! Thanks!&lt;/p&gt;</description>
      <pubDate>Wed, 30 Mar 2011 11:10:35 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1497e049-37cc-4eb0-b579-474c7dcb5d77</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-77584</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by wholesale hair weave</title>
      <description>&lt;p&gt;You do not need any oily residue there, since this is the spot where you will be applying your lace.. You can also use skin prep and let dry before applying glue.&lt;/p&gt;</description>
      <pubDate>Thu, 24 Mar 2011 20:22:43 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:95fbacf2-3c5c-46ed-a0fc-2a6fb9ee1261</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-75216</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by dswehfhh</title>
      <description>&lt;p&gt;We are the professional &lt;a href="http://www.china-clothing-manufacturer.com/jackets.html" rel="nofollow"&gt;jacket manufacturer&lt;/a&gt;, &lt;a href="http://www.china-clothing-manufacturer.com/jackets.html" rel="nofollow"&gt;jacket supplier&lt;/a&gt;, &lt;a href="http://www.china-clothing-manufacturer.com/jackets.html" rel="nofollow"&gt;jacket factory&lt;/a&gt;, welcome you to &lt;a href="http://www.china-clothing-manufacturer.com/jackets.html" rel="nofollow"&gt;custom jacket&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Wed, 09 Mar 2011 13:43:02 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:5b208bcb-fe5b-4a7e-ba60-4ac267d78bd5</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-71055</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by cable ties</title>
      <description>&lt;p&gt;love the discussion in here. lots of great ideas.&lt;/p&gt;</description>
      <pubDate>Thu, 03 Mar 2011 05:23:42 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3139f156-e4af-45af-b605-19da5203f0ab</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-68694</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by pandora</title>
      <description>&lt;p&gt;Thanks for taking the time to discuss and share this with us, I for one feel strongly about it and really enjoyed learning more about this topic. I can see that you possess a degree of expertise on this subject, I would very a lot like to hear much more from you on this subject matter &#8211; I have bookmarked this page and will return soon to hear additional about it.&lt;/p&gt;</description>
      <pubDate>Wed, 26 Jan 2011 20:54:39 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:82e26e14-a2c4-45b0-8e66-84b1ab495be0</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-59644</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by jvc charger</title>
      <description>&lt;p&gt;Video cameras have to be frequented primarily in two modes. The first, characteristic on a lot early television, is what could be known as a. Images directly To a screen for Immediate observation. A couple cameras still accommodate live television production, but lots of live connections in most cases are being security, military/tactical, as well as industrial operations where surreptitious or remote viewing is required. The 2nd is To have on the images recorded To a container device being archiving or farther processing; as Many years,. was the primary format frequented as this purpose, rather. Recorded video is used into TV and film production, and more commonly. and monitoring tasks where unattended recording as for a situation is required as at a later time analysis.&lt;/p&gt;</description>
      <pubDate>Mon, 24 Jan 2011 22:02:48 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:f9dcd4f6-f38a-4835-a960-d119c0eeb2af</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-59175</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by iPad to mac transfer</title>
      <description>&lt;p&gt;I really like this essay. Thank you for writing it so seriously.  I want to recommend it for my friends strongly. iPad to Mac Transfer can help you transfer music, movie, photo, ePub, PDF, Audiobook, Podcast and TV Show from ipad to mac freely.&lt;/p&gt;</description>
      <pubDate>Fri, 21 Jan 2011 05:13:30 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:2c8ae437-0726-4812-98c8-6a14467b1891</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-58338</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by accounting services</title>
      <description>&lt;p&gt;Very interesting post, I like the successor pattern a lot, but I&#8217;m also one of those people who like functional programming and immutable objects.&lt;a href="http://www.admgroupllc.com/" rel="nofollow"&gt;accounting services&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 20 Jan 2011 09:53:45 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:966c16c0-aafa-4c15-8993-26017b0a6e79</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-58170</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by replica tag heuer carrera</title>
      <description>&lt;p&gt;I suppose the students who take our TDD course could claim to be Object Mentor Certified TDDers; and they&#8217;d be right.&lt;/p&gt;</description>
      <pubDate>Fri, 14 Jan 2011 01:46:46 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:f7c5670b-33a7-4811-a721-047aa13bc5ef</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-56997</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Silicone Molding</title>
      <description>&lt;p&gt;&lt;a href="http://www.taiwanmoldmaker.com/service-mold-maker.html" rel="nofollow"&gt;Mold making&lt;/a&gt; is the core business of Intertech (Taiwan).  With world level technology,  
Intertech enjoys a very good reputation for making &lt;a href="http://www.taiwanmoldmaker.com/service-injection-mold.html" rel="nofollow"&gt;Injection Mold&lt;/a&gt; and 
&lt;a href="http://www.taiwanmoldmaker.com/service-plastic-mold.html" rel="nofollow"&gt;Plastic Molds&lt;/a&gt;for their worldwide customers.&lt;/p&gt;</description>
      <pubDate>Mon, 27 Dec 2010 21:01:59 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:e6fe7bea-9dce-4b1e-841f-b06ee1938a61</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-52298</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by http://www.blacktowhiteiphone4.com</title>
      <description>&lt;p&gt;Enjoy the christmas time and enjoy the hottest &lt;a href="http://www.blacktowhiteiphone4.com" rel="nofollow"&gt;white iphone 4&lt;/a&gt;. All you need to do is the white iphone 4 conversion kit home. &lt;br&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 22 Dec 2010 20:46:42 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:0780d3d2-01f3-426e-8db6-98e7476b512d</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-51165</link>
    </item>
    <item>
      <title>"The Successor Value Pattern" by Pandora </title>
      <description>&lt;p&gt;I suppose the students who take our TDD course could claim to be Object Mentor Certified TDDers; and they&#8217;d be right.&lt;/p&gt;</description>
      <pubDate>Thu, 02 Dec 2010 01:37:46 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:5211f06c-b9cd-4827-bbef-0513e0e65199</guid>
      <link>http://blog.objectmentor.com/articles/2009/03/22/the-sucessor-value-pattern#comment-45159</link>
    </item>
  </channel>
</rss>

