<?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>Hyperextended Metaphor &#187; programming</title>
	<atom:link href="http://innocuous.org/articles/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://innocuous.org</link>
	<description>Richard Tibbetts on Various Topics</description>
	<lastBuildDate>Sat, 12 Feb 2011 14:19:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Proactive Assumption Violation: Avoiding Bugs By Behaving Badly</title>
		<link>http://innocuous.org/articles/2010/11/14/proactive-assumption-violation-avoiding-bugs-by-behaving-badly/</link>
		<comments>http://innocuous.org/articles/2010/11/14/proactive-assumption-violation-avoiding-bugs-by-behaving-badly/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 03:38:46 +0000</pubDate>
		<dc:creator>tibbetts</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://innocuous.org/articles/2010/11/14/proactive-assumption-violation-avoiding-bugs-by-behaving-badly/</guid>
		<description><![CDATA[Bugs are a fact of life in software, and probably always will be. Some bugs are probably unavoidable, but a lot of bugs can be avoided through good architecture, defensive programming, immutability, and other techniques. One major source of bugs, especially frustrating bugs, is non-deterministic behavior. Every programmer has experienced bugs which don&#8217;t reproduce, which [...]]]></description>
			<content:encoded><![CDATA[<p>Bugs are a fact of life in software, and probably always will be. Some bugs are probably unavoidable, but a lot of bugs can be avoided through good architecture, defensive programming, immutability, and other techniques. One major source of bugs, especially frustrating bugs, is non-deterministic behavior. Every programmer has experienced bugs which don&#8217;t reproduce, which require a special environment, or special timing, or even just luck to make happen. To avoid these bugs, programmers learn to favor determinism, making sure their software behaves the same way every time.</p>
<p>But sometimes a little extra non-determinism can help to avoid bugs. When designing a library the specification may contain caveats which the implementation does not exercise. If a program only ever uses one implementation, or doesn&#8217;t exercise the full range of behaviors while testing, then the program may depend on behaviors which are an artifact of the implementation. When an alternative implementation is used, or circumstances exercise other behaviors, then the program will exhibit bugs. What I would like to suggest is that instead the implementation proactively violate any assumptions the client might have, by deliberately and non-deterministically taking advantage of all the caveats in the interface specification. This will force clients to code defensively, and help to eliminate this class of bugs.</p>
<p>For example, an interface for Set might include iteration, but say that iteration order is unspecified. Most Set implementations, like Java&#8217;s HashSet, will iterate in a stable order if the set doesn&#8217;t change. The order might even be consistent from one run of the program to the next. But if programs depend on iteration stability, substituting a different implementation, such as one based on a <a href="http://en.wikipedia.org/wiki/Splay_tree" onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');">splay tree</a>, will introduce bugs. If instead the implementation of Set iteration deliberately returned a different iteration order each time, then programs would be unable to depend upon it.</p>
<p>For a real-world example, consider the standard C function <a href="http://opengroup.org/onlinepubs/007908799/xsh/memcpy.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/opengroup.org');">memcpy</a>. According to the specification, if the source and destination buffers overlap, behavior is undefined. But what does undefined really mean? Recently, <a href="http://article.gmane.org/gmane.comp.lib.glibc.alpha/15278" onclick="javascript:pageTracker._trackPageview('/outbound/article/article.gmane.org');">Linux switched to a new memcpy implementation</a>, one which copies backwards (high bytes first, low bytes last), because it is faster on modern hardware. The result is a dramatic change in overlapping buffer behavior, leading to difficult to isolate bugs like <a href="https://bugzilla.redhat.com/show_bug.cgi?id=638477" onclick="javascript:pageTracker._trackPageview('/outbound/article/bugzilla.redhat.com');">Red Hat Bug 639477: Strange sound on mp3 flash website</a>. The bug was eventually <a href="https://bugzilla.redhat.com/show_bug.cgi?id=638477#c31" onclick="javascript:pageTracker._trackPageview('/outbound/article/bugzilla.redhat.com');">tracked down to memcpy using valgrind</a>. But if the original memcpy had been more deliberately harmful in the case of overlapping buffers, than bugs like this would not be created in the first place.</p>
<p>Another place where this comes up is thread safety. Many APIs are not thread safe, but the results of using them in a thread-unsafe way are benign, or unlikely. Take the Java DOM API for XML documents. This is not a thread safe API, which is not surprising for a complex mutable data structure. What is a bit surprising is that even just reading the Java DOM from multiple threads can have unintended consequences. This is because of a cache for reuse of Node objects, and the failure mode is that very occasionally accessor functions return null when they are called from multiple threads simultaneously. Debugging a program that was suffering from this behavior took several hours, because the undesirable behavior is very infrequent. Is there a way we can apply the principle of proactive assumption violation to make this sort of bug less common?</p>
<p>System that cope with infrastructure faults by degrading their behavior are another case where proactive assumption violation can reduce bugs later. NoSQL databases are well known for taking approaches like eventual consistency in order to offer better performance and availability. But that means that when the system is under heavy load or suffering from partial outages, consistency may take a long time to resolve. I ran into this as a user of Netflix the other night. My television and my laptop had two different ideas of what my current Netflix queue contained; my television couldn&#8217;t see the recent updates. It turns out there is even a <a href="http://www.slideshare.net/adrianco/no-sq-lfornetflix" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.slideshare.net');">slide deck from Netflix</a> describing the architecture choices that led to my undesirable user experience. Most of the time things are consistent enough that I wouldn&#8217;t see this asynchrony. But when I do see it, as a user there is no obvious way to get around it or even to know that it is happening. Would a NoSQL infrastructure that let consistency drift more often end up with better average user experience?</p>
<p>Clients of interfaces often make assumptions about how those interfaces work, assumptions that are explicitly or implicitly not part of the spec. But if implementations of the interface don&#8217;t violate those assumptions, then programs can be developed which require them to be true. This leads to unexpected and expensive bugs if and when those assumptions are violated. One solutions is for implementations to deliberately violate these assumptions, for no other reason than to force clients of their interface to future-proof. The result is more work up front for programmers, but fewer bugs in the long run.</p>
<p>What do you think about proactive assumption violation? Is it a technique you have ever used? Have you experienced bugs which would be avoided if others had employed proactive assumption violation?</p>
]]></content:encoded>
			<wfw:commentRss>http://innocuous.org/articles/2010/11/14/proactive-assumption-violation-avoiding-bugs-by-behaving-badly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Algorithms for the 21st Century</title>
		<link>http://innocuous.org/articles/2006/09/28/algorithms-for-the-21st-century/</link>
		<comments>http://innocuous.org/articles/2006/09/28/algorithms-for-the-21st-century/#comments</comments>
		<pubDate>Fri, 29 Sep 2006 02:51:17 +0000</pubDate>
		<dc:creator>tibbetts</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://new.innocuous.org/articles/2006/09/28/algorithms-for-the-21st-century/</guid>
		<description><![CDATA[Went to a talk at MIT tonight, by Stephen C Johnson, a researcher at The Mathworks. The talk was sponsored by the Greater Boston ACM. The paper, Algorithms for the 21st Century, was presented at Usenix 2006. The general thrust was how computer architecture has drifted from the idealized model used in most algorithms classes, [...]]]></description>
			<content:encoded><![CDATA[<p>Went to a talk at MIT tonight, by <a href="http://yaccman.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/yaccman.com');">Stephen C Johnson</a>, a researcher at <a href="http://www.mathworks.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.mathworks.com');">The Mathworks</a>. The talk was sponsored by the <a href="http://www.gbcacm.org/website/semInfo.php?id=1115" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.gbcacm.org');">Greater Boston ACM</a>. The paper, <a href="http://yaccman.com/papers/a21/Alg21.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/yaccman.com');">Algorithms for the 21st Century</a>, was presented at Usenix 2006. The general thrust was how computer architecture has drifted from the idealized model used in most algorithms classes, in significant ways. The major focus was on the memory subsystem, and how caching can effect algorithmic performance. By looking at the behavior of very simple algorithms, we can see fairly complex variations in performance, by factors as high as 60 times worse. This in turn implies that the performance of complex algorithms will be even more diffi<br />
cult to characterize.<br />
One big take-away is that the built-in cache management schemes of modern memory systems are pessimal for certain algorithms. This actually sounds quite a bit like the complaints against operating system disk buffer/virtual memory management by database authors. Database algorithms, because they often have large storage access requirements that can be characterized in advance, benefit from managing their own buffers. Similarly, it seems like scientific computing (eg, Matlab), which wants to manipulate gigabytes of memory in very structured ways, would benefit from direct management of caching. Of course, cache management needs to run at processor-speed, unlike disk buffer management, so writing heavyweight algorithms is inappropriate. Unfortunately, the talk did not discuss any recommendations for extentions to enable management. I wonder if something as simple as being able to mark a page as no-cache in the TLB would be sufficient.<br />
My other take-away is that computer science researchers don&#8217;t understand computers nearly enough. The presenter, while familiar with processor design and memory architecture, wasn&#8217;t really able to explain the behavior of these simple algorithms in their entirety. I&#8217;m always bothered when I encounter this lack of understanding. On some level it seems that it should be possible to fully understand computer systems. After all, they are developed by humans, and to a first approximation their behavior is deterministic and well defined. Unfortunately, they change rapidly, and so any abstract models we develop are shortly invalidated. Fundamentally, this is what makes computer science difficult.</p>
]]></content:encoded>
			<wfw:commentRss>http://innocuous.org/articles/2006/09/28/algorithms-for-the-21st-century/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steve Vinoski on Extreme Programming at Iona</title>
		<link>http://innocuous.org/articles/2006/08/25/steve-vinoski-on-extreme-programming-at-iona/</link>
		<comments>http://innocuous.org/articles/2006/08/25/steve-vinoski-on-extreme-programming-at-iona/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 01:06:08 +0000</pubDate>
		<dc:creator>tibbetts</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Management]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[xp]]></category>

		<guid isPermaLink="false">http://new.innocuous.org/articles/2006/08/25/steve-vinoski-on-extreme-programming-at-iona/</guid>
		<description><![CDATA[Thursday at StreamBase we had a lunch talk by Steve Vinoski, Chief Engineer at Iona Software. Our CEO (Barry Morris) is former CEO of Iona, and he asked Steve to talk to use about Extreme Programming (XP). Iona switched to the extreme programming model nearly 10 years ago, and was the first large product company [...]]]></description>
			<content:encoded><![CDATA[<p>Thursday at <a href="http://streambase.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/streambase.com');">StreamBase</a> we had a lunch talk by <a href="http://blogs.iona.com/vinoski/" onclick="javascript:pageTracker._trackPageview('/outbound/article/blogs.iona.com');">Steve Vinoski</a>, Chief Engineer at <a href="http://iona.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/iona.com');">Iona Software</a>. Our CEO (Barry Morris) is former CEO of Iona, and he asked Steve to talk to use about <a href="http://www.extremeprogramming.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.extremeprogramming.org');">Extreme Programming (XP)</a>. Iona switched to the extreme programming model nearly 10 years ago, and was the first large product company to change over. Their experiences were documented in <a href="http://www.iona.com/devcenter/appserv/XP_Orbix.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.iona.com');">a paper by Jim Watson.</a><br />
At StreamBase we use several agile development techniques, but are not faithful to any one methodology. I expected the talk to be about how being faithful to XP was a great thing for Iona. From my reading, I understood that XP demanded total fidelity in order to succeed. Every one of their twelve points is supposed to be critically interdependent and synergistic.<br />
What I learned from Vinoski was that drinking the koolaid is not required. Iona worked directly with Kent Beck, originator of XP. Apparently in person he is a lot more laid back than in his writing. For example, Iona didn&#8217;t find pair programming particularly worthwhile, and ended up giving their engineers back their private spaces. They never implemented a 40 hour work week. They do test first programming, but not religiously. They try to fit development into 2 week iterations, but again are not strictly attatched to it. For example, documentation work generally lags behind development, and frequently their iterations don&#8217;t actually result in customer-visible functionality.<br />
The other thing I found interesting was that Iona was another example of a pattern I see in extreme programming success stories. At Iona, engineering was a mess before they switched to XP. They didn&#8217;t have nightly builds, good testing, or a consistent view of the source tree. Releases were made in an ad-hoc manner, and there was little or no visibilty or feedback in the engineering process. With the introduction of XP they were able to get many of these issues under control. Like many XP stories, things started out really bad. With the introduction of XP they got much better. I can see two plausible explanations for the frequency of this story. It may be that only companies in a lot of pain are able to marshall the resources to change to XP, and so only troubled companies try it. But it may also be that XP is only worth attempting if your organization is on the rocks. Otherwise, moving to a more moderated agile process may be the way to go.<br />
At StreamBase we use many agile techniques. We benefit greatly from automated testing, and have good test coverage. We use a branch driven development model, and keep trunk in a shippable state. We break projects into small milestones (a few weeks, and we keep making them smaller) so that development can be visible. We keep developers as close to customers as possible. And we remain introspective, looking for other opportunities to improve on our process. Many innovations in software engineering come under the banner of agile development today. I think any engineering organization can benefit from learning more about extreme programming and other agile methologies. But I think taking a moderate approach is prudent, unless your organization is in a great deal of pain.</p>
]]></content:encoded>
			<wfw:commentRss>http://innocuous.org/articles/2006/08/25/steve-vinoski-on-extreme-programming-at-iona/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

