<?xml version="1.0"?>
<?xml-stylesheet href="/transform" type="text/xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:bibo="http://purl.org/ontology/bibo/" xmlns:bs="http://purl.org/ontology/bibo/status/" xmlns:ci="https://vocab.methodandstructure.com/content-inventory#" xmlns:dct="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" lang="en" prefix="bibo: http://purl.org/ontology/bibo/ bs: http://purl.org/ontology/bibo/status/ ci: https://vocab.methodandstructure.com/content-inventory# dct: http://purl.org/dc/terms/ foaf: http://xmlns.com/foaf/0.1/ rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# xhv: http://www.w3.org/1999/xhtml/vocab# xsd: http://www.w3.org/2001/XMLSchema#" vocab="http://www.w3.org/1999/xhtml/vocab#" xml:lang="en">
  <head>
    <title property="dct:title">Production Code</title>
    <base href="https://doriantaylor.com/production-code"/>
    <link href="document-stats#EAHA9e0S8-BfLJW5X1Ef5K" rev="ci:document"/>
    <link href="elsewhere" rel="alternate bookmark" title="Elsewhere"/>
    <link href="this-site" rel="alternate index" title="This Site"/>
    <link href="http://purl.org/ontology/bibo/status/published" rel="bibo:status"/>
    <link href="" rel="ci:canonical" title="Production Code"/>
    <link href="lexicon/#EzqXIsriaILFcWjXdS7FbI" rel="dct:audience" title="Software Developer"/>
    <link href="person/dorian-taylor#me" rel="dct:creator" title="Dorian Taylor"/>
    <link href="person/dorian-taylor" rel="meta" title="Who I Am"/>
    <link about="./" href="3f36c30c-6096-454a-8a22-c062100ae41f" rel="alternate" type="application/atom+xml"/>
    <link about="./" href="f07f5044-01bc-472d-9079-9b07771b731c" rel="alternate" type="application/atom+xml"/>
    <link about="./" href="this-site" rel="alternate"/>
    <link about="./" href="elsewhere" rel="alternate"/>
    <link about="./" href="e341ca62-0387-4cea-b69a-cdabc7656871" rel="alternate" type="application/atom+xml"/>
    <link about="verso/" href="3f36c30c-6096-454a-8a22-c062100ae41f" rel="alternate" type="application/atom+xml"/>
    <link about="verso/" href="this-site" rel="alternate"/>
    <link about="verso/" href="elsewhere" rel="alternate"/>
    <meta content="production-code" datatype="xsd:token" property="ci:canonical-slug"/>
    <meta content="&#x201C;I don't really see a difference between prototype and production code.&#x201D; OK what the hell do I mean by that?" name="description" property="dct:abstract"/>
    <meta content="2018-02-23T22:56:07+00:00" datatype="xsd:dateTime" property="dct:created"/>
    <meta content="production-code" property="dct:identifier"/>
    <meta content="2018-02-23T22:57:25+00:00" datatype="xsd:dateTime" property="dct:issued"/>
    <meta content="2018-02-28T05:11:42+00:00" datatype="xsd:dateTime" property="dct:modified"/>
    <meta content="2022-05-31T04:18:52+00:00" datatype="xsd:dateTime" property="dct:modified"/>
    <meta content="2022-05-31T15:10:50+00:00" datatype="xsd:dateTime" property="dct:modified"/>
    <meta about="person/dorian-taylor#me" content="Dorian Taylor" name="author" property="foaf:name"/>
    <meta content="summary" name="twitter:card"/>
    <meta content="@doriantaylor" name="twitter:site"/>
    <meta content="Production Code" name="twitter:title"/>
    <meta content="&#x201C;I don't really see a difference between prototype and production code.&#x201D; OK what the hell do I mean by that?" name="twitter:description"/>
    <object>
      <nav>
        <ul>
          <li>
            <a href="document-stats#EAHA9e0S8-BfLJW5X1Ef5K" rev="ci:document" typeof="qb:Observation">
              <span>urn:uuid:00703d7b-44bc-4f81-a7cb-256e57d447f9</span>
            </a>
          </li>
        </ul>
      </nav>
    </object>
  </head>
  <body about="" id="EvB5pmtyg0D2c09IFTlx-J" typeof="bibo:Article">
    <p>I was in a meeting earlier this week, during which I blurted out something about how I don't really consider much of a difference between prototype and production code, and I'm still trying to figure out what I meant.</p>
    <p>My career has been pretty much situated in its entirety in weirdo R&amp;D territory. The code I write has <a href="https://www.apache.org/licenses/LICENSE-2.0#no-warranty" rel="dct:references">no warranty of merchantability or fitness for a particular purpose</a>, as the saying goes. It nevertheless <em>has</em> found its way into production on numerous occasions. If there are any properites that demarcate prototype code from production, I'd say they converge toward:</p>
    <dl>
      <dt>Language</dt>
      <dd>Obviously if the prototype is in shell and the production is in C, the former will have to be rewritten into the latter. <em>But</em>, if prototype <em>and</em> production are <em>both</em> written in, say, Python or Ruby, there's a good chance at least one chunk of the prototype will end up in production verbatim.</dd>
      <dt>Performance, ex. language</dt>
      <dd>Typically when we write prototypes, we don't worry too much about loading giant files into memory or generating a lot of storage or network I/O. Same goes for sloppy algorithms with nested loops, or loops with black-boxed calls out to libraries that do any combination thereof. <em>Except</em> when the poor performance gets in the way of running the prototype over and over again, which is something you do a lot with prototypes. I find myself cleaning up at least <em>some</em> of this mess as I go.</dd>
      <dt>Error handling</dt>
      <dd>A similar condition holds as for performance: you run the prototype, over and over, over a bigger and more variegated input set. It's bound to crap out eventually, and you're gonna need to know why. All the places you suppressed errors, you're eventually going to have to go back and add some kind of handler for them. If you know that's the right thing to do at the outset, there's no sense in restraining yourself.</dd>
      <dt>Security</dt>
      <dd>I spent most of my career as a developer heavily informed by the infosec community, so including security features in my code is almost a compulsion. <em>However</em> knowing that environments where the prototype and production code are the same language, this compulsion becomes rational, because if <em>I</em> don't do it now, there's no telling whether somebody <em>else</em> will do it later. It's not like it's hard, or takes a lot of time: almost all security programming reduces to making sure the data you just ingested corresponds to what it claims to be, or at least what you assume it ought to be. In other words: input sanitation, which intersects heavily with <em>error handling</em> directly above.</dd>
      <dt>Documentation</dt>
      <dd>Of course production code, at least in theory, is supposed to be comprehensively documented. In a prototype, this is arguably a waste of time. I may be betraying one of my idiosyncrasies here, but I disagree. I write prose documentation in prototypes all the time, but my <em>motivation</em> is distinctly different. It's much more akin to <a href="http://www.literateprogramming.com/" rel="dct:references">literate programming</a>, a story about how I want the process to behave, rather than a spec or an operator's manual&#x2014;although those feature too. Moreover, I include naming things like classes and methods and method signatures under the umbrella of <em>documentation</em>, and for much the same reason&#x2014;that is, the tendency for prototypes to get appropriated into production. I do give those some non-zero consideration since it's so much harder to change the names of things once those names have been minted.</dd>
      <dt>Test suite</dt>
      <dd>Perhaps the one place I am decidedly <q>prototype</q> is in the test suite, <em>however</em> that is largely because in the early stages of a piece of software it is <span class="parenthesis" title="Indeed, if I had subscribed to TDD or some variant I would never have written any actual software.">rarely clear precisely what needs to be tested and how.</span> Nevertheless, automated tests are useful in prototypes for things you can't eyeball, and I find they accumulate organically, so it's best to assume up front that they will.</dd>
      <dt>Packaging</dt>
      <dd>One essential feature of production software is that a user&#x2014;for some definition of the term&#x2014;should be able to install it. Nowadays, with distributed teams, each member running their own self-contained development environment on their laptops, even <em>prototypes</em> have users. Furthermore, most modern languages have <span class="parenthesis" title="which include infrastructure for test suites">extremely sophisticated boilerplate generators</span>, such that to <em>not</em> package your code is actually going out of your way.</dd>
    </dl>
    <p>One of the more memorable experiences of my software development career has to be a 20-minute argument I had with a boss over a 2-minute expenditure on some input sanitation in some module or other, which had been largely generated from boilerplate. The charge was, of course, that I had wasted time, which I suppose was true if I was <em>also</em> to be held responsible for the order-of-magnitude blowup over it, but in my judgment the input sanitation itself was a good investment.</p>
    <p>The reason why, is because if you allow me my precious two minutes to exercise what I concede is ultimately a <em>tic</em>&#x2014;implementing an input sanitation routine&#x2014;then I don't have to second-guess the code further down the line. As the author, I am outsourcing a great measure of my cognitive overhead into the artifact&#x2014;my own and that of anybody who comes after me. <span class="parenthesis" title="or anybody else">If I</span> don't have to occupy myself with trivia, like whether or not an algorithm is actually being fed the right data, then progress on the whole goes <em>faster</em>.</p>
    <p>Alan Kay <span class="parenthesis before" title="at least">once</span> said <q>If you choose the right data structure, most of the computation is already done for you.</q> In a way, the prototype is <em>itself</em> a kind of computation: you are <q>computing</q> the optimal configuration for a formal process, along with its concomitant structure. The difference is this computation is happening inside your head. Why would you deliberately choose a suboptimal configuration when you were aware of an optimal one? Because of a one-time savings of two minutes?</p>
    <aside role="note" id="E9wU4isVZWHmLxpaHc_8zI">
      <p>Of course, here is where the shrewd interlocutor says something like <q>ah, but events like these add up!</q> Sure, but how many are we talking? It takes thirty of these things to make an hour. The point of a prototype is to get it <em>right</em>. If your business strategy depends on whether a prototype is gotten right sooner, on the scale of actual literal <em>hours</em>, then you've probably never done this before.</p>
    </aside>
    <p>By definition, a prototype has to encode at <em>least</em> the rudiments of the process to be carried out in production, or it doesn't demonstrate anything. To evolve production software directly out of a prototype when both are written in the same language, I believe is a perfectly natural and sensible thing to do. So is including features of production code in the prototype when it would cost more to argue about than just to do it, and to do so would only improve the output.</p>
    <p>Anyway, I think that's what I was getting at.</p>
  </body>
</html>
