<?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/"
	>

<channel>
	<title>The Daily Build &#187; engineering</title>
	<atom:link href="http://blog.bstpierre.org/category/engineering/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bstpierre.org</link>
	<description>Software Development, version 3.0</description>
	<lastBuildDate>Fri, 03 Feb 2012 02:59:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Data vs Code</title>
		<link>http://blog.bstpierre.org/data-vs-code</link>
		<comments>http://blog.bstpierre.org/data-vs-code#comments</comments>
		<pubDate>Fri, 05 Feb 2010 16:08:05 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[engineering]]></category>
		<category><![CDATA[c-programming]]></category>
		<category><![CDATA[software-engineering]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=285</guid>
		<description><![CDATA[I&#8217;ll take an array over a giant switch-case statement any day. The array definition will be more compact and easier to see all at once. Defining actions in an array enforces uniformity. You can put checks in the code to automatically verify that the array definition is complete. (I.e. verify it contains a definition for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll take an array over a giant switch-case statement any day.</p>
<ol>
<li>The array definition will be more compact and easier to see all at once.</li>
<li>Defining actions in an array enforces uniformity.</li>
<li>You can put checks in the code to automatically verify that the array definition is complete. (I.e. verify it contains a definition for every item it should have.) Yes, some tools can do this for certain types of switch statements. Using an array-based check is more portable and more foolproof.</li>
</ol>
<p>If you have a switch statement of mostly cut and paste cases, you can probably convert it to an array very easily, and then rewrite the switch statement to look up the value in the array and do whatever thing is supposed to be done, either via function pointers or by using an associated value from the array.</p>
<p>I did this on a horrible switch statement once. Dozens of cases, 80% were nearly identical but the few that weren&#8217;t were awful to untangle. Once I pulled the case bodies into separate functions, put function pointers into a table, and replaced the switch body with a lookup loop it was much cleaner. The code for the odd cases was eventually pushed out (it was a symptom of bad design). The whole exercise enabled another round of changes that allowed the functions for the case bodies to be collapsed back into the table &#8212; we ended up removing an entire unnecessary layer of indirection and made the design much easier to grok.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/data-vs-code/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insist on Automatic Tests</title>
		<link>http://blog.bstpierre.org/insist-on-tests</link>
		<comments>http://blog.bstpierre.org/insist-on-tests#comments</comments>
		<pubDate>Fri, 29 Jan 2010 19:08:08 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[engineering]]></category>
		<category><![CDATA[software-engineering]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=281</guid>
		<description><![CDATA[At some point your team is going to be gone. Not all at once (well, maybe, but in that case you won&#8217;t care), but over time turnover will completely replace your team. If you are the manager, and you outlast the team, you&#8217;re going to pay for low quality code when you try to bring [...]]]></description>
			<content:encoded><![CDATA[<p>At some point your team is going to be gone. Not all at once (well, maybe, but in that case you won&#8217;t care), but over time turnover will completely replace your team.</p>
<p>If you are the manager, and you outlast the team, you&#8217;re going to pay for low quality code when you try to bring in new people and they end up breaking everything becuase there&#8217;s no tests to check their bug fixes and/or enhancements.</p>
<p>If you are a surviving member of the team, you&#8217;re going to pay with huge headaches because you&#8217;ve got to fix code where you have no idea what might be broken as a result.</p>
<p><strong>Change is scary when you don&#8217;t have automatic tests.</strong> Just suck it up and write the tests!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/insist-on-tests/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>If the comments are ugly, the code is ugly</title>
		<link>http://blog.bstpierre.org/if-the-comments-are-ugly-the-code-is-ugly</link>
		<comments>http://blog.bstpierre.org/if-the-comments-are-ugly-the-code-is-ugly#comments</comments>
		<pubDate>Tue, 17 Nov 2009 02:59:07 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[engineering]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=206</guid>
		<description><![CDATA[If the comments are ugly, the code is ugly (via slashdot). Amen! I get uncomfortable whenever I have to leave a long comment, but it&#8217;s usually to document some deficiency in a lower layer that the code is working around. Typically broken hardware. (So that someone coming behind me doesn&#8217;t say, &#8220;This is overly complicated, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.itworld.com/development/84780/if-comments-are-ugly-code-ugly">If the comments are ugly, the code is ugly</a> (via <a href="http://slashdot.org/">slashdot</a>). Amen! I get uncomfortable whenever I have to leave a long comment, but it&#8217;s usually to document some deficiency in a lower layer that the code is working around. Typically broken hardware. (So that someone coming behind me doesn&#8217;t say, &#8220;This is overly complicated, I can simplify it&#8221; and then proceed to blow everything up.)</p>
<blockquote><p>&#8220;Good programs do not contain spelling errors or have grammatical mistakes.&#8221;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/if-the-comments-are-ugly-the-code-is-ugly/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Who Else Wants Better Short Term Memory?</title>
		<link>http://blog.bstpierre.org/who-else-wants-better-short-term-memory</link>
		<comments>http://blog.bstpierre.org/who-else-wants-better-short-term-memory#comments</comments>
		<pubDate>Thu, 12 Nov 2009 13:13:24 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[engineering]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[codereview]]></category>
		<category><![CDATA[coding-standard]]></category>
		<category><![CDATA[software-engineering]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=197</guid>
		<description><![CDATA[In &#8220;Talent is Overrated&#8221;, Geoff Colvin at one point discusses how superstars in many fields use the memory technique of &#8220;chunking&#8221; to boost their short term memory. His simple example is the 13-letter word &#8220;lexicographer&#8221;. To you and I (assuming you speak English and have a decent vocabulary), it is easy to remember. We don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>In <a title="&quot;Talent is Overrated&quot; by Geoff Colvin -- on Amazon" href="http://www.amazon.com/dp/1591842247/?tag=bstpierreorg-20">&#8220;Talent is Overrated&#8221;</a>, Geoff Colvin at one point discusses how superstars in many fields use the memory technique of &#8220;<a title="More about chunking on wikipedia." href="http://en.wikipedia.org/wiki/Chunking_(psychology)">chunking</a>&#8221; to boost their short term memory.</p>
<p>His simple example is the 13-letter word &#8220;lexicographer&#8221;. To you and I (assuming you speak English and have a decent vocabulary), it is easy to remember. We don&#8217;t have to remember 13 letters, we just remember the whole chunk. But when presented with &#8220;trgdpxhdewfwm&#8221; for 3 seconds, you probably can&#8217;t remember more than half a dozen letters.</p>
<p>Another example is that chess masters can recall board positions after being shown a chess board with pieces on it for just a few seconds. They do this by chunking sets of pieces together &#8212; almost like &#8220;words&#8221; &#8212; whereas novices will try to remember individual pieces (&#8220;letters&#8221;).</p>
<p>It struck me that programmers do the same thing when reading and writing code.</p>
<p>The coding standard helps us, by telling us where the chunks are and how to draw the boundaries between chunks.</p>
<p>If you have a coding standard.</p>
<p>And apply it consistently.</p>
<p><strong>When you choose names at random, you destroy your short term memory.</strong> You become a crappy programmer, and you drag everyone around you down too.</p>
<p>Quick example in C. Assume you&#8217;re writing a small module for checking environmental status.</p>
<pre style="padding-left: 30px;">BOOL isOverTemp();
BOOL isUnderTemp();

int GetCurTemperature();

BOOL env_isOverVoltage();
BOOL env_isUnderVoltage();</pre>
<p>Anyone writing this pile of gibberish should be <span style="text-decoration: line-through;">fired</span> excommunicated.</p>
<p>Why?</p>
<p>For starters, I just wrote it, and I can&#8217;t now remember which was camel case and which was underscored. Also: which one was abbreviated?</p>
<p>Before you object that this is a contrived example, two points: (1) yes, it is contrived, that&#8217;s the point of an example, and (2) I have worked with far worse on an almost daily basis &#8212; the example above is fairly tame.</p>
<p>On the other hand, if you know the coding standard has some simple rules &#8212; <strong>and they are followed uniformly</strong> &#8212; you can easily remember the function names.</p>
<ol>
<li>Initial 2-3 letter module prefix (&#8220;env&#8221; for this example).</li>
<li>All functions are lowercase with underscores.</li>
<li>No abbreviations.</li>
</ol>
<p>Then we have:</p>
<pre style="padding-left: 30px;">BOOL env_is_over_temperature();
BOOL env_is_under_temperature();

int env_get_cur_temperature();

BOOL env_is_over_voltage();
BOOL env_is_under_voltage();</pre>
<p>Now, when you&#8217;re writing, reviewing, or maintaining code, you don&#8217;t need to constantly refer to the header or documentation to get it right. A simple three-line coding standard just boosted your memory capacity by over 643%.</p>
<p>(In the interest of full disclosure: I made that number up.)</p>
<p>I realize that implementing even this simple three line standard is controversial because all the camel case folks are pulling out big sticks and the underscore people are grabbing rocks. To which I say: just flip a coin and enjoy the extra brain power. Adopt a three-line standard, <strong>follow it</strong>, and save the curly-brace debate for the next major coding standard revision.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/who-else-wants-better-short-term-memory/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Makefiles are Software Too</title>
		<link>http://blog.bstpierre.org/makefiles-are-software-too</link>
		<comments>http://blog.bstpierre.org/makefiles-are-software-too#comments</comments>
		<pubDate>Tue, 14 Apr 2009 03:17:48 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[engineering]]></category>
		<category><![CDATA[software-engineering]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=173</guid>
		<description><![CDATA[This post was inspired by recent experience with some horrible build scripts from the open source world &#8212; but I&#8217;ve seen enough in-house badness over the years that I wanted to establish some basic parameters for build scripts. This is a really broad way to divide the world, but I see two important categories of [...]]]></description>
			<content:encoded><![CDATA[<p>This post was inspired by recent experience with some horrible build scripts from the open source world &mdash; but I&#8217;ve seen enough in-house badness over the years that I wanted to establish some basic parameters for build scripts.</p>
<p>This is a really broad way to divide the world, but I see two important categories of build scripts. (By &#8220;build script&#8221; I mean Makefiles, SConsfiles, Ant files, and their ilk).</p>
<ol>
<li>Build scripts intended for in-house use, never seen by outsiders.</li>
<li>Build scripts that you distribute to external users.</li>
</ol>
<p>Both sets of build scripts are important. Let&#8217;s consider the build script (or Makefile system, or whatever you&#8217;re using) as a software system independent of the software that is being built. Its primary requirement is to reliably convert your source code into an executable. Any decent build script has numerous other requirements, most of which are probably implied. I have never seen a written requirement for the numerous build scripts I&#8217;ve written. I have only rarely heard them discussed &mdash; and never actually posed as &#8220;requirements&#8221;.</p>
<p>I have, always taken the following meta-requirements for granted. Based on my experience with some fairly awful build scripts, I guess these aren&#8217;t universally acknowledged.</p>
<ul>
<li>The build script should build all the &#8220;normal&#8221; executables with a single command.</li>
<li>The build script must encapsulate all environment variables within the script. (This is a corollary of the above.)</li>
<li>The build script should not unnecessarily rebuild source code in a directory tree that has previously been built. (This is <tt>make</tt>&#8216;s raison d&#8217;etre.)</li>
<li>The build script should be documented. It doesn&#8217;t have to be elaborate, but a five-line comment at the top of the script describing the available command-line variables would be nice.</li>
<li><tt>make clean</tt> or its equivalent must work reliably.</li>
<li>It should rarely be necessary to run <tt>make clean</tt>.</li>
<li>Bonus: the build should be parallelizable, to be able to take advantage of multicore machines and/or distributed builds.</li>
</ul>
<p>Back to those two categories. If you screw up an in-house build script, it&#8217;s primarily your team that&#8217;s going to suffer. I&#8217;m not aware of any bugs from SQA or Customers on projects I&#8217;ve been on that were traced back to a build script, but I can see where it could happen. Mainly what I&#8217;ve seen is developers habitually wasting time rebuilding source that should not need to be rebuilt. The worst offender in this respect was a build script that forced a &#8220;make clean&#8221; at the beginning of every build. In the immortal words of Dave Barry, I&#8217;m not making this up. Really.</p>
<p>(Actually, I think it was even worse when I was dealing with a build script that required a &#8220;make clean&#8221; every time around but didn&#8217;t have it coded into the script!)</p>
<p>I can&#8217;t say I have a completely clean conscience in this area: I wrote a big pile of Makefiles for a past employer in which I unknowingly used features (bugs?) of a specific version of GNU Make that were &#8220;fixed&#8221; in a subsequent version. As time went on it became (a) a much bigger task to fix the Makefile code that used the &#8220;feature&#8221; and (b) harder to keep the specific version of GNU Make that worked with the Makefiles! I imagine they&#8217;re still stuck with this situation&#8230; sorry guys.</p>
<p>In the second category, when you toss a slapped-together build script to your unsuspecting users you do all of human society a disservice. Now they are not only wasting their time fighting with a bad build script, but they often have the disadvantage of being unable to contact the author directly for support or commiserate with other experienced users of the system.</p>
<p>So do us all a favor: if you don&#8217;t know what you&#8217;re doing when you start to write your next build script, please ask for help. Otherwise we&#8217;ll have to resort to some sort of professional licensing scheme for build script authors.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/makefiles-are-software-too/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Productivity: It Comes from Software Design Rather than Software Tools</title>
		<link>http://blog.bstpierre.org/productivity-it-comes-from-software-design-rather-than-software-tools</link>
		<comments>http://blog.bstpierre.org/productivity-it-comes-from-software-design-rather-than-software-tools#comments</comments>
		<pubDate>Wed, 31 Dec 2008 16:51:00 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[engineering]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=14</guid>
		<description><![CDATA[I just read Scott Bellware&#8217;s Productivity: It Comes from Software Design Rather than Software Tools. These bullet points — the core of his argument — are excellent (quoted here): Design quality is the most important factor influencing productivity in software development The things that obstruct quality degrade productivity The reductions in productivity over time that [...]]]></description>
			<content:encoded><![CDATA[<p>I just read Scott Bellware&#8217;s <a href="http://blog.scottbellware.com/2008/12/productivity-it-comes-from-software.html">Productivity: It Comes from Software Design Rather than Software Tools</a>.</p>
<p>These bullet points — the core of his argument — are excellent (quoted here):</p>
<blockquote>
<ul>
<li>Design quality is the most important factor influencing productivity in software development</li>
<li>The things that obstruct quality degrade productivity</li>
<li>The reductions in productivity over time that are typical to tool-driven software development are greater than what can be solved by tools</li>
<li>The application of tools to these problems exacerbates the quality problem, creating a vicious cycle that accelerates exponentially</li>
<li>Quality software design is the product of principles and practices, not tools</li>
<li>The typical degradation in a software&#8217;s quality over time isn&#8217;t due to the nature of software, it&#8217;s due to the nature of the approaches we choose to develop and operate software</li>
</ul>
</blockquote>
<p>Full disclosure here: I am working on a set of software tools, and a big part of my consulting for software teams is helping them install tools to support their improvement initiatives.</p>
<p>I agree with Scott that good design is the root of all that&#8217;s virtuous in software. I guess I also agree that tools are often a distraction, though I think he&#8217;s drawing a direct line where the root causes go deeper.</p>
<p>Maybe it&#8217;s my embedded background, and the fact that I&#8217;ve worked on teams that were woefully under-equipped in terms of tools. (Or execs were sold a bill of goods and we got stuck with the resulting boat anchors and paperweights.) I just don&#8217;t see an over-emphasis on tools, maybe this happens in IT more.</p>
<p>What I do see are many opportunities for improvement.</p>
<ul>
<li>Designs can be better communicated. If designs can be communicated better amongst the team, they can be reviewed better, which will kill bad designs before they get coded — and the feedback will help developers improve their future designs. A tool for formatting and transmission could help here. But such a tool would only be helpful to a team that already has processes in place for creating and reviewing the design.</li>
<li>Requirements can be managed better. Practices like Scrum seem helpful, but there are still challenges. Again, a tool can help here but only when the team has an understanding of how the tool fits into an existing process.</li>
<li>Existing processes and tools are overly slanted towards managing <span style="font-style: italic;">code</span>.<br />
<a href="http://blog.bstpierre.org/five-reasons-to-slow-down">By the time any requirement or design has been reduced to code, it&#8217;s way too late to fix it.</a> Start working on improving quality earlier in the cycle, the effort will pay off in a big way.</li>
</ul>
<p>Putting software tools in the hands of unskilled developers is like letting me go after wood with power tools: it&#8217;s an expensive way to make a lot of sawdust. Better to build skills with manual processes and then introduce tools when manual chores become tedious.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/productivity-it-comes-from-software-design-rather-than-software-tools/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

