<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Peter Swan on Medium]]></title>
        <description><![CDATA[Stories by Peter Swan on Medium]]></description>
        <link>https://medium.com/@pdswan?source=rss-1740f0e83d96------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hpuwzTUUiDswYZ5p.jpg</url>
            <title>Stories by Peter Swan on Medium</title>
            <link>https://medium.com/@pdswan?source=rss-1740f0e83d96------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 02:50:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pdswan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Reading List for Curious Developers]]></title>
            <link>https://medium.com/@pdswan/a-reading-list-for-curious-developers-bb68f0294d46?source=rss-1740f0e83d96------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb68f0294d46</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[readinglist]]></category>
            <dc:creator><![CDATA[Peter Swan]]></dc:creator>
            <pubDate>Fri, 27 Mar 2015 03:23:01 GMT</pubDate>
            <atom:updated>2015-03-27T03:30:17.278Z</atom:updated>
            <content:encoded><![CDATA[<p>books I’ve read that fundamentally changed the way I think about software development</p><p>Yesterday at <a href="https://gust.com/">Gust</a>, during a retrospective around our on-boarding process, one of our more recent hires requested we put together a list of books for new developers interested in learning more about the things we value in software and the software development process.</p><p>Hence, here is an incomplete list of books that are — IMHO — highly valuable reading for software developers; especially those working with Ruby and/or Rails.</p><ol><li><a href="https://pragprog.com/book/hwcuc/the-cucumber-book">The Cucumber Book</a> &amp;<a href="https://pragprog.com/book/achbd/the-rspec-book">The RSpec book</a> — There is a lot of overlap in these two, but they provide an excellent basis for practicing outside in, behavior / test driven development in Ruby. <strong>Too many people misuse and abuse Cucumber, you don’t have to be one of them.</strong></li><li><a href="http://www.growing-object-oriented-software.com/">Growing Object Oriented Software Guided by Tests</a> — The best book I’ve read about applying outside in, test driven principles to a non-trivial, real-world use case. <strong>Confused as to how mocks can be useful? This is the book for you.</strong></li><li><a href="http://objectsonrails.com/">Objects on Rails</a> — Change your thought process while working in Rails. <strong>Learn to rely on the facilities provided by Rails when you need them, not as a default.</strong></li><li><a href="http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052">Working Effectively with Legacy Code </a>— <strong>Learn to use tests to explore and characterize a system</strong> in order to work effectively with untested code, code you don’t understand, or code you wrote last week.</li><li><a href="http://www.manning.com/bjarnason/">Functional Programming in Scala</a> — A challenging, but equally rewarding introduction to functional programming. <strong>Understanding this book will make you a better programmer; it will also make you deeply skeptical of object oriented programming.</strong> If it doesn’t, read it again.</li></ol><p>A note on reading: your mileage will vary based on your state of mind when you crack any one of these books. Be skeptical of everything, but prioritize internalizing and understanding concepts you find valuable over dismissing concepts you disagree with.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb68f0294d46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nothing is Something…and Something is often Something else]]></title>
            <link>https://medium.com/@pdswan/nothing-is-something-and-something-is-often-something-else-a54709b45c33?source=rss-1740f0e83d96------2</link>
            <guid isPermaLink="false">https://medium.com/p/a54709b45c33</guid>
            <dc:creator><![CDATA[Peter Swan]]></dc:creator>
            <pubDate>Fri, 30 Jan 2015 17:14:54 GMT</pubDate>
            <atom:updated>2015-01-30T18:03:41.374Z</atom:updated>
            <content:encoded><![CDATA[<h3>Nothing is Something…and Something is often Something Else</h3><p>Earlier this year I read a post by Sandi Metz called “<a href="http://www.sandimetz.com/blog/2014/9/9/shape-at-the-bottom-of-all-things">The Shape at the Bottom of All Things</a>”. This post is full of great information, but something about the code she ends up with bothered me.</p><p>I couldn’t articulate my issues at the time but, in an ironic twist of fate, attending Sandi’s talk “Nothing is Something” at the inaugural code genius last week helped me formalize my issues enough that I hope I can now express them to others.</p><p>First, I should note that “Nothing is Something” is a phenomenal talk and Sandi is a phenomenal speaker and teacher. You’ll have <a href="http://www.sandimetz.com/speaking/">plenty more chances</a> to catch this talk and I highly suggest you do. If you can’t there’s plenty of <a href="http://www.sandimetz.com/blog/">awesome</a> <a href="http://www.confreaks.com/presenters/211-sandi-metz">Sandi</a> material on the internet. I suggest you consume it all.</p><p>Both the talk and the post revolve around “<strong>This is the House that Jack Built</strong>”; from <a href="http://en.wikipedia.org/wiki/This_Is_the_House_That_Jack_Built">Wikipedia</a>:</p><blockquote>“<strong>This Is the House That Jack Built” </strong>is a popular <a href="http://en.wikipedia.org/wiki/United_Kingdom">British</a> <a href="http://en.wikipedia.org/wiki/Nursery_rhyme">nursery rhyme</a> and <a href="http://en.wikipedia.org/wiki/Cumulative_tale">cumulative tale</a></blockquote><p>For those of you that did not attend, I’ll try to quickly summarize the material.</p><p>We start here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9be232f426096537b58836d8bbc22df0/href">https://medium.com/media/9be232f426096537b58836d8bbc22df0/href</a></iframe><p>We receive a new requirement: the data should be randomized. We add a subclass RandomHouse to fulfill the requirement:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/931381191a339c8d22f0fd4094fca32d/href">https://medium.com/media/931381191a339c8d22f0fd4094fca32d/href</a></iframe><p>We receive a third requirement: each line should be repeated. We add an additional subclass, EchoHouse to fulfill this requirement.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a381169833407421ba4a81b2336d1d2/href">https://medium.com/media/7a381169833407421ba4a81b2336d1d2/href</a></iframe><p>Now the kicker: the product team requests a random version that <em>also</em> repeats. We get that sinking feeling as we realize it’s happened again: <strong>a</strong> <strong>new requirement has <em>completely invalidated our design decisions</em></strong>!</p><p>We are stuck, and we are failed by inheritance, but why? Sandi has a pretty wonderful methodology for figuring it out, it’s based on the idea that:</p><blockquote>You can see more about how things differ by making them more alike.</blockquote><p>First we <strong>identify the difference</strong> between House and RandomHouse: the call to shuffle. Next we <strong>surface the difference as a first-class citizen by giving a name to the concept it represents</strong>: Ordering. Next we observe that <strong>the name of our concept does not have an <em>is a </em>relationship with our class</strong>: Ordering <em>is not a</em> House. This observation helps us understand that inheritance is not the correct way to structure our code! Finally, we <strong>make something out of nothing</strong> by observing that a lack of ordering can also be interpreted as a default ordering or a <a href="http://en.wikipedia.org/wiki/NOP">noop</a>!</p><p>Armed with these observations we arrive at a more flexible, composable implementation that utilizes <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/860370cd2373f11e250a40ad1bf0f62f/href">https://medium.com/media/860370cd2373f11e250a40ad1bf0f62f/href</a></iframe><p>We undertake the same exercise with EchoHouse, but the name of the concept is more elusive. We settle for the more generic idea of “morphing” data and end up with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb92d75e95582b389de7a35c3e22ad2d/href">https://medium.com/media/fb92d75e95582b389de7a35c3e22ad2d/href</a></iframe><p>Now we’ve fulfilled all the requirements and we’ve developed new techniques and intuition along the way. This is not a bad day’s work!</p><p>But are we done?</p><p>There was some some discussion about diminishing returns of re-factoring and the specter of over engineering at this point in the night. I got the impression that the consensus in the room was that this was an o.k. place to stop.</p><p>I‘d like to assert that we are most definitely not done; here’s why:</p><p><strong>We have built up considerable context and intuition around the code as we’ve been working with it, but this context and intuition will fade over time. Nobody will ever be in a better position to solidify concepts and separate responsibilities than we are right now.</strong></p><p>So take a breather, stretch your legs and then take another sniff around your code before you call it quits.</p><p>Ready?</p><p>Let’s return to the same technique we used earlier. Take a look at <a href="https://gist.github.com/pdswan/5663b99f12b34d751bcc">all</a> the <a href="https://gist.github.com/pdswan/4749aee85beda3f6d0c6">iterations</a> <a href="https://gist.github.com/pdswan/2e7d78a505fee8461470">of</a> <a href="https://gist.github.com/pdswan/a16b48e7ee25716c395d">our</a> <a href="https://gist.github.com/pdswan/c2c090bef742ed62ad02">code</a> and make note of the differences to bring them into sharper relief.</p><p>Interesting isn’t it? Did we change less than you thought?</p><p><strong>Turns out we haven’t made a single change to the algorithm behind House#recite. We’ve only changed how @pieces are initialized!</strong></p><p>Just by applying the same techniques again at the end of a development cycle we’ve uncovered a pretty clear violation of the <a href="http://blog.8thlight.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html">Single Responsibility Principle</a>! House has at least two reasons to change:</p><ol><li>the @pieces to recite change (the data)</li><li>the way in which the @pieces are recited changes(the behavior)</li></ol><p>This particular violation is easy to fix, we just remove the responsibility of initializing pieces from House altogether:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/401c74a759a3ebe47ced05f008398893/href">https://medium.com/media/401c74a759a3ebe47ced05f008398893/href</a></iframe><p>No longer burdened with the concerns of data transformation, House is now primarily concerned with recitation, which, brings a new problem into focus: <strong>House is a terrible name for a class primarily concerned with recitation!</strong></p><p>Much has been <a href="http://www.objectmentor.com/resources/articles/Naming.pdf">written</a> <a href="http://objology.blogspot.com/2011/09/one-of-best-bits-of-programming-advice.html">about</a> <a href="http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html">naming</a>, but for the sake of brevity, let’s keep things simple and try to improve our names by aligning with the definition from <a href="http://en.wikipedia.org/wiki/This_Is_the_House_That_Jack_Built">Wikipedia</a>:</p><blockquote>“<strong>This Is the House That Jack Built” </strong>is a popular <a href="http://en.wikipedia.org/wiki/United_Kingdom">British</a> <a href="http://en.wikipedia.org/wiki/Nursery_rhyme">nursery rhyme</a> and <a href="http://en.wikipedia.org/wiki/Cumulative_tale">cumulative tale</a></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fee3073d74914de839303c034d76afc/href">https://medium.com/media/4fee3073d74914de839303c034d76afc/href</a></iframe><p>Great! So what have we gained by our additional effort?</p><p>Let’s adopt the perspective of a developer unfamiliar with the code. Try searching the internet for “CumulativeTales”. Now try searching for “House”. By <strong>solidifying the context of our code and naming it appropriately we help developers make informed decisions about how to use it and extend it</strong>.</p><p><strong>Separating data from </strong>the<strong> behavior </strong>of recitation<strong> has made our code obviously re-useable</strong>: it can be used to recite any collection of pieces that implements #last and #length without changing anything!</p><p><strong>Before our modifications re-use would have required another developer to recognize that a class named House contained a recitation algorithm that was independent of the data hardcoded right next to it</strong>.</p><p><strong>That developer</strong> <strong>would also have to convince herself that the code was not written in a way that prohibited re-use <em>on purpose</em></strong>. In my experience these factors present a surprisingly high barrier to re-use that often results in wheel re-invention especially in a team setting.</p><p><strong>Separating the responsibilities</strong> of ordering and morphing from the recitation algorithm allowed us to <strong>simplify the code by reducing the number of initialization arguments from 2 to 1</strong>. Additionally, <strong>future data transformation requirements will never require us to change code in the CumulativeTales module!</strong></p><p>To summarize, we have:</p><ol><li>Made our code more instructive for future developers (ourselves included)</li><li>Removed barriers to re-use</li><li>Allowed different concerns to change independently</li><li>Simplified the code</li></ol><p>I hope that’s enough to convince you that not only is this exercise not “over engineering”, it’s an exercise you should adopt in your day-to-day work.</p><p>With a little bit of effort you can shore up the foundations of your code and guide future developers (yourself included!) toward sustainable change.</p><p>If you remain unconvinced maybe <a href="http://www.confreaks.com/presenters/211-sandi-metz">Sandi can convince you</a>! She addresses exactly these points around minute 24 =)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a54709b45c33" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>