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

<channel>
	<title>Code Simplicity</title>
	<atom:link href="http://www.codesimplicity.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codesimplicity.com</link>
	<description></description>
	<pubDate>Thu, 04 Dec 2008 09:16:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>(I)SAR Clarified</title>
		<link>http://www.codesimplicity.com/archives/75</link>
		<comments>http://www.codesimplicity.com/archives/75#comments</comments>
		<pubDate>Mon, 01 Dec 2008 20:00:43 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=75</guid>
		<description><![CDATA[In my previous post, I said that there are three major parts to any computer program: Structure, Action, and Results. Also, a program has Input, which could be considered a fourth part of the program, although usually it&#8217;s not the programmer who&#8217;s creating the input, but the user. So we can either abbreviate this as [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="/archives/49">previous post</a>, I said that there are three major parts to any computer program: <em>Structure</em>, <em>Action</em>, and <em>Results</em>. Also, a program has <em>Input</em>, which could be considered a fourth part of the program, although usually it&#8217;s not the <em>programmer</em> who&#8217;s creating the input, but the user. So we can either abbreviate this as <abbr title="Structure, Action, Results">SAR</abbr> or <abbr title="Input, Structure, Action, Results">ISAR</abbr>, depending on whether or not we want to include &#8220;Input.&#8221;</p>
<p>Now, some people misunderstood me and said, &#8220;Oh, SAR is just another name for <a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a>.&#8221; No, I used MVC as an example of SAR, but SAR is a much, much broader concept than MVC&#8211;they are not comparable theories. MVC is a pattern for designing software, whereas SAR (or ISAR) is a statement of the three (or four) components that are present in <em>all software</em>.</p>
<p>The fascinating thing about SAR is that it applies not only to a whole program, but also to any <em>piece</em> of that program. A whole program has a Structure, just as a function or single line of code has a Structure. Same for Action and Results.</p>
<p>Here&#8217;s a little more about each of the pieces, and some examples to help explain:</p>
<h3>Structure</h3>
<p>Here are some examples of things that would be considered &#8220;Structure&#8221; for the whole program:<span id="more-75"></span></p>
<ul>
<li>The directory layout of your code.</li>
<li>All of the classes and how they relate to each other.</li>
<li>The structure (schema) of the database, if your program uses a database.
<p>    Note here that the actual data <em>in</em> the database isn&#8217;t part of the Structure, though. If your program is <em>producing</em> the data and then sticking it into the database, then that&#8217;s part of the <em>Result</em>. If the data is sitting in the database and your program is supposed to process it, then that data is part of the <em>Input</em>.
  </li>
</ul>
<p>Then an individual class (and I mean a &#8220;class&#8221; in the object-oriented sense) would also have a Structure:</p>
<ul>
<li>The names of methods in the class and the types/names of parameters that they take.</li>
<li>The names and types of variables (member variables) in the class.</li>
</ul>
<p>Whether or not a function (or variable) is private or public would also be part of the Structure, because Structure describes what something <em>is</em> (as opposed to what it <em>does</em> or <em>produces</em>), and &#8220;private&#8221; or &#8220;public&#8221; are words that describe what something <em>is</em>.</p>
<p>A Structure is sort of &#8220;the components of the program&#8221; or &#8220;the pieces you make the program out of.&#8221; Function names and types, variable names and types, classes&#8211;these things are all <em>Structure</em>.</p>
<p>Structure just &#8220;sits there.&#8221; It doesn&#8217;t <em>do</em> anything unless there&#8217;s some part of your program that <em>uses</em> it. For example, a method doesn&#8217;t call <em>itself</em>, it just sits there waiting to be called. A variable doesn&#8217;t put data into itself, it just sits there waiting for you to do something with it.</p>
<h3>Action</h3>
<p>The <em>Action</em> of a whole program is very easy to understand. A tax program &#8220;does taxes.&#8221; A calculator program &#8220;does math.&#8221;</p>
<p>An Action is always a <em>verb</em> of some sort. &#8220;Calculates.&#8221; &#8220;Fixes.&#8221; &#8220;Adds.&#8221; &#8220;Removes.&#8221; Those are <em>actions</em>. Usually they&#8217;re a little more descriptive and specific, though, like, &#8220;Calculates how much rainfall there will be in Africa next year,&#8221; or &#8220;Fixes broken hard drives.&#8221;</p>
<p>Inside of a class, the <em>Action</em> is the code <em>inside</em> of the methods. That&#8217;s all some sort of <em>action</em>&#8211;something going on, something happening. In many programming languages, you can also have code outside of any class or function&#8211;code that just <em>runs</em> when you start the program. That&#8217;s <em>Action</em>.</p>
<h3>Results</h3>
<p>Every program, every function, and every line of code has some <em>effect</em>. It produces some <em>result</em>. </p>
<p>A Result can always be talked about in the <em>past tense</em>&#8211;it&#8217;s something that <em>has been</em> done or created. &#8220;Calculated rainfall,&#8221; or &#8220;Fixed hard drives.&#8221;  In a tax program, we&#8217;d call the Result either <em>filed taxes</em> or <em>filled-out tax forms</em>. As you can see, it sounds a lot like the Action, just <em>completed</em>.</p>
<p>You don&#8217;t <em>have</em> to describe a Result in the past tense, though. I&#8217;m just saying it always <em>can be</em> described that way. For example, in a calculator program, normally we&#8217;d call the Result of addition &#8220;the sum,&#8221; (not past-tense, just a noun) but you could also say that the Result is &#8220;added numbers&#8221; (which is past-tense). Same thing, just a different way of describing it.</p>
<p>Individual pieces of your program have Results, too. When you call a method or function, it has a very specific Result. It gives you back some data, or it causes some data to be changed.</p>
<p>Whatever your program (or any part of your program) <em>produces</em>, that&#8217;s the Result.</p>
<h3>ISAR in a Single Line of Code</h3>
<p>So, I said that SAR applies to a single line of code, but I didn&#8217;t give you any examples. So here&#8217;s a single line of code:</p>
<blockquote><p>
  <code>x = y + z</code>
</p></blockquote>
<p><code>y</code> and <code>z</code> in that line are part of the Structure. They&#8217;re variables that hold some data. To make an analogy: A jug is a structure that holds water. A variable is a structure that holds data. </p>
<p>The numbers that are stored inside <code>y</code> and <code>z</code> are the <em>Input</em>. That&#8217;s the data that we&#8217;re doing something with.</p>
<p><code>+</code> is an Action: &#8220;Add these two numbers.&#8221; <code>=</code> is also an Action: &#8220;Store the result in <code>x</code>.&#8221;</p>
<p>And, of course, the Result is the sum of <code>y</code> and <code>z</code> that gets stored in <code>x</code>. If <code>y</code> is 1 and <code>z</code> is 2, then the Result is the number 3, which gets stored in <code>x</code>. (Also note that <code>x</code> is a itself variable and thus also part of the Structure, but that&#8217;s getting pretty technical.)</p>
<h3>Wrapping It Up</h3>
<p>So anyhow, I hope that explains SAR a bit better. It&#8217;s a concept that applies to any kind of programming, whether you&#8217;re building a big application or just writing a single-line script. And it&#8217;s not something that you have to think about in-depth every time you write a piece of code, but it&#8217;s something that can help us analyze and understand a program, particularly when we&#8217;re looking at how we can improve its design.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/75#comments">Comments: 4</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/75/feed</wfw:commentRss>
		</item>
		<item>
		<title>Structure, Action, and Results</title>
		<link>http://www.codesimplicity.com/archives/49</link>
		<comments>http://www.codesimplicity.com/archives/49#comments</comments>
		<pubDate>Sat, 01 Nov 2008 22:38:30 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=49</guid>
		<description><![CDATA[There&#8217;s a very popular model for designing software that we&#8217;ve all heard of if we&#8217;re web developers, and probably most desktop developers have heard of too: our old friend MVC. This works well because it reflects the basic nature of a computer program: a series of actions taken on a structure of data to produce [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a very popular model for designing software that we&#8217;ve all heard of if we&#8217;re web developers, and probably most desktop developers have heard of too: our old friend <abbr title="Model, View, Controller">MVC</abbr>. This works well because it reflects the basic nature of a computer program: a series of <strong>actions</strong> taken on a <strong>structure</strong> of data to produce a <strong>result</strong>. Programs also take input, and so you could possibly argue that input was a fourth part of a program, but usually I just think of a computer program as the first three parts: Structure, Action, and Results.</p>
<p>In the MVC sense, the Model is the Structure, the Controller is what does the Actions, and the View is the Result. I think the analogy (and the words) Structure, Action, and Results are more widely and accurately applicable to the operation of every program in existence, though, moreso than MVC, though MVC is a perfectly good way of looking at it for GUI applications.</p>
<p>Really, Structure, Action, and Results probably describes almost any machine in existence. A machine has some parts that don&#8217;t move, a framework&#8211;that&#8217;s the structure. Some parts move and do something&#8211;that motion is the action. And of course the machine produces something (otherwise we wouldn&#8217;t care much about it) so that&#8217;s the result.</p>
<p>Computer programs are unusual machines in that they can modify their own structure. However, it&#8217;s important that some part of the program be stable, that they &#8220;not move&#8221; in a logical sense. The way that object classes relate to each other, the names of methods and variables&#8211;these are all parts of the structure that usually don&#8217;t change while you&#8217;re running. (Sometimes you make new classes, methods, or variables while you&#8217;re running, but they usually follow some pre-set plan, so there&#8217;s still a lot of &#8220;not moving&#8221; involved.)</p>
<p>When I&#8217;m writing software, I usually build the Structure first, then I work on the Actions, and then I work on the displaying of the Result. Some people work backwards from the Results, that&#8217;s fine too. Probably the only inadvisable thing to do is to start with the Actions, since it&#8217;s kind of confusing to be performing Actions without a Structure and with no defined Result.</p>
<p>There&#8217;s so much to this concept that I could probably write a whole book just on this one topic, but I think this is a decent introduction, and I&#8217;m sure that given this, you can think of lots of other useful applications of it.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/49#comments">Comments: 0</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/49/feed</wfw:commentRss>
		</item>
		<item>
		<title>Simplicity and Security</title>
		<link>http://www.codesimplicity.com/archives/48</link>
		<comments>http://www.codesimplicity.com/archives/48#comments</comments>
		<pubDate>Fri, 17 Oct 2008 20:00:52 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=48</guid>
		<description><![CDATA[A big part of writing secure software (probably the biggest part) is simplicity.
When we think about software security, the first question that we ask is, &#8220;How many different ways could this program possibly be attacked?&#8221; That is, how many &#8220;ways in&#8221; are there? It&#8217;s a bit like asking &#8220;How many doors and windows are there [...]]]></description>
			<content:encoded><![CDATA[<p>A big part of writing secure software (probably the biggest part) is simplicity.</p>
<p>When we think about software security, the first question that we ask is, &#8220;How many different ways could this program possibly be attacked?&#8221; That is, how many &#8220;ways in&#8221; are there? It&#8217;s a bit like asking &#8220;How many doors and windows are there on this building?&#8221; If your building has 1 exterior door, it&#8217;s very easy to protect that door. If it has 1000, it will be impossible to keep the building secure, no matter how good the doors are or how many security guards you have.</p>
<p>So we need to limit the &#8220;ways in&#8221; to our software to some reasonable number, or it won&#8217;t ever be secure. That&#8217;s accomplished by making the <em>overall system</em> relatively simple, or breaking it down into very simple and totally separate component parts. </p>
<p>Then, once we&#8217;ve limited the ways in, we need to start thinking about &#8220;How many different possible attacks are there against each way in?&#8221; We limit that by making the ways in <em>themselves</em> very simple. Like a door with only one unique key, instead of a door that can take five different keys, all of which individually will open the door.</p>
<p>Once that&#8217;s done, we limit how much damage any attack could do if it got through. For example, in a building, we&#8217;d make any given door only allow access to one room.</p>
<p>All of this explains, for example, why Windows is fundamentally flawed and will <em>never</em> be secure, and why UNIX-based systems have a better reputation for security. <span id="more-48"></span></p>
<p>Standard UNIX has a very small number of system calls that are used to implement the vast majority of all UNIX programs out there. (Even the extended list is only about 140 system calls, though most of those are never used by the average program.) Each system call is extremely specific and does one very limited thing.</p>
<p>Windows, on the other hand, has a <a href="http://www.metasploit.com/users/opcode/syscalls.html">ridiculous set of system calls</a> that are confusing, take too many arguments, and do too much.</p>
<p>Going up to a higher level in the system, the <a href="http://msdn.microsoft.com/en-us/library/aa383686(VS.85).aspx">Windows API</a> is massive and complex. It&#8217;s a strange beast that controls both the OS and the GUI. There&#8217;s really no equivalent thing in UNIX (because the OS and the GUI are separate), but we can at least compare parts of it. Here&#8217;s <a href="http://msdn.microsoft.com/en-us/library/bb540361(VS.85).aspx">The Windows Logging API</a>. Here&#8217;s <a href="http://www.gnu.org/software/libc/manual/html_node/Submitting-Syslog-Messages.html#Submitting-Syslog-Messages">the Linux Logging API</a>. There&#8217;s just no comparison. It&#8217;s like a joke. There&#8217;s so many &#8220;ways in&#8221; to any part of Windows that it will <em>never</em> be fundamentally secure.</p>
<p>You might say, &#8220;Well, I haven&#8217;t had a virus on my Windows machine in a long time.&#8221; That&#8217;s not what I&#8217;m talking about&#8211;I&#8217;m talking about <em>fundamental</em> security. In order to have a secure Windows machine, you have to have a firewall that asks you every time a program wants to make an outbound connection. You have to have a spyware scanner. You have to have <a href="http://www.thepcspy.com/read/what_really_slows_windows_down/5">antivirus software that slows down your computer by as much as 2000%</a>. If Windows was <em>secure</em>, you wouldn&#8217;t need those things.</p>
<p>When we design our own systems, keeping them simple is the only real guarantee of security. We keep each &#8220;way in&#8221; to the system as simple as possible, and we never add more &#8220;ways in&#8221; than we absolutely need. These are compatible things, too, because the simpler each &#8220;way in&#8221; is, the <em>fewer</em> we&#8217;ll actually need. That may not make sense until you think about it this way: If all actions on the system can be reduced to, say, 13 fundamental function calls, then the user can do <em>everything</em> with those 13 calls, even if they&#8217;re not very powerful individually. If instead we only let them do 100 different specific tasks, and <em>don&#8217;t</em> allow them to use the 13 fundamental calls, we have to add a new function for <em>every specific task</em>.</p>
<p>There are lots of other &#8220;ways in&#8221; to a program than just its public API, too. How the user interface interacts with the backend&#8211;that involves various &#8220;ways in&#8221;. Can we access this program&#8217;s internal structure from another program? That would be another &#8220;way in.&#8221; There&#8217;s <em>lots</em> of ways to apply this principle. </p>
<p>Any way you slice it, though, the best way to get real security in things is <em>simplicity</em>. We shouldn&#8217;t have to put a small army in front of our software just to keep it secure. It should just fundamentally have so few &#8220;ways in&#8221; that it doesn&#8217;t need the protection, and those &#8220;ways in&#8221; should be so streamlined and simple that they&#8217;re impossible to exploit.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/48#comments">Comments: 14</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/48/feed</wfw:commentRss>
		</item>
		<item>
		<title>What Is A Computer?</title>
		<link>http://www.codesimplicity.com/archives/47</link>
		<comments>http://www.codesimplicity.com/archives/47#comments</comments>
		<pubDate>Fri, 10 Oct 2008 18:00:49 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=47</guid>
		<description><![CDATA[What is a computer? You&#8217;d think that would be a fairly simple question. After all, I&#8217;m using one to type this up, I ought to know what it is, right? I mean obviously, it&#8217;s a&#8230;computer! I mean, it&#8217;s got a keyboard, and a monitor, and there&#8217;s that box down there&#8230;
But what is it that makes [...]]]></description>
			<content:encoded><![CDATA[<p>What is a computer? You&#8217;d think that would be a fairly simple question. After all, I&#8217;m using one to type this up, I ought to know what it is, right? I mean obviously, it&#8217;s a&#8230;computer! I mean, it&#8217;s got a keyboard, and a monitor, and there&#8217;s that box down there&#8230;</p>
<p>But what is it that makes all that stuff a <em>computer</em>? Why do we look at it and go, &#8220;Oh yeah, that&#8217;s a computer,&#8221; as opposed to, say, &#8220;Oh, that&#8217;s just a TV,&#8221; or &#8220;That&#8217;s where I keep the leprechauns at night.&#8221;?</p>
<p>Some people try to define the word &#8220;computer&#8221; just by saying &#8220;it&#8217;s got such and such parts and they all work this way,&#8221; but that&#8217;s like saying &#8220;airplanes have two wings and jet engines.&#8221; It&#8217;s true, but I could build an airplane that <em>didn&#8217;t</em> have two wings or jet engines. The way something <em>works</em> is not a <em>definition</em> for that thing.</p>
<p>Others try to define it mathematically, but that can also be somewhat limiting, because then only the devices that fit into your mathematical scheme are computers, and there are multiple mathematical models that would all be considered &#8220;computers.&#8221;</p>
<p>So I turned to the dictionary. That was fun for me&#8211;I&#8217;m a dictionary fanatic. I&#8217;ve got lots of great dictionaries, and there are even more online. The Compact Oxford English Dictionary had <a href="http://www.askoxford.com/concise_oed/computer?view=uk">the best definition</a>, as it turned out.. I was very happy with it at first, but when I started to think about it, it didn&#8217;t quite work. For example, it calls computers &#8220;an electronic device,&#8221; and we know that <a href="http://www.maxmon.com/1830ad.htm">computers can be built without electronics</a>.</p>
<p>So I worked to come up with a definition of my own. Strangely enough, the key question that it boiled down to was &#8220;Why is a player piano <em>not</em> a computer?&#8221; It &#8220;processes information&#8221; by playing notes from its roll. If you gave it an etching machine, it could &#8220;store information&#8221; back on to the roll. But despite all that, it&#8217;s clearly not a computer. What is a computer doing that is fundamentally different from a player piano, that a player piano could <em>never</em> do? <span id="more-47"></span></p>
<p>After about two years, I finally came up with an answer that was both simple and all-encompassing. A computer is:</p>
<blockquote><p>
Any piece of matter which can carry out symbolic instructions and compare data in assistance of a human goal.
</p></blockquote>
<p>And that, my friends, is really it. My only thought left is whether I should say &#8220;<em>a series</em> of symbolic instructions&#8221; to more clearly differentiate it from a calculator. What do you think?</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/47#comments">Comments: 25</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/47/feed</wfw:commentRss>
		</item>
		<item>
		<title>Top 10 Reasons To Work On Open Source (In a California Accent)</title>
		<link>http://www.codesimplicity.com/archives/46</link>
		<comments>http://www.codesimplicity.com/archives/46#comments</comments>
		<pubDate>Fri, 12 Sep 2008 18:00:39 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Essays]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=46</guid>
		<description><![CDATA[So, as a little digression from our normal content, I felt like writing a list of the top 10 reasons to work on open-source software&#8230;but being a born Californian, I felt I had to pay a little respect to my roots. So here we have the top 10 reasons to work on open-source&#8230;as said by, [...]]]></description>
			<content:encoded><![CDATA[<p>So, as a little digression from our normal content, I felt like writing a list of the top 10 reasons to work on open-source software&#8230;but being a born Californian, I felt I had to pay a little respect to my roots. So here we have the top 10 reasons to work on open-source&#8230;as said by, like, a dude from Cali (with translations underneath <img src='http://www.codesimplicity.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ).<span id="more-46"></span></p>
<ol>
<li value="10"><strong>Dudes at Silicon Valley parties will think you&#8217;re, like, cool.</strong>
<p>Impress people you don&#8217;t know! You can say, &#8220;I work on an <em>open source</em> project,&#8221; and nod your head like you&#8217;re cool. But no, more seriously, about 50% of all the people I meet at Silicon Valley parties are totally amazed that I&#8217;m one of the primary developers of Bugzilla, something that they use every day.</p>
<p>This doesn&#8217;t work so well with the <em>ladies</em>, though, usually. &#8220;Yeah, I&#8217;m an <em>extremely intense</em> programmer, oh yeah.&#8221;</p>
<p>No, but more seriously: How many girls did <em>you</em> see at OSCON? If anybody has a scheme to get more girls involved or interested in open source, the whole open-source <em>world</em> (the current girls included, I&#8217;m sure) would be thrilled.</p>
</li>
<li value="9"><strong>It totally has nothing to do with whether or not you&#8217;re a &#8220;hottie.&#8221; Just be yourself, man, just be yourself.</strong>
<p>Open Source is definitely one place where you&#8217;ll be respected for your intelligence and ability, not how expensive your clothes are or how much you paid for your haircut. Nobody cares what you look like. We only care how good your ideas are.</p>
</li>
<li value="8"><strong>It&#8217;s hella <em>sick</em> when you&#8217;re interviewing!</strong>
<p>When you&#8217;re interviewing and you worked on some open-source project, it&#8217;s completely valid job experience. Sometimes it even makes you <em>more</em> valuable than normal job experience, if the project is well-known. Also, if you worked on open-source in your spare time, that shows the kind of passion for software engineering that employers are really looking for.</p>
</li>
<li value="7"><strong>You can, like, totally freelance. Seriously? Ya, like totally seriously.</strong>
<p>There&#8217;s a lot of need for contractors for certain open-source projects. If you become a prominent contributor to a project and get your name on its Consultants List, then you can make a living doing consulting for people who use the software!</p>
</li>
<li value="6"><strong>Dude, we&#8217;ll like, laugh at your jokes and stuff, dude.</strong>
<p>I have laughed harder while listening to some conversations on IRC than I have at almost anything else in the world. There&#8217;s something about shared experience and understanding that makes things much funnier than jokes that &#8220;everybody&#8221; is supposed to get. And where else can you make jokes about programming languages and have <em>multiple people</em> actually <em>get</em> them?</p>
</li>
<li value="5"><strong>You can say how, like, stuff <em>goes</em> and people will actually <em>listen</em> to you. Whoa.</strong>
<p>When you write a feature, to a large degree you&#8217;re the one who&#8217;s going to decide how it works! Don&#8217;t like how a particular program works? Well, maybe you could have been the one who wrote that feature instead! Don&#8217;t like some documentation? What if you had written it instead?</p>
<p>And if you don&#8217;t like how something works now, the more you contribute to an open-source project, the more say you&#8217;ll have in fixing that thing. Have an itch to just make things work <em>right</em>? Open Source is the place to be.</p>
</li>
<li value="4"><strong>You learn, like, so much stuff, like seriously.</strong>
<p>Are you looking for something new, some way to expand your horizons and learn something new instead of just mechanically doing the same thing over and over at work? No matter what your interest is, there&#8217;s going to be some open-source project out there that uses the things you want to learn about. And it won&#8217;t just be some tiny project just for yourself, but something that people really use!</p>
</li>
<li value="3"><strong>You can like, <em>belong</em> to something, and stuff. That&#8217;s some cosmic stuff, man.</strong>
<p>When you contribute to an open-source project, you&#8217;re not just a cog in a great machine, or just a worker at a job. You become part of a larger community, with its own in-jokes, culture, and people.</p>
<p>I used to think that was just some marketing gibberish, but it&#8217;s really true. It may not be the best way to find people who you can &#8220;hang out&#8221; with every day, but you&#8217;ll get to know a lot of new people and become part of a group in a very definite way.</p>
<p>It&#8217;s even more true if you go to conventions like OSCON or the more specific ones for the various open-source projects, where you can meet and hang out with lots of other developers &#8220;In Real Life&#8221;, most of whom are really great (and intelligent) people.</p>
</li>
<li value="2"><strong>You get to feel like a revolutionary (a revolutionary <em>nerd</em>, but&#8230;hey, s&#8217;all good, s&#8217;all good).</strong>
<p>Yeah! Down with The Man! We don&#8217;t need any stinkin&#8217; proprietary software!</p>
<p>You can even get to <em>protest</em> things, like software patents! You&#8217;ll be almost as cool as your <em>parents</em> were in the 60&#8217;s. Kind of.</p>
<p>No, but seriously: Open Source is still a relatively new thing in the world, and you can be a part of blazing its trail. It&#8217;s not the &#8220;normal&#8221; way to do things quite just yet, so if you like being a little different than the swarming masses, open source is the place to be.</p>
</li>
<li value="1"><strong>It seriously helps out, man.</strong>
<p>Working on open-source software helps out a lot of people:</p>
<ul>
<li>The people who use the software. Millions of people use open-source software around the world every day to do their job, handle their problems, or just have fun! You could be affecting the lives of all those people.</li>
<li>The people who write the software. Open-source projects almost all <em>really</em> want your assistance! If a project is at <em>all</em> popular, they probably have more feature requests than they can handle. Don&#8217;t come to an open-source project and say, &#8220;This is what I&#8217;m going to do for you,&#8221; but do come and say, &#8220;How can I help you guys out?&#8221; We all need some help, and competent help is much appreciated.</li>
<li>All the people who <em>won&#8217;t have to</em> write the software that you write. Sometimes you just want to download a program to do a task for you. You don&#8217;t want to have to write a program for <em>everything</em> you want to do. You&#8217;re saving the time of millions of users and computer programmers, by creating something that everybody can use and modify!</li>
</ul>
</li>
</ol>
<p>And that&#8217;s my list! Hope you had totally chill time, brah.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/46#comments">Comments: 23</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/46/feed</wfw:commentRss>
		</item>
		<item>
		<title>Success Comes From Execution, not Innovation</title>
		<link>http://www.codesimplicity.com/archives/45</link>
		<comments>http://www.codesimplicity.com/archives/45#comments</comments>
		<pubDate>Mon, 08 Sep 2008 18:00:05 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Essays]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=45</guid>
		<description><![CDATA[There&#8217;s a strange sort of social disease going around in technology circles today, and it all centers around this word &#8220;innovation.&#8221;
Everybody wants to &#8220;innovate.&#8221; The news talks about &#8220;who&#8217;s being the most innovative.&#8221; Marketing for companies insists that they are &#8220;innovating.&#8221;
Except actually, it&#8217;s not innovation that leads to success. It&#8217;s execution.
It doesn&#8217;t matter how good [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a strange sort of social disease going around in technology circles today, and it all centers around this word &#8220;<a href="http://www.merriam-webster.com/cgi-bin/dictionary?book=Dictionary&#038;va=innovation">innovation</a>.&#8221;</p>
<p>Everybody wants to &#8220;innovate.&#8221; The news talks about &#8220;who&#8217;s being the most innovative.&#8221; Marketing for companies insists that they are &#8220;innovating.&#8221;</p>
<p>Except actually, it&#8217;s not innovation that leads to success. It&#8217;s <em>execution</em>.</p>
<p>It doesn&#8217;t matter how good or how new my idea is. It matters how well I carry it out in the real world.</p>
<p>Now, our history books worship the inventors, not the executors. We are taught all about the people who invent new things, come up with new ideas, and plough new trails. But look around you in present time and in the recent past, and you&#8217;ll see that the most successful people are the ones who <em>carried out the idea really well</em>, not the people who came up with the idea.</p>
<p>Elvis didn&#8217;t invent rock and roll. Ford didn&#8217;t invent the automobile <em>or</em> the assembly line. Apple didn&#8217;t invent the GUI. Webster didn&#8217;t invent dictionaries. Maytag didn&#8217;t invent the washing machine. Google didn&#8217;t invent web searching. I could go on and on and <strong>on</strong>.</p>
<p>Granted, sometimes the innovator also is an excellent executor (Alexander Graham Bell being an example), but usually that&#8217;s not the case. Most inventors don&#8217;t turn out to be the most successful people in their field (or even successful at all).</p>
<p>So stop worrying about &#8220;coming up with something new.&#8221; You don&#8217;t have to do that. You just have to execute an <em>already existing</em> idea really, really well. You can add your own flair to it, maybe, or fix it up a little, but you don&#8217;t have to have something brand new.</p>
<p>There are so many examples that prove this that it&#8217;s hard <em>not</em> to see one if you move your eyes <em>anywhere</em>. Just look, you&#8217;ll see.</p>
<p>Now, I&#8217;m not saying that people shouldn&#8217;t innovate. You should! It&#8217;s fun, and it advances the whole human race a tiny step every time you do. But it&#8217;s not the path to long-term success for you or for any group you belong to. That&#8217;s all in execution.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/45#comments">Comments: 22</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/45/feed</wfw:commentRss>
		</item>
		<item>
		<title>Designing for Performance, and the Future of Computing</title>
		<link>http://www.codesimplicity.com/archives/44</link>
		<comments>http://www.codesimplicity.com/archives/44#comments</comments>
		<pubDate>Thu, 04 Sep 2008 18:00:29 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Essays]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=44</guid>
		<description><![CDATA[So, you might have heard that Google released a web browser.
One of the features of this web browser is its JavaScript engine, called v8, which is designed for performance.
Designing for performance is something that Google does often. Now, designing for performance usually leads to complexity. So, being a major supporter of software simplicity, I&#8217;m opposed, [...]]]></description>
			<content:encoded><![CDATA[<p>So, you might have heard that Google released <a href="http://www.google.com/chrome">a web browser</a>.</p>
<p>One of the features of this web browser is its JavaScript engine, called <a href="http://code.google.com/p/v8/">v8</a>, which is <a href="http://code.google.com/apis/v8/design.html">designed for performance</a>.</p>
<p>Designing for performance is something that Google does often. Now, designing for performance usually leads to complexity. So, being a major supporter of software simplicity, I&#8217;m opposed, in a theoretical sense, to designing for performance. </p>
<p>However, Google is in an interesting situation. Essentially, we live in the Bronze Age of computing (or perhaps the Silicon Age, as I suspect future historians may call this period of history). Our computers are primitive, compared to what we are likely to have 50 to 100 (or 1000!) years from now. That may seem hard to believe, but it&#8217;s always hard to imagine the far future. Google is operating on a level far exceeding our current hardware technology, really, and so their design methods unfortunately can&#8217;t live in a theoretical fairy-land where hardware is always &#8220;good enough.&#8221; (However, I personally <em>like</em> to live in that land, when possible, because hardware will improve as time goes on&#8211;an important fact to understand if you&#8217;re going to have a long-lived software project).</p>
<p>What is it about our computers that makes them so primitive? Well, usually I don&#8217;t go about predicting the future in this blog, or even talking about too many specifics, because I want to keep things generally applicable (and also because the future is hard to predict, particularly the far future). But I will talk about some of my thoughts here on this, and you can agree with them or not, as you please. <span id="more-44"></span></p>
<h3>Our Current Computers</h3>
<p>First, you have to understand that to me, anything that could be running this web browser right now, that could be showing me my desktop, and that I could be typing into right now&#8211;I&#8217;d consider that a computer. It actually doesn&#8217;t matter what it&#8217;s doing underneath, or <em>how</em> it works. A good, offhand definition then of a computer would be:</p>
<blockquote><p>
  Any piece of matter which can carry out symbolic instructions and compare data in assistance of a human goal.
</p></blockquote>
<p>Currently computers do this using math, which they do with <a href="http://nobelprize.org/educational_games/physics/transistor/history/">transistors</a>, <em>digitally</em>. The word &#8220;digital&#8221; comes from &#8220;digit&#8221;, a word meaning, basically, &#8220;fingers or toes.&#8221; For most people, your fingers and toes are separate, individual items. They don&#8217;t blend into each other. &#8220;Digitally&#8221; means, basically, &#8220;done with separate, individual numbers.&#8221; You know, like 1, 2, 3, 4&#8211;not 1.1, 1.2, 1.3. People (normally) have 1 or 2 fingers, not 1.5 fingers.</p>
<p>Said another way, current computers change from one fixed state to another, very fast. They follow instructions that change their state. I don&#8217;t really care if we say that the state is &#8220;transistor one is on, transistor two is off, transistor three is on&#8230;&#8221; or &#8220;Bob has a cat, Mary has a dog, Jim has a cat&#8230;&#8221; it&#8217;s all a description of a state. What we care about ultimately is the total current state. If there are 1,000,000 possible states (and there are far, far, <strong>far</strong> more in a current computer), then we can say that &#8220;we are at state 10,456&#8243; and that&#8217;s all we really need to know.</p>
<p>The problem with current computers is <a href="http://www.intel.com/technology/mooreslaw/index.htm">Moore&#8217;s Law</a>. We don&#8217;t need computers that are twice as fast. We need computers that are about a million times faster than the ones we have. We need computers so fast that software engineers never have to worry about performance ever again, and can just design their code to be the sanest, most maintainable thing possible. With that kind of performance, we could design almost any software imaginable.</p>
<p>The problem is that with Moore&#8217;s Law, we&#8217;re not going to get computers 1000 times faster for about 20 years. We&#8217;re going to get to 1,000,000 times faster in about 40 years. And there&#8217;s a chance that the laws of physics will stop us dead in our tracks before that point, anyhow.</p>
<h3>Future Computers</h3>
<p>So, let&#8217;s stick with the idea of a machine that changes states for the near future, because I can&#8217;t think of any other clever way to make a computer that would follow my definition from above. There are three problems, then:</p>
<ol>
<li>How many states can we represent?</li>
<li>How many physical resources does it require to represent all those states (including space, power, etc.)?</li>
<li>How quickly can we change between states?</li>
</ol>
<p>And then &#8220;How many states can we represent at once?&#8221; might also be a good question&#8211;we&#8217;re seeing this come up more and more with dual-core and quad-core processors (and other technologies before that, but I don&#8217;t want to assume that everybody reading my blog is an expert in hardware architecture, and I don&#8217;t want to explain those technologies).</p>
<p>So the ideal answers are:</p>
<ol>
<li>We can represent an infinite number of states.</li>
<li>It requires no physical resources to represent them.</li>
<li>We can change between them without time.</li>
</ol>
<p>And then also &#8220;We can represent an infinite number of different states at once.&#8221;</p>
<p>Currently we theoretically <em>could</em> represent an infinite number of states, we&#8217;d just have to add more transistors to our chip. So really, the question becomes, &#8220;How many states can we represent with how many physical resources?&#8221; Currently we can fit two states into 32 <a href="http://www.nanooze.org/english/articles/article4_howbigisananometer.html">nanometers</a>. (That&#8217;s one transistor.)</p>
<p>My <em>suspicion</em> is that the future is <em>not</em> in fitting two states into a continually smaller space, but in fitting a <em>near-infinite</em> number of states into a slightly larger space. Electricity and other force waves can be &#8220;on&#8221; or &#8220;off&#8221;, but they also have lots of other properties, many of which are sufficient to represent an infinity (or near-infinity). Frequency of any wave represents an infinity, for example&#8211;you can have a 1 Hz wave, a 1.1 Hz wave, a 1.15 Hz wave, a 1.151 Hz wave, etc. So, that basically answers Question 1 ideally&#8211;you can have an infinite number of states, you just have to have some device which is sufficiently small, in which a wave can have its properties modified and measured by electronics, optics, or some other such technology.</p>
<p>You&#8217;ll notice that we&#8217;ve also conveniently answered our bonus question, because we can represent quite a few different states at once, once each individual component of our system can represent an infinity all by itself.</p>
<p>If we want to look a bit further into the future, our second question can be answered by the fact that waves take up essentially <em>no space</em> (only the medium that they vibrate takes up space). Our understanding of physics is not (as far as I know) currently good enough to create structures out of pure force just yet, but such structures would come quite close to taking up &#8220;no physical resources.&#8221;</p>
<p>And beyond that (how we get the state changes to happen without time), I have no idea. That question may be unanswerable, and may only be resolvable by changing computers to being something other than mathematical devices. (That is, not be involved with states at all, but some other method of following instructions and comparing data.) But the better our components become, the closer we can get to &#8220;no time.&#8221;</p>
<h3>The Roundup</h3>
<p>So there&#8217;s my thoughts for the day on the future of computing. Sometimes designing software for performance is a necessary evil (but really only in the case where it&#8217;s an extreme issue, like with Google&#8217;s products, or the great new need for speed in JavaScript nowadays, or in other low-level places), but I hope that future changes in the fundamental architecture of computers will obsolete that necessity.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/44#comments">Comments: 13</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/44/feed</wfw:commentRss>
		</item>
		<item>
		<title>Design From The Start</title>
		<link>http://www.codesimplicity.com/archives/43</link>
		<comments>http://www.codesimplicity.com/archives/43#comments</comments>
		<pubDate>Fri, 15 Aug 2008 18:00:38 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Essays]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=43</guid>
		<description><![CDATA[I don&#8217;t know if this has become clear to everybody yet, but you really need to design from the start. You need to be working on simplicity and the other Laws of Software Design from the very beginning of your project.
My policy on projects that I control is that we never add a feature unless [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know if this has become clear to everybody yet, but you really need to design <em>from the start</em>. You need to be working on simplicity and the other <a href="/category/laws-of-software">Laws of Software Design</a> from the very beginning of your project.</p>
<p>My policy on projects that I control is that we <em>never</em> add a feature unless the design can support it simply. This drives some people crazy, notably people who have no concept of the <a href="/archives/17">future</a>. They start to foam at the mouth and say things like, &#8220;We can&#8217;t wait! This feature is <em>so important</em>!&#8221; or &#8220;Just put it in now and we&#8217;ll just clean it up later!&#8221; They don&#8217;t realize that this is their <em>normal attitude</em>. They&#8217;re going to say the same thing about the next feature. If you give in to them, then <em>all</em> of your code will be poorly designed and much too complex. It&#8217;ll be Frankenstein&#8217;s monster, jammed together out of broken parts. And just like the friendly green giant, it&#8217;ll be big, ugly, unstable, and harmful to your health. <span id="more-43"></span></p>
<p>Adding a tiny little piece and refactoring it afterward is fine. Landing a huge feature that the architecture can&#8217;t support and then trying to clean it up afterward is a terrible task. Size matters.</p>
<p>The worst situation, however, is when you let people keep adding features with no design for months or years, and then one day you wake up and realize that <a href="http://uk.youtube.com/watch?v=iFIMxZVaSzk">something is not right</a>. Now you have to fix your <em>whole codebase</em>. This is a terrible task, because just like adding a new feature, it can&#8217;t be done all at once, unless you want to <a href="http://www.joelonsoftware.com/articles/fog0000000069.html">re-write</a>. If you want to start doing things the right way, you have to start doing things the <em>right way</em>. And that means that you have to fix the design piece by piece, in simple steps. That usually requires months or <em>years</em> of effort&#8211;totally wasted effort, because you should have just designed <em>from the start</em>. You should have <a href="/archives/17">thought about the future</a>.</p>
<p>In your project lacks a strict design, and it continues to grow, then you will eventually end up over your head in complexity. I understand that this is hard for some people to imagine. Some folks can&#8217;t imagine that there is a future beyond lunch. Other folks just haven&#8217;t had enough experience to understand how complex things can get. And I understand that there can be a corporate culture that says, &#8220;Oh, we just hack in new features, and we should do things the right way, but we can&#8217;t because <em>blah blah blah</em>.&#8221; But one day your project will fail. And no matter how many <em>reasons</em> you can give for that failure, it won&#8217;t change the fact that your project <em>failed</em>.</p>
<p>Often, when you&#8217;ve done your design right, there&#8217;s not a whole lot of credit that comes your way. Catastrophic failures in design are big and noticeable, small increments of work toward a good design are invisible to people who aren&#8217;t intimately connected with the code. So this can make it difficult&#8211;handling a big failure gets you a lot of thanks, preventing one in the first place, well, nobody noticed.</p>
<p>So I&#8217;ll congratulate you myself. Did you design from the start? That was awesome. You absolutely did the right thing. Have you started designing now? Well, you should have started earlier, but congratulations on starting to move in the right direction. Your users and fellow developers will see the benefits&#8211;working software, on-time releases, and a clear, understandable codebase. Will they know how much work it took to get it that way? Maybe not. But that&#8217;s OK. Sometimes doing things the right way is really its own reward.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/43#comments">Comments: 6</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/43/feed</wfw:commentRss>
		</item>
		<item>
		<title>Sane Software Design</title>
		<link>http://www.codesimplicity.com/archives/41</link>
		<comments>http://www.codesimplicity.com/archives/41#comments</comments>
		<pubDate>Mon, 11 Aug 2008 19:30:31 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=41</guid>
		<description><![CDATA[I have come up with an analogy that should make the basic principles of software design understandable to everybody. The great thing about this analogy is that it covers basically everything there is to know about software design. 
Imagine that you are building a structure out of lead bars. The final structure will look like [...]]]></description>
			<content:encoded><![CDATA[<p>I have come up with an analogy that should make the basic principles of software design understandable to everybody. The great thing about this analogy is that it covers basically everything there is to know about software design. <span id="more-41"></span></p>
<p>Imagine that you are building a structure out of lead bars. The final structure will look like this:</p>
<pre>
   |
_|_|_|_
   |
   |
   |</pre>
<p>You have to build the structure and put it up at a certain location, so that people can use it (for this example, we don&#8217;t care what they need it for, but assume that they need it for some specific reason).</p>
<p>The lead bars represent the individual pieces of your software. Putting it up at the location is like putting your software into production (or sending it out to your users). Everything else should be fairly clear as to how it translates to software, if you think about it. You don&#8217;t have to translate everything to software in your mind as you read, though. Everything should be quite clear if you just imagine that you really are just building a structure out of lead bars.</p>
<h3>The Wrong Way</h3>
<p>Imagine that you were building this all by yourself, and that you had to make the bars out of raw metal. Here&#8217;s the wrong way to build it:</p>
<ol>
<li>Make one tall lead bar, and lay it flat on the ground in your workshop:
<pre>
|
|
|
|
|</pre>
</li>
<li>Cut a hole through the tall bar, and measure that hole.</li>
<li>Make a new bar that will fit through that hole:
<pre>_____</pre>
</li>
<li>Put that new bar through the hole and weld them together permanently:
<pre>
  |
__|__
  |
  |
  |</pre>
</li>
<li>Cut two holes in the horizontal bar, measure them, and make two new lead bars that will fit in those individual holes:
<pre>|   |</pre>
</li>
<li>Insert the two bars into the horizontal bar, and weld them together permanently:
<pre>
   |
_|_|_|_
   |
   |
   |</pre>
</li>
<li>With a forklift, put this into a truck to move it to the location where it&#8217;s supposed to be (It&#8217;s too heavy to move by yourself.)</li>
<li>With a pulley, make the construction stand upright and put it into the ground.</li>
<li>Discover that it won&#8217;t stay up by itself, but if you put some blocks next to it as an emergency solution, it doesn&#8217;t fall over:
<pre>
   |
_|_|_|_
   |
  _|_
 | | |</pre>
</li>
<li>Three days later, watch the structure fall over and break because the blocks aren&#8217;t actually a permanent solution.</li>
<li>Unfortunately, part of the horizontal bar has snapped, and you have to fix it. This is difficult because the bars are all welded together, so you can&#8217;t easily take out the bar and replace it with another one. You either have to build a whole new structure or weld together the broken bar. Welding the broken halves together creates a weak bond, but it&#8217;s cheaper than building a whole new structure, so you just weld them.</li>
<li>Put stronger blocks next to the structure to keep it up.</li>
<li>Next week, the weather breaks the welded bars. Weld them back together again.</li>
<li>In six days, watch the structure fall over because blocks are not a permanent solution.</li>
<li>Repeat the last few steps until you run out of money or time.</li>
</ol>
<h3>Analysis of The Wrong Way</h3>
<p>So, what was <em>good</em> about the above process? Well, it did allow one person to successfully complete a structure. In software terms, that one person &#8220;made something that works.&#8221; It also created a lot of work for one person, which is good if that one person wanted a lot of work.</p>
<p>What was bad about it?</p>
<ul>
<li>The bars all had to be made in sequence, individually.</li>
<li>Problems with the final structure (that it wouldn&#8217;t stay up) were only discovered after it was entirely built and in place.</li>
<li>When problems were discovered, they were just &#8220;quick fixed&#8221; without planning for the future.</li>
<li>It took enormous effort to move the completed structure into place.</li>
<li>If we ever had to change the configuration of the bars, we couldn&#8217;t, because they&#8217;re welded together. We&#8217;d have to build a whole new structure.</li>
<li>The completed structure requires frequent attention.</li>
</ul>
<p>And I&#8217;m sure we could come up with other faults. This whole analogy (including the parts below) could be analyzed all day.</p>
<h3>Bringing It To a Group</h3>
<p>The biggest problem with the Wrong Way process is that it wouldn&#8217;t work <em>at all</em> if there were multiple people working on the project (as there usually are in real-world software projects). The main problem is that you had to measure all the holes before you built a bar, so everything had to be done by one person, in order.</p>
<p>There are, generally, two ways to solve this problem:</p>
<ol>
<li>Write a specification for the sizes of all the individual holes beforehand, and then spread out the work of making all the different bars for each hole.
<p>This is problematic because one person has to write this specification, and if this were a large project (imagine thousands of holes instead of just three or four), it would take a lot of time. Nobody else on the team can be working until the specification is completed. The spec could be full of mistakes&#8211;there are as many chances for mistakes as there are holes specified, so if there are thousands of holes, that&#8217;s a lot of chances for errors to be made.</p>
</li>
<li>Just say, &#8220;All bar holes will always be the same size and in the same places on the bars. Bars can be screwed together.&#8221; Then set everybody to making bars with standardized holes (or go buy them from the store).
<p>That is simple, and it gets everybody working at once. Because you&#8217;ve standardized your bars, you&#8217;ve lost a little flexibility in dealing with any special cases that come up (maybe a half-width hole would be more useful in some part of the structure). However, you should be able to build a decent structure entirely with standard holes, so that&#8217;s not too much of a problem. And when you have a standard, you can make specific exceptions in some places more easily than if things are not standardized.</p>
<p>Of course, with this method it is very important that you do a little research to pick a good hole size and good bars.</p>
</li>
</ol>
<h3>The Right Way</h3>
<p>So, what would our process look like for many people all using standardized bars that screw together? (This is the right way to build something.)</p>
<ol>
<li>Have your team all go build (or buy) their individual bars. You can have as many people working simultaneously as there are bars in the structure.</li>
<li>Have them test their individual bars to make sure that they won&#8217;t break.</li>
<li>Have them carry their individual bars to the place where the structure needs to be.</li>
<li>Put the first bar into the ground, standing upright:
<pre>|</pre>
</li>
<li>Push on the first bar from all angles to see if it is going to fall over.</li>
<li>Screw in a second bar to the first one:
<pre>|
|</pre>
</li>
<li>Test the complete structure now, only to find that it&#8217;s not strong enough to stand by itself.</li>
<li>Attach unbreakable steel ropes to the sides of the structure, like so:
<pre>
  /|\
 / | \</pre>
<p>These ropes should be able to withstand anything within reason, or even well beyond reason.</p>
</li>
<li>Test it again and find out that it now can stay up no matter how hard you push on it.</li>
<li>Add a third bar, and put new ropes on so that it looks like this:
<pre>
   /|\
  //|\\
 // | \\</pre>
</li>
<li>Remove the lower ropes:
<pre>
   /|\
  / | \
 /  |  \</pre>
<p>(Anybody who&#8217;s been involved in refactoring Bugzilla can remember doing a lot of things that sound <em>just like</em> these last two steps. <img src='http://www.codesimplicity.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
</li>
<li>Test it again.</li>
<li>Continue these steps until you have a completed structure:
<pre>
      |
   _|_|_|_
  /   |   \
 /    |    \
/     |     \</pre>
</li>
<li>When a pipe breaks in three months, figure out what was wrong with that pipe, fix the problem, and replace it with a new pipe that fits into the same holes. The structure is just as strong as it was before.</li>
<li>Continue the above process until you no longer have to pay attention to the structure and it just stays up all by itself.</li>
<li>Adjust the structure as necessary for the changing requirements of the users of the structure, which is easy because the holes are all standardized.</li>
</ol>
<p>So, did you notice that we followed all the Laws Of Software Design?</p>
<ul>
<li>We <a href="/archives/17">thought about the future</a>. We did that for the entire process, but we particularly did it when we put on unbreakable steel ropes that would last no matter what happened in the future.
<p>Also note that we <a href="/archives/32">didn&#8217;t try to predict the future</a>, we just followed our principles so that no matter what happened, our structure was going to stay together and be easy to build.</li>
<li>We <a href="/archives/18">allowed for change</a> by screwing the bars together instead of welding them. We also put standardized holes in all the bars, even if we didn&#8217;t need them, in case we needed to add more bars in the future.</li>
<li>In every step of creating the structure, we <a href="/archives/19">kept our changes small</a> and tested everything as we went. Creating each individual bar was a small task, and we put them together in small steps.</li>
<li>And of course, the most important decision we made was to <a href="/archives/23">keep it simple</a> by making all the holes consistent and standard, and keeping each piece small and simple.</li>
</ul>
<p>Whether you are one person or a thousand, whether your project is 10 lines of code or 10 million, this process will work.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/41#comments">Comments: 2</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/41/feed</wfw:commentRss>
		</item>
		<item>
		<title>Slides From My Talk</title>
		<link>http://www.codesimplicity.com/archives/38</link>
		<comments>http://www.codesimplicity.com/archives/38#comments</comments>
		<pubDate>Fri, 25 Jul 2008 00:35:55 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Administrative]]></category>

		<category><![CDATA[code simplicity]]></category>

		<category><![CDATA[oscon]]></category>

		<category><![CDATA[slides]]></category>

		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=38</guid>
		<description><![CDATA[So, I just had my talk, Code Simplicity: Software Design In Open Source Projects at OSCON 2008. It went really well!
Here&#8217;s the slides from my talk (also available in PDF Format).
-Max
Comments: 0]]></description>
			<content:encoded><![CDATA[<p>So, I just had my talk, <a href="http://fosscoach.wikia.com/wiki/Code_Simplicity:_Software_Design_In_Open_Source_Projects">Code Simplicity: Software Design In Open Source Projects</a> at <a href="http://en.oreilly.com/oscon2008">OSCON 2008</a>. It went really well!</p>
<p>Here&#8217;s the <a href="/wp-content/uploads/2008/07/code-simplicity-open-source-design.odp">slides from my talk</a> (also available in <a href="/wp-content/uploads/2008/07/code-simplicity-open-source-design.pdf">PDF Format</a>).</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/38#comments">Comments: 0</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/38/feed</wfw:commentRss>
		</item>
		<item>
		<title>Talking at OSCON</title>
		<link>http://www.codesimplicity.com/archives/37</link>
		<comments>http://www.codesimplicity.com/archives/37#comments</comments>
		<pubDate>Tue, 22 Jul 2008 12:15:45 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Administrative]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=37</guid>
		<description><![CDATA[I&#8217;m going to be talking at FOSSCoach, a free series of lectures at OSCON. You don&#8217;t need a session pass to attend, but you do need to register (for free).
I&#8217;ll be talking on Thursday, July 24, at 3:25pm, in either room E143 or E144 at the Oregon Convention Center.
I&#8217;ll tell you basically everything I know [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to be talking at <a href="http://fosscoach.wikia.com/wiki/FOSSCoach_at_OSCON_2008">FOSSCoach</a>, a free series of lectures at OSCON. You don&#8217;t need a session pass to attend, but you do need to <a href="http://fosscoach.wikia.com/wiki/OSCON08:How_To_Register">register</a> (for free).</p>
<p>I&#8217;ll be talking on Thursday, July 24, at 3:25pm, in either room E143 or E144 at the <a href="http://maps.google.com/maps?f=q&#038;hl=en&#038;geocode=&#038;q=777+NE+Martin+Luther+King,+Jr.+Blvd.+Portland,+Oregon+97232&#038;sll=37.0625,-95.677068&#038;sspn=35.494074,81.035156&#038;ie=UTF8&#038;ll=45.529591,-122.66171&#038;spn=0.007666,0.019784&#038;z=16">Oregon Convention Center</a>.</p>
<p>I&#8217;ll tell you basically everything I know and have learned about software design, and then how it applies to Open Source software, all in about 45 minutes. Should be fun and interesting!</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/37#comments">Comments: 0</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/37/feed</wfw:commentRss>
		</item>
		<item>
		<title>The Source of Bugs</title>
		<link>http://www.codesimplicity.com/archives/35</link>
		<comments>http://www.codesimplicity.com/archives/35#comments</comments>
		<pubDate>Mon, 21 Jul 2008 19:00:44 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<category><![CDATA[bugs]]></category>

		<category><![CDATA[complexity]]></category>

		<category><![CDATA[simplicity]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=35</guid>
		<description><![CDATA[
Bugs most commonly come from somebody&#8217;s failure to reduce complexity. Less commonly, they come from the programmer&#8217;s misunderstanding of something that was actually simple.

Other than typos, I&#8217;m pretty sure that those two things are the source of all bugs, though I haven&#8217;t yet done extensive research to prove it.
When something is complex, it&#8217;s far too [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
<strong>Bugs most commonly come from somebody&#8217;s failure to reduce complexity. Less commonly, they come from the programmer&#8217;s misunderstanding of something that was actually simple.</strong>
</p></blockquote>
<p>Other than typos, I&#8217;m pretty sure that those two things are the source of all bugs, though I haven&#8217;t yet done extensive research to prove it.</p>
<p>When something is complex, it&#8217;s far too easy to misuse it. If there&#8217;s a black box with millions of unlabeled buttons on it, and 16 of them blow up the world, somebody&#8217;s going to blow up the world. Similarly, in programming, if you can&#8217;t easily understand the documentation of a language, or the actual language itself, you&#8217;re going to mis-use it somehow.</p>
<p>There&#8217;s no <em>right</em> way to use a box with millions of unlabeled buttons, really. You could never figure it out, and even if you wanted to read the 1000-page manual, you probably couldn&#8217;t remember the whole thing well enough to use the box correctly. Similarly, if you make anything complex enough, people are more likely to use it wrongly than to use it correctly. If you have 50, 100, or 1000 of these complex parts all put together, they&#8217;ll never work right, no matter how brilliant an engineer puts them together.</p>
<p>So do you start to see here where bugs come from? Every time you added some complexity, somebody (and “somebody” could even be you, yourself) was more likely to mis-use your complex code. Every time it wasn&#8217;t <em>crystal clear</em> <strong>exactly</strong> what should be done and how your code should be used, somebody could have made a mistake. Then you put your code together with some other code, and there was another chance for mistakes or mis-use. Then we put more pieces together, etc.</p>
<p>Often, this sort of situation happens: the hardware designer made the hardware really complicated. So it had to have a complicated assembly language. This made the programming language and the compiler really complicated. By the time you got on the scene, you had no hope of writing bug-free code without ingenious testing and design. And if your design was <em>less than perfect</em>, well&#8230;suddenly you have lots of bugs.</p>
<p>This is also a matter of understanding the viewpoint of other programmers. After all, something might be simple to <em>you</em>, but it might be complex to somebody who isn&#8217;t you. </p>
<p>If you want to understand the viewpoint of somebody who doesn&#8217;t know anything about your code, find the documentation of a library that you&#8217;ve never used, and read it.</p>
<p>Also, find some code you&#8217;ve never read, and read it. Try to understand not just the individual lines, but what the whole program is doing and how you would modify it if you had to. That&#8217;s the same experience people are having reading your code. You might notice that the complexity doesn&#8217;t have to get very high before it becomes frustrating to read other people&#8217;s code.</p>
<p>Now, once in a while, something is really simple, and the programmer just misunderstood it. That&#8217;s another thing to watch for. If you catch a programmer explaining something to you in a way that makes no sense, perhaps that programmer misunderstood something somewhere along the line. Of course, if the thing he was studying was extremely complex, he had basically no hope of fully understanding it without a PhD in <em>that thing</em>.</p>
<p>So these two things are very closely related. When you write code, it&#8217;s partially your responsibility that the programmer who reads your code in the future understands it, and understands it easily. Now, he could have some critical misunderstanding—maybe he never understood what “if” meant. That&#8217;s not your responsibility. Your responsibility is writing clear code, with the expectation that the future programmer reading your code understands the basics of programming and the language you&#8217;re using.</p>
<p>So, there are a few interesting rules that you can get out of this one:</p>
<blockquote><p>
The simpler your code is, the fewer bugs you will have.
</p></blockquote>
<blockquote><p>
Always work to simplify everything about your program.
</p></blockquote>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/35#comments">Comments: 5</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/35/feed</wfw:commentRss>
		</item>
		<item>
		<title>What Is A Bug?</title>
		<link>http://www.codesimplicity.com/archives/36</link>
		<comments>http://www.codesimplicity.com/archives/36#comments</comments>
		<pubDate>Fri, 18 Jul 2008 19:00:21 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=36</guid>
		<description><![CDATA[  Okay, most programmers know the story—way back when, somebody found an actual insect inside a computer that was causing a problem. (Actually, apparently engineers have been calling problems “bugs” since earlier than that, but that story is fun.)
  But really, when we say “bug” what exactly do we mean?
  Here&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[<p>  Okay, most programmers know the story—way back when, somebody found an actual insect inside a computer that was causing a problem. (Actually, apparently engineers have been calling problems “bugs” since earlier than that, but that story is fun.)</p>
<p>  But really, when we say “bug” what <em>exactly</em> do we mean?</p>
<p>  Here&#8217;s the precise definition of what constitutes a bug. Either:</p>
<ol>
<li>The program did not behave according to the <strong>programmer&#8217;s intentions</strong>.<br/>or<br/></li>
<li>The programmer&#8217;s intentions did not fulfill common and reasonable <strong>user expectations</strong>.</li>
</ol>
<p><span id="more-36"></span>So usually, as long as the program is doing what the programmer intended it to do, it&#8217;s working correctly. Sometimes what the programmer intended it to do is totally surprising to a user and causes him some problem, so that&#8217;s a bug.</p>
<p>  Anything else is a <em>new feature</em>. That is, if the program does exactly what was intended in exactly the expected fashion, but it doesn&#8217;t do <em>enough</em>, that means it needs a new “feature.” That&#8217;s the difference between the definition of “feature” and “bug.”</p>
<p>  Note that hardware can have bugs too. The programmer&#8217;s intention is rarely “the computer now explodes.” So if the programmer writes a program and the computer explodes, that&#8217;s probably a bug in the hardware. There can be other, less dramatic bugs in the hardware, too.</p>
<p>  Essentially, anything that causes the programmer&#8217;s intentions to not be fully carried out can be considered a bug, unless the programmer is trying to make the computer do something it wasn&#8217;t designed to do. For example, if the programmer tells the computer “take over the world” and it wasn&#8217;t designed to be able to take over the world, then the computer would need a new “take over the world” feature. That wouldn&#8217;t be a bug. </p>
<p>  With hardware, you also have to think about the <em>hardware designer&#8217;s</em> intentions, and common and reasonable <em>programmer</em> expectations. At that level, software programmers are actually the main “users”, and hardware designers are the people whose intentions we care about. (Of course, we  also care about the normal user&#8217;s expectations, especially for hardware that users interact with directly like printers, monitors, keyboards, etc.)</p>
<p>  -Max</p>
<p><a href="http://www.codesimplicity.com/archives/36#comments">Comments: 4</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/36/feed</wfw:commentRss>
		</item>
		<item>
		<title>Creating Complexity: Lock-In To Bad Technologies</title>
		<link>http://www.codesimplicity.com/archives/31</link>
		<comments>http://www.codesimplicity.com/archives/31#comments</comments>
		<pubDate>Wed, 16 Jul 2008 19:00:23 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Creating Complexity]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=31</guid>
		<description><![CDATA[  In The Never-Shipping Product, I mentioned seven ways to add complexity, and one of them was &#8220;Lock-In To Bad Technologies.&#8221; But what&#8217;s a &#8220;bad&#8221; technology? Is it all just based on opinion? Should we throw our hands up in the air and give in to the whims of our junior developer who thinks [...]]]></description>
			<content:encoded><![CDATA[<p>  In <a href="/archives/30">The Never-Shipping Product</a>, I mentioned seven ways to add complexity, and one of them was &#8220;Lock-In To Bad Technologies.&#8221; But what&#8217;s a &#8220;bad&#8221; technology? Is it all just based on opinion? Should we throw our hands up in the air and give in to the whims of our junior developer who thinks writing the application in BASIC is a great idea?</p>
<p>  Well, okay, maybe it&#8217;s not <em>all</em> opinion. There must be some way to tell a good technology from a bad one (besides looking back after five years of development and saying, &#8220;Wow, we really shouldn&#8217;t have decided to base our product off of <a href="http://toastytech.com/guis/bob.html">Microsoft Bob</a>.&#8221;)</p>
<p>When I&#8217;m evaluating a technology for inclusion in one of my projects, I look particularly at the technology&#8217;s <em>survival potential</em>, <em>interoperability</em>, and <em>attention to quality</em>. <span id="more-31"></span></p>
<p>  By &#8220;survival potential&#8221; I mean &#8220;how long is this software going to continue to be maintained?&#8221; If you get stuck with libraries or some dependency that becomes obsolete, you&#8217;re really in for some trouble. You can get some idea of the survival potential of the software by seeing how often they&#8217;ve released recently. Also, how responsive are they to bug reports? Do they have a mailing list that&#8217;s very active with users and developers? Are there lots of people online talking about this technology? If a technology has a <em>lot</em> of momentum now, you can be fairly sure that it&#8217;s not going to die any time soon.</p>
<p>  By &#8220;interoperability&#8221; I mean, &#8220;Does this system use some standard that would allow us to switch to a different system if we want, in the future?&#8221; For example, some database systems support <a href="http://savage.net.au/SQL/">standard SQL</a> very well. Some other ones aren&#8217;t as good about that&#8211;they have strange behaviors that don&#8217;t agree with the standard, or they just don&#8217;t support it at all. Using a database with standard-SQL support would allow you to switch to any other standard-SQL database in the future, whereas using a less-standard database would lock you in.</p>
<p>  The final one, &#8220;attention to quality,&#8221; is more of a subjective measurement, but the idea is to see if the product is getting <em>better</em> in its recent releases. If it&#8217;s open-source, check if they&#8217;re refactoring and cleaning up the code base. Is it becoming easier to use or more complex? Do the people who maintain the technology actually care about the quality of their product, or are they just code monkeys working for the pay? Are there are a lot of serious security vulnerabilities in the software that have been published lately?</p>
<p>  Lock-in is a worse problem when you&#8217;re using proprietary software than when your dependencies are open-source. Proprietary vendors can just stop supporting something (or go out of business), whereas in the open-source world anybody is free to pick up a codebase and maintain it if the original maintainers drop it. Granted, open-source projects are just as likely to fall out of existence as proprietary projects are, but at least there&#8217;s the hope (particularly if the project was very popular) that somebody will come around to maintain it again, with open-source.</p>
<p>Proprietary vendors also have a monetary incentive to lock you into their technologies&#8211;even their free technologies. Once you start using their free technologies, they can sell you services and products related to them. Open-source vendors usually lack that monetary incentive, and so are more <em>likely</em> to be &#8220;friendly&#8221; when you want to switch away from them. This isn&#8217;t always true (some proprietary vendors beat the pants off of open-source vendors in terms of interoperability, and some open-source products will still lock you in), but it&#8217;s enough the case that I automatically think &#8220;let&#8217;s use open-source&#8221; when I&#8217;m looking for interoperability.</p>
<p>  There are other aspects to look at when you&#8217;re choosing a technology, and some of it really is opinion. Some people like the way Ruby <em>looks</em> better than the way Python looks. That&#8217;s a valid reason to choose a technology sometimes&#8211;if you just <em>like</em> some technology more than another one, and everything else seems equal according to the criteria above, go with the one that makes you happy. After all, <em>you&#8217;re</em> the one who&#8217;s going to be using it&#8211;your opinion matters! All I&#8217;ve tried to do here is give some <em>universal</em> guidelines that can be used to weed out the definitely bad choices, and the rest is up to your personal research, needs, and desires.</p>
<p> -Max</p>
<p><a href="http://www.codesimplicity.com/archives/31#comments">Comments: 3</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/31/feed</wfw:commentRss>
		</item>
		<item>
		<title>Unforseeable Consequences: Why We Have Principles</title>
		<link>http://www.codesimplicity.com/archives/32</link>
		<comments>http://www.codesimplicity.com/archives/32#comments</comments>
		<pubDate>Mon, 14 Jul 2008 19:00:51 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=32</guid>
		<description><![CDATA[One of the most important things to know about any kind of engineering is:

  There are some things about the future that you do not know.

Obviously it&#8217;d be ideal if we were all-knowing and could perfectly predict every consequence of every decision we&#8217;ll ever make. But that&#8217;s impossible. In fact, it&#8217;s so far from [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important things to know about <em>any</em> kind of engineering is:</p>
<blockquote><p>
  There are some things about the future that you <strong>do not know</strong>.
</p></blockquote>
<p>Obviously it&#8217;d be ideal if we were all-knowing and could perfectly predict every consequence of every decision we&#8217;ll ever make. But that&#8217;s impossible. In fact, it&#8217;s so far from possible that if you predict more than half of the consequences of your engineering decisions, you&#8217;re godlike or just <em>really</em> lucky.</p>
<p>Let&#8217;s take an example outside of the realm of programming: <span id="more-32"></span> CDs, which were designed in 1979 to replace cassette tapes as the primary method of listening to music. Who could have predicted that 20 years later, DVDs would be made the same size and shape so that manufacturers could make CD/DVD drives for computers? Did anybody imagine the problems of spinning a CD <em>fifty times</em> faster than it was supposed to be spun, for reading in a CD-ROM drive?</p>
<p>This is why, in engineering, we have &#8220;guiding principles.&#8221; There are certain rules that, when we follow them, keep things working well no matter <em>what</em> happens in the future. </p>
<p>In the case of software, I&#8217;ve summed up the most basic guiding principles as the <a href="/archives/category/laws-of-software">Laws Of Software</a>. The very first (and most important) law is that <a href="/archives/17">the future is more important than the present</a> (because it&#8217;s very big and the present is very small). But here&#8217;s the thing to know about that: <strong>that doesn&#8217;t mean you have to predict everything about the future</strong>. Instead, it explains why you should be making decisions according to the laws of software&#8211;because those laws make for good <em>future</em> software, no matter <em>what</em> that future is.</p>
<p>Sometimes it can be hard to understand why you should be <a href="/archives/8">stupid, dumb simple</a>, if you&#8217;re only thinking about the present. And it can be impossible to predict exactly <em>why</em> or <em>how</em> simplicity will help you in the future. I can tell you that it <em>will</em> help, and you&#8217;ll be glad you did it, and if you don&#8217;t believe me (which you are welcome to do&#8211;your mind is yours!) you&#8217;re going to end up in mess of trouble somewhere down the line, in a future you <em>can&#8217;t predict</em>.</p>
<p>I&#8217;m not singling you out, here. You&#8217;re not dumb. It&#8217;s just that <em>nobody</em> can predict the total future of a piece of software, except to know that certain decisions <em>now</em> will make that future better, and that other decisions will make that future worse. We know this from decades of experience in the software development industry&#8211;certain basic principles invariably lead us in the right direction, and certain &#8220;<a href="http://c2.com/cgi/wiki?AntiPattern">anti-patterns</a>&#8220;, if followed consistently, <em>invariably</em> lead us into trouble.</p>
<p>To be a successful software developer, you have to be willing to <em>not know</em> some things about the future, and trust that following your principles is the right thing to do. Sometimes it can take years to see that you were right, but it&#8217;s a glorious day when you finally realize that your product still exists because you made the right decision <em>three years ago</em>, when you couldn&#8217;t even prove to anybody that it <em>was</em> the right decision, but forged ahead anyway with your &#8220;excessive simplicity&#8221; because you knew it was the right thing to do.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/32#comments">Comments: 3</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/32/feed</wfw:commentRss>
		</item>
		<item>
		<title>FOSSCoach 2008</title>
		<link>http://www.codesimplicity.com/archives/33</link>
		<comments>http://www.codesimplicity.com/archives/33#comments</comments>
		<pubDate>Tue, 01 Jul 2008 21:14:53 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Administrative]]></category>

		<category><![CDATA[fosscoach]]></category>

		<category><![CDATA[oscon]]></category>

		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=33</guid>
		<description><![CDATA[If you&#8217;re going to be in Portland, Oregon or attending OSCON and you want to hear me talk, I&#8217;ve proposed a session for FOSSCoach called Code Simplicity: Software Design In Open Source Projects.
Registration for FOSSCoach is free, but is limited to 100 people, so sign up if you want to come.
-Max
Comments: 0]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re going to be in Portland, Oregon or attending OSCON and you want to hear me talk, I&#8217;ve proposed a session for <a href="http://fosscoach.wikia.com/">FOSSCoach</a> called <a href="http://fosscoach.wikia.com/wiki/Code_Simplicity:_Software_Design_In_Open_Source_Projects">Code Simplicity: Software Design In Open Source Projects</a>.</p>
<p><a href="http://fosscoach.wikia.com/wiki/OSCON08:How_To_Register">Registration</a> for FOSSCoach is free, but is limited to 100 people, so sign up if you want to come.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/33#comments">Comments: 0</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/33/feed</wfw:commentRss>
		</item>
		<item>
		<title>The Never-Shipping Product</title>
		<link>http://www.codesimplicity.com/archives/30</link>
		<comments>http://www.codesimplicity.com/archives/30#comments</comments>
		<pubDate>Mon, 02 Jun 2008 19:00:51 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Creating Complexity]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/?p=30</guid>
		<description><![CDATA[When you work as a professional programmer, you almost always know somebody (or are somebody) who&#8217;s going through one of the most common development horror stories in the book:
&#8220;We started working on this project five years ago, and the technology we were using/making was modern then, but it&#8217;s obsolete now. Things keep getting more and [...]]]></description>
			<content:encoded><![CDATA[<p>When you work as a professional programmer, you almost always know somebody (or are somebody) who&#8217;s going through one of the most common development horror stories in the book:</p>
<p>&#8220;We started working on this project five years ago, and the technology we were using/making was modern then, but it&#8217;s obsolete now. Things keep getting more and more complex with this obsolete technology, so it keeps getting less and less likely that we&#8217;ll ever finish the project. But if we re-write, we could be here for another five years!&#8221;</p>
<p>Another popular one is: &#8220;We can&#8217;t develop fast enough to keep up with modern user needs.&#8221; Or, &#8220;While we were developing, Google wrote a product better than ours much faster than us.&#8221;</p>
<p>When I hear things like that, the first thing I ask myself is &#8220;How did that happen? Why did it take so long for them to finish their product that they ran into that problem?&#8221;</p>
<p>The answer lies in <em>complexity</em>. <span id="more-30"></span> The more complex a task is, the harder it is to complete it. So you start out with something simple that can be completed in one month. Then you add complexity, and the task will take three months. Then you take each piece of that and make it more complex, and the task will take <em>nine</em> months. </p>
<p>Complexity <em>builds</em> on complexity&#8211;it&#8217;s not just a linear thing. It&#8217;s not like, &#8220;We have ten features, and so adding one more will only add 10% more time.&#8221; No, one new feature will have to be coordinated with all ten of your existing features. So if just the feature itself takes 10 hours of coding time, there will be another hour of coding time for that feature interacting with each other feature. The more features there are, the higher the cost gets of adding a feature.</p>
<p>Some projects start out with such a complex set of requirements that they never get a first version out. If you&#8217;re in this situation, you should just trim features. Don&#8217;t shoot for the moon in your first release&#8211;get out something that works and make it work <em>better</em> over time.</p>
<p>There are other ways to add complexity than just adding features, too. The most common other ways are:</p>
<ul>
<li><strong>Expanding the <a href="/archives/7">purpose of the software</a></strong>. Generally, just don&#8217;t ever do that. Your marketing droids might be drooling over the idea of &#8220;making a single piece of software that does your taxes and cooks dinner&#8221;, but you should be <em>screaming</em> as loud as you can whenever any suggestion like that comes near your desk. Stick to your purpose&#8211;your software just has to do what it does <em>well</em>, and you will succeed, if that purpose is something people need.</li>
<li><strong>Adding programmers.</strong> Yes, that&#8217;s right&#8211;adding more people to the team adds <em>complexity</em>, it does not make things simpler. Remember <em><a href="http://www.robelle.com/smugbook/manmonth.html">The Mythical Man Month</a></em>? What he says in there is true because of the complexity equation I explained higher up in this article&#8211;if you have ten programmers, adding an eleventh means spending time to groove in that one programmer, plus the time to groove in the existing ten programmers to the new guy, plus the time spent by the new guy interacting with the existing ten programmers.</li>
<li><strong>Change things</strong>: Any time you change something, you&#8217;re adding complexity. Whether it&#8217;s a requirement, a design, or just a piece of code, you&#8217;re introducing the possibility of bugs, the time required to implement the change, the time required to validate that the new change works with all the other pieces of the software, the time required to decide upon the change, and the time required to track the change, and the time required to test the change. Each change builds on the last in terms of all this complexity, so the more you change, the more and more time each new change is going to take. It&#8217;s still important to make certain changes, but you should be making informed decisions about it, not just changing everything on a whim.</li>
<li><strong>Lock-In to bad technologies</strong>. This is where you make a bad decision about your backend or libraries and then are stuck with it for a long time because you&#8217;re so dependent on it. Obviously &#8220;bad technology&#8221; is very subjective, but sometimes there are obvious good choices and obvious bad ones. For example, if you need an embedded scripting language, <a href="http://www.lua.org/">Lua</a> is generally considered to be a good choice, and &#8220;write our own&#8221; would probably be one of the worse choices, depending on the situation. It&#8217;s definitely relative&#8211;it&#8217;s not like there&#8217;s only one good choice and all the rest are bad, but some choices might make your life easier than others.</li>
<li><strong>Poor design or no design</strong>. Basically, this just means &#8220;a failure to <a href="/archives/19">plan for change</a>.&#8221; Things are going to change, and that requires design work, to maintain simplicity while the project grows. Failing to do this can introduce massive complexity very fast, because suddenly each new feature <em>quadruples</em> the complexity of the code instead of just adding a little bit to the complexity.</li>
<li><strong>Re-inventing the wheel</strong>. For example, if you invent your own protocol when a perfectly good one exists, you&#8217;re going to be spending a <em>lot of time</em> working on the protocol, when you could just be working on your software. You should basically <em>never</em> have any huge invented-in-house dependency, like a webserver, a protocol, or a major library, unless that <em>is</em> your product.</li>
</ul>
<p>The thing about all of these is that they&#8217;re <em>insidious</em>. Most of them only do long-term damage&#8211;something you won&#8217;t see for a year or more. So when somebody proposes them, often they sound harmless! And even when you start implementing them, maybe they seem fine. But as time goes on&#8211;and particularly as more and more of these stack up&#8211;the complexity becomes more apparent and grows and grows and grows, until you&#8217;re another victim of that ever-so-common horror story: &#8220;The Never-Shipping Product.&#8221; (Which is nowhere near as cool as <em>The Neverending Story</em>, believe me.)</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/30#comments">Comments: 1</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/30/feed</wfw:commentRss>
		</item>
		<item>
		<title>Specific Solutions</title>
		<link>http://www.codesimplicity.com/archives/28</link>
		<comments>http://www.codesimplicity.com/archives/28#comments</comments>
		<pubDate>Tue, 22 Apr 2008 14:36:34 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Essays]]></category>

		<category><![CDATA[colossus]]></category>

		<category><![CDATA[kyle xy]]></category>

		<category><![CDATA[second life]]></category>

		<category><![CDATA[the sims]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/28</guid>
		<description><![CDATA[  So, I&#8217;m a huge Kyle XY fan, and I was entertaining myself this morning by watching the various &#8220;behind the scenes&#8221; clips that they have on the website. Of course, before each clip was an ad&#8211;the same ad every time&#8211;for The Sims. No matter how silly the ad may be, being forced to [...]]]></description>
			<content:encoded><![CDATA[<p>  So, I&#8217;m a huge <a href="http://abcfamily.go.com/abcfamily/path/section_Shows+Kyle-XY/page_Video-Kyle_Full_1001">Kyle XY</a> fan, and I was entertaining myself this morning by watching the various &#8220;behind the scenes&#8221; clips that they have on the website. Of course, before each clip was an ad&#8211;the same ad every time&#8211;for <a href="http://thesims.ea.com/">The Sims</a>. No matter how silly the ad may be, being forced to watch it over and over did eventually get me thinking&#8211;although not about buying The Sims:</p>
<p>  Why has The Sims sold 100 million copies, while <a href="http://secondlife.com/">Second Life</a>, an ostensibly much more flexible and powerful universe, only has about 2 million active users? They look pretty similar, and you might guess at first glance that they&#8217;d have somewhat similar audiences. But, although 2 million users is nothing to scoff at, 100 million absolutely trounces it. So why the big difference?</p>
<p>  Well, of course, The Sims has EA Games behind them, who have a massive distribution channel and a lot of marketing power, but the Internet buzz and general promotion of Second Life is pretty good too, so although EA has the edge, that doesn&#8217;t explain a 50-to-1 difference in sales. There must be something actually different about the products themselves.</p>
<p>  Well, at first glance, The Sims is very user-friendly and Second Life is (from what I&#8217;ve heard) hard to use. The Sims does a limited scope of things very well, and Second Life does an unlimited number of things through a difficult interface, with mediocre results.</p>
<p>  But fundamentally, why is it that products like The Sims succeed so much more than things like Second Life? And why <em>does</em> The Sims have a better interface, why <em>do</em> people want to play The Sims more than they want to play Second Life? <span id="more-28"></span> Well:</p>
<blockquote><p>
    It&#8217;s easy to make a system that does something specific, and hard to make a system that does everything.
  </p></blockquote>
<p>  When something is easy to make, you can spend a lot more time focusing on the little details&#8211;the polish. When something is hard to make, you spend all your efforts just making it work, and there&#8217;s no time left to sand off the rough edges. Specific solutions allow you to handle a problem with a level of grace, efficiency, and quality that could never be achieved by a generic, do-it-all solution.</p>
<p>  A great example is the <a href="http://www.codesandciphers.org.uk/lorenz/colossus.htm">Colossus</a> computer, built in 1943 to break <a href="http://www.codesandciphers.org.uk/lorenz/fish.htm">encrypted German radio messages</a> in World War II. That was <em>all</em> the Colossus did&#8211;it was fundamentally incapable of doing any other task. However, it would have taken a 5 MHz general-purpose computer to break that code at the same rate as the Colossus&#8211;a level of speed that desktop computers didn&#8217;t reach until the 1970&#8217;s, <em>30 years later</em>.</p>
<p>  This is something that I have been trying to get across to programmers for quite some time&#8211;you don&#8217;t need to solve <em>all</em> the world&#8217;s problems with one piece of code, you only need to solve <em>the problem you&#8217;re solving</em>. Whether you&#8217;re designing a whole system or just a tiny piece, your code doesn&#8217;t need to do any more than is called for by the known requirements. Sure, keep it extendable for the future&#8211;that&#8217;s part of making a quality solution. But all solutions should be <em>specific</em> solutions to <a href="/archives/24">known problems</a>.</p>
<p>  The Sims satisfies a specific, known need&#8211;the desire of people to play out <em>specific types</em> of fantasy lives. It succeeds because it&#8217;s <em>not</em> infinitely flexible. Second Life is a nightmare of complexity because it tries to be &#8220;everything to everyone&#8221;&#8211;a situation in which you almost always end up being not enough to anyone.</p>
<p>  When people have problems with complexities or confusions in their software, I encourage them to be The Sims. Be <a href="http://en.wikipedia.org/wiki/Notepad">Notepad</a>. Be the <a href="http://www.google.com/">Google main page</a>. Don&#8217;t try to anticipate every need in the world, just solve the ones you <em>know</em> exist. Everything tends to fall into place when you really know your requirements and just go to solve <em>them</em>.</p>
<p>  -Max</p>
<p><a href="http://www.codesimplicity.com/archives/28#comments">Comments: 3</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/28/feed</wfw:commentRss>
		</item>
		<item>
		<title>Complexity and the Wrong Solution</title>
		<link>http://www.codesimplicity.com/archives/27</link>
		<comments>http://www.codesimplicity.com/archives/27#comments</comments>
		<pubDate>Mon, 14 Apr 2008 20:00:20 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<category><![CDATA[complexity]]></category>

		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/27</guid>
		<description><![CDATA[  Often, if something is getting very complex, that means that there is an error somewhere far below the level that things are getting complex on.
  For example, it&#8217;s very difficult to make a car move if it has square wheels. You&#8217;re going to be spending lots and lots of time figuring out [...]]]></description>
			<content:encoded><![CDATA[<p>  Often, if something is getting very complex, that means that there is an error somewhere far below the level that things are getting complex on.</p>
<p>  For example, it&#8217;s very difficult to make a car move if it has square wheels. You&#8217;re going to be spending lots and lots of time figuring out how to make the car work, when really it should just have round wheels.</p>
<p>  Any time there&#8217;s an “unsolvable complexity” in your program, it&#8217;s because there&#8217;s something fundamentally wrong with it. If the problem is “unsolvable” at one level, maybe you should back up and look at what&#8217;s underlying the problem. Maybe you put square wheels on the car, and now you&#8217;re trying to figure out how to make it go fast.</p>
<p>  Programmers actually do this quite often. For example, “I have this terribly messy code, now it&#8217;s really complex to add a new feature!” Well, your fundamental problem there is the that code is messy. Clean it up, make the already-existing code simple, and suddenly adding the new feature will be simple.</p>
<p><strong>What Problem Are You Trying To Solve?</strong></p>
<p>  If somebody comes up to you and says something like, “How do I make this pony fly to the moon?”, the question you need to ask is, “What problem are you trying to solve?” You&#8217;ll find out that they really need to collect gray rocks. Why they thought they had to fly to the moon, and use a <em>pony</em> to do it, only they know. People <em>do</em> get confused like this.</p>
<p>  So when things get complex, back up and you look at the problem that you&#8217;re trying to solve. Take a <em>really big</em> step back. You are allowed to question <em>everything</em>. Maybe you thought that adding 2 and 2 was the only way to get 4, and you didn&#8217;t think about adding 1 and 3 instead, or just skipping the addition entirely and just <em>putting</em> “4” there.  The “problem” is “How do I get 4?” <em>Any</em> method of solving that problem is acceptable, so figure out what the <em>best</em> method would be, for the situation that you&#8217;re in.</p>
<p>  Discard your assumptions. Really <em>look</em> at the <em>problem</em> that you&#8217;re trying to solve, and think about the simplest way to solve that problem. Not “How do I solve this problem using my current code?” Not “How did Professor Bob solve this problem in his program?” No, just how, <em>in general</em>, in a perfect world, should that problem be solved? From there, you might see how your code needs to be re-worked. Then you can re-work your code. <em>Then</em> you can solve the problem.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/27#comments">Comments: 16</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/27/feed</wfw:commentRss>
		</item>
		<item>
		<title>Truncated Posts in RSS?</title>
		<link>http://www.codesimplicity.com/archives/26</link>
		<comments>http://www.codesimplicity.com/archives/26#comments</comments>
		<pubDate>Thu, 10 Apr 2008 21:45:10 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Administrative]]></category>

		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/26</guid>
		<description><![CDATA[  Hey everybody. So, some of my posts are rather long, and so I truncate them with a (Read More&#8230;) link that takes you to the full post. That link also shows up in the RSS, as a (more&#8230;) link.
  For the frontpage of codesimplicity.com, I think that&#8217;s pretty useful&#8211;it makes it a [...]]]></description>
			<content:encoded><![CDATA[<p>  Hey everybody. So, some of my posts are rather long, and so I truncate them with a (Read More&#8230;) link that takes you to the full post. That link also shows up in the RSS, as a (more&#8230;) link.</p>
<p>  For the frontpage of codesimplicity.com, I think that&#8217;s pretty useful&#8211;it makes it a lot easier to browse the various articles. But I was wondering, for those who read this in an aggregator or via RSS&#8211;for the long posts, do you prefer getting only the short version (with the &#8220;more&#8230;&#8221; link) or would you rather just have the whole post?</p>
<p><strong>Update:</strong> It looks like, from the comments, that full text in the feed is the clear winner! That&#8217;s actually my preference too, when reading sites, but I usually am not reading posts as long as the ones I write. <img src='http://www.codesimplicity.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> I&#8217;ve installed and activated the <a href="http://cavemonkey50.com/code/full-feed/">Full Text Feed</a> plugin for WordPress, so in the future the feeds will contain the full text even though the front page and email notifications will still be cut by the &#8220;more&#8221; link.</p>
<p>  -Max</p>
<p><a href="http://www.codesimplicity.com/archives/26#comments">Comments: 11</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/26/feed</wfw:commentRss>
		</item>
		<item>
		<title>Instant Gratification = Instant Failure</title>
		<link>http://www.codesimplicity.com/archives/25</link>
		<comments>http://www.codesimplicity.com/archives/25#comments</comments>
		<pubDate>Wed, 09 Apr 2008 20:09:38 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Essays]]></category>

		<category><![CDATA[bugzilla]]></category>

		<category><![CDATA[mozilla]]></category>

		<category><![CDATA[refactoring]]></category>

		<category><![CDATA[vci]]></category>

		<category><![CDATA[VCs]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/25</guid>
		<description><![CDATA[The broadest problem that I see in the software industry is that companies are unwilling to engage in strategies that only show results in the long term. Or, more specifically, that organizations are unaware that there is any such thing as a long-term strategy.
In the US, it&#8217;s probably a symptom of a general cultural problem&#8211;if [...]]]></description>
			<content:encoded><![CDATA[<p>The broadest problem that I see in the software industry is that companies are unwilling to engage in strategies that only show results in the long term. Or, more specifically, that organizations are unaware that there <em>is</em> any such thing as a long-term strategy.</p>
<p>In the US, it&#8217;s probably a symptom of a general cultural problem&#8211;if an American can&#8217;t see an instant result from something, they think it doesn&#8217;t work. This leads to fast food, french fries, and fat people. The healthy way to eat (protein and vegetables) has a <em>delayed</em> effect on the body (you don&#8217;t get the energy for over an hour), and the bad way to eat (endless carbohydrates without nutritional value) has an instant result&#8211;immediate energy.</p>
<p>Software is always a <em>long-term process</em>. I wrote the first version of <a href="http://vci.everythingsolved.com/">VCI</a> in about three weeks, and that was <em>insanely fast</em>. Any actual application (VCI&#8217;s just a library) takes months or years of person-hours, even if you keep it small. So you&#8217;d think that organizations would be far-sighted about their development strategies, right?</p>
<p>Unfortunately, it just doesn&#8217;t happen. Competitor X comes out with &#8220;Shiny New Feature&#8221; and The Company says &#8220;we must have Shiny New Feature RIGHT NOW!&#8221; That&#8217;s not a long-term winning strategy, that&#8217;s just short-sighted panic. If you have users, they&#8217;re not all going to get up and go away in the next five minutes just because somebody else has one feature that you don&#8217;t. You should be looking at <em>trends</em> of how many users you&#8217;re gaining or losing, not just responding mindlessly to the immediate environment.</p>
<p>So what&#8217;s a good long-term strategy? Well, refactoring your code so that you will still be able to add features in the future, that&#8217;s a good one. Or spending some extra time putting some polish on your features and UI so that when the product is released, users are actually happy with it. <em>Not</em> adding features that you don&#8217;t want to maintain, if they&#8217;re not important enough&#8211;that&#8217;s another one.</p>
<p>Remember that <a href="http://www.mozilla.org/">Mozilla</a> did poorly for years, only to finally start gaining dominance in a market that Netscape had lost, because they had a <em>long-term</em> plan. Granted, Mozilla made some decisions early on that caused some things to take longer than they should have, but they still won out in the long term, despite failing in the short term.</p>
<p>Of course, it can be hard to convince people that your long-term plan is right, sometimes, because it takes so long to show results! When I started refactoring <a href="http://www.bugzilla.org/">Bugzilla</a> about four years ago, there was pretty constant resistance, particularly when I would review patches and say, &#8220;You need to wait for the new architecture before this can go in,&#8221; or &#8220;This needs to be fixed to not be <a href="http://www.computerhope.com/jargon/s/spaghett.htm">spaghetti code</a>.&#8221; But once the refactoring really got rolling (after about two and a half years), it suddenly became <a href="http://www.bugzilla.org/releases/3.0/new-features.html">way easier to add new features</a> and nearly all the developers became big supporters of refactoring.</p>
<p>I read so much &#8220;advice&#8221; on &#8220;how to run your software business&#8221; that just focuses on instant gratification&#8211;what you can get done <em>right now</em>. &#8220;Add features!&#8221; &#8220;Get millions of dollars instantly from <abbr title="Venture Capitalists">VCs</abbr>!&#8221; Unfortunately, the way the universe seems to work is that you can destroy something in an instant, but it takes <em>time</em> to create something. So in reality, the closer you get to &#8220;instant gratification&#8221;, the closer you get to destruction of your product, your business, and your future.</p>
<p>If you want a good plan, pick one that admits that <em>creation takes time</em>. It doesn&#8217;t have to take <em>forever</em>, but it&#8217;s never <em>instant</em>.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/25#comments">Comments: 11</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/25/feed</wfw:commentRss>
		</item>
		<item>
		<title>If It Ain&#8217;t Broken&#8230;</title>
		<link>http://www.codesimplicity.com/archives/24</link>
		<comments>http://www.codesimplicity.com/archives/24#comments</comments>
		<pubDate>Fri, 04 Apr 2008 19:00:06 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<category><![CDATA[third law]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/24</guid>
		<description><![CDATA[Okay, so remember our third law? (You can&#8217;t break things if you don&#8217;t change them.) Well, that has a very important related rule, that every engineer on Earth knows, but sometimes forgets:

Never “fix” anything unless it&#8217;s a problem, and you have evidence showing that the problem really exists.

Of course, most of us know this as [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so remember our <a href="/archives/19">third law</a>? (You can&#8217;t break things if you don&#8217;t change them.) Well, that has a very important related rule, that every engineer on Earth knows, but sometimes forgets:</p>
<blockquote><p>
<strong>Never “fix” anything unless it&#8217;s a problem, and you have evidence showing that the problem really exists.</strong>
</p></blockquote>
<p>Of course, most of us know this as &#8220;If it ain&#8217;t broken, don&#8217;t fix it.&#8221; However, these wise words are frequently ignored, because many developers don&#8217;t have a good understanding of what &#8220;broken&#8221; means. Often, developers just <em>imagine</em> that users have a problem with something, and start fixing it. Or they go off and develop features that don&#8217;t solve anybody&#8217;s problem. This is <em>far, far</em> more common than you might think.</p>
<p>So that&#8217;s why I say you should have <em>evidence</em> that there&#8217;s a problem. Without that evidence, you could just be fixing things that aren&#8217;t actually problems, and if you go around fixing things that aren&#8217;t broken, you&#8217;re going to <em>break things</em>. And not only could you be generating bugs, but you&#8217;re wasting your time and adding complexity to your program for no reason. You need <em>evidence</em> that there&#8217;s a problem, before you start coming up with a solution.</p>
<p>What do I mean by “evidence”? <span id="more-24"></span> Well, five users report that when they push the red button, your program explodes. Okay, that&#8217;s good enough for me! Or <em>you</em> push the red button, and you notice that the program explodes.</p>
<p>However, just because a user reports something doesn&#8217;t mean it&#8217;s a problem. Sometimes a user just didn&#8217;t realize that your program had some feature already, and so asked you to implement something else silly. For example, you write a program that sorts a list of words alphabetically, and a user asks you to add a feature that sorts a list of <em>letters</em> alphabetically. Your program <em>already does that</em>. (Actually, it already does more than that. This is often the case, with this sort of confused request.) So in this case, the user thought there was a problem, but there wasn&#8217;t even really a problem, even though he could maybe present “evidence” that he couldn&#8217;t sort a list of letters. (He just didn&#8217;t realize that he should use the <em>word</em>-sorting feature.)</p>
<p>Note that if you get a lot of requests like the above, it probably means that users can&#8217;t easily figure out how to find what they need. There&#8217;s some complexity that needs to be reduced on your end.</p>
<p>Finally, sometimes a user will report that there&#8217;s a bug, but actually that&#8217;s the program behaving exactly as you intended it to. In this case, it&#8217;s a matter of “majority rules.” If a significant number of users think that the behavior is a bug, it&#8217;s a bug. If only a tiny minority (like one or two) think it&#8217;s a bug, it&#8217;s not a bug.</p>
<p>The most famous error in this area is what we call “premature optimization”. That is, some developers seem to like to “make things go fast”.  But they do it before they know that it&#8217;s slow! This is like a charity sending food to rich people. “We just wanted to help people!” Right—illogical, isn&#8217;t it? They&#8217;re solving a problem that doesn&#8217;t exist.</p>
<p>The only parts of your program where you should be concerned about speed are the exact parts that you can show cause a real performance problem for the users. The rest of the code, the primary concern is simplicity, not “make things go fast”.</p>
<p>There are infinite ways of violating this rule, but the way to follow it is <em>so simple</em>: just get real evidence that the problem is <em>valid</em> before you fix it.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/24#comments">Comments: 0</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/24/feed</wfw:commentRss>
		</item>
		<item>
		<title>The Fourth Law of Software Design: Complexity vs. Ease of Maintenance</title>
		<link>http://www.codesimplicity.com/archives/23</link>
		<comments>http://www.codesimplicity.com/archives/23#comments</comments>
		<pubDate>Mon, 10 Mar 2008 19:00:39 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<category><![CDATA[complexity]]></category>

		<category><![CDATA[fourth law]]></category>

		<category><![CDATA[girders]]></category>

		<category><![CDATA[overengineering]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/23</guid>
		<description><![CDATA[Okay, so if we never change our software, we can entirely avoid defects. But change is inevitable! Particularly if we&#8217;re going to add new features. And after all, one of our goals was to make software easy to maintain, and to maintain software, it has to be changed here and there. In other words, we [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so if we never change our software, we can entirely avoid defects. But change is inevitable! Particularly if we&#8217;re going to add new features. And after all, one of <a href="/archives/22">our goals</a> was to make software easy to maintain, and to maintain software, it has to be changed here and there. In other words, we <em>will</em> be making changes. So &#8220;don&#8217;t change anything&#8221; can&#8217;t be the ultimate defect-reduction technique.</p>
<p>Well, like I said in the <a href="/archives/19">my design philosophy</a> it helps to keep your changes small. But if you want to avoid even more defects, and eliminate them even from your small changes, there&#8217;s another law that can help you. And it doesn&#8217;t just reduce defects&#8211;it  keeps things maintainable, makes it easy to add new features, improves the overall understandability of your code, and knowing it helps you make better software, all around. This Fourth Law of Software Design is: <span id="more-23"></span></p>
<blockquote><p>
<strong>The maintainability of a system is inversely proportional to the complexity of its individual pieces.</strong>
</p></blockquote>
<p>Where &#8220;maintainability&#8221; means &#8220;ease of maintenance.&#8221; Extreme <em>unmaintainability</em> would be the total inability to maintain some part or the whole of a piece of software. <em>Perfect</em> maintainability is impossible, but it&#8217;s the goal you strive for&#8211;total change or infinite new code with no difficulty.</p>
<p>This law is largely empirical, meaning that I figured it out by observation, not by logic. However, it does have a logical basis:</p>
<ol>
<li>The simpler something is, the easier it is to understand. For example, a beach ball is very simple&#8211;a single large round object that you throw around&#8211;and is something that anybody can understand.</li>
<li>The more complex something is, the harder it is to understand. For example, a jet plane is very complex, and takes extensive training to use and understand. Complexity is not the only factor that makes things hard to understand, but with enough complexity, <em>anything</em> can become hard to understand.</li>
<li>The less you understand something, the harder it is to fix or modify it.</li>
<li>Thus: The more complex something becomes, the harder it is to modify (maintain) it.</li>
</ol>
<p>However, you&#8217;ll notice that I didn&#8217;t say anything about the complexity of the <em>whole system</em>, in the law. I only mentioned its <em>individual pieces</em>. Why did I do that?</p>
<p>Well, an average-sized computer program is so complex that no human being could comprehend it all at once in their mind. It&#8217;s only possible to comprehend <em>pieces</em> of it. So we actually <em>always</em> have some large, complex structure for our whole program. What then becomes important is that the <em>pieces</em> can be understood when we look at them, and that we understand how the pieces relate to each other. The easier it is to understand the pieces, the more likely it is that any given person will understand them. That&#8217;s particularly important when you&#8217;re handing your code off to other people, or when you go away from your code for a few months and then have to come back and &#8220;re-learn&#8221; what you did, by reading your own code.</p>
<p>Let&#8217;s make an analogy, to demonstrate the principle. Imagine that you&#8217;re building a 30-foot tall steel structure. There are two ways to make it&#8211;you could make it out of a bunch of small girders, or you could try to forge three huge pieces of steel and put them together. With the girders approach, it&#8217;s easy to make or buy the individual pieces. The three huge pieces, on the other hand, have to be carefully custom-made and worked on extensively. With the girders, if one breaks you just replace it with an identical spare part. With the &#8220;huge pieces&#8221; approach, when one breaks you have to evacuate the structure, remove 1/3 of it, create a whole new custom piece, and then add that back in without collapsing the whole structure. The girders are simple, the huge pieces are complex.</p>
<p>So why do people sometimes write software with the &#8220;huge pieces&#8221; approach instead of the girders approach? It&#8217;s because there&#8217;s a <em>perceived</em> savings of time when you&#8217;re first <em>creating</em> the software, with the &#8220;huge pieces&#8221; method. With a bunch of small pieces, there is a lot of time spent <em>putting them together</em>. You don&#8217;t see that with the huge pieces&#8211;there&#8217;s three of them, they snap together, and that&#8217;s it. But the part that&#8217;s missed here is that it took <em>way more time</em> to create the three huge pieces than it did to create the girders. When you&#8217;re making a huge, complex single piece, any tiny error means that the whole thing has to be fixed or re-worked. And per observation in the practical world of programming, you will spend far more time fixing and re-working those huge pieces than you will putting together the small girders. So even though the time spent creating the &#8220;huge pieces&#8221; might seem like &#8220;productive, important time&#8221; and the time spent putting together the girders might seem like &#8220;busywork&#8221; or &#8220;wasted time,&#8221; the &#8220;girders&#8221; approach is actually more efficient.</p>
<p>I could go on and on about this, but you can find out about it for yourself. If you don&#8217;t believe me, spend a few years working on a software project where all the parts are very complex. I don&#8217;t <em>recommend</em> that you do that, but if you need any proof of this law for yourself, that would be a good (if painful) way to get it. Of course, you could also just <em>apply</em> the law and see if your software keeps on being maintainable&#8211;that&#8217;s a much less painful demonstration. <img src='http://www.codesimplicity.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So how do we use this law, in the practical world of programming? Well, generally I recommend that people make the individual components of their code as simple as possible. Ideally this would start way down at the assembly language level, but you don&#8217;t always get simplicity there. Nor do you always get a simple programming language. But with what you have, strive for simplicity. Make everything as simple as possible. Don&#8217;t be afraid to be <a href="/archives/8">stupid, dumb simple</a>. There is no limit to how simple you can make something, because if you go too far, your &#8220;simplicity&#8221; will start becoming <em>complex</em>. (In other words, you&#8217;ll be <a href="/archives/12">overengineering</a>.) So just be as simple as you can possibly be, and if you overdo it (which almost never happens), it&#8217;ll be pretty obvious.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/23#comments">Comments: 5</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/23/feed</wfw:commentRss>
		</item>
		<item>
		<title>The Third Law of Software Design</title>
		<link>http://www.codesimplicity.com/archives/19</link>
		<comments>http://www.codesimplicity.com/archives/19#comments</comments>
		<pubDate>Fri, 07 Mar 2008 19:00:18 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<category><![CDATA[bugs]]></category>

		<category><![CDATA[designing too far into the future]]></category>

		<category><![CDATA[overengineering]]></category>

		<category><![CDATA[third law]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/19</guid>
		<description><![CDATA[So now we know that there is more future time than present time and that software will change as time goes on.
Our next law is, once again, axiomatic, and needs no derivation:

It is impossible to introduce new defects in your software if you do not change anything about it.

This is important&#8211;and categorized as a law&#8211;because [...]]]></description>
			<content:encoded><![CDATA[<p>So now we know that <a href="/archives/17">there is more future time than present time</a> and that <a href="/archives/18">software will change</a> as time goes on.</p>
<p>Our next law is, once again, <a href="/archives/17">axiomatic</a>, and needs no derivation:</p>
<blockquote><p>
<strong>It is impossible to introduce new defects in your software if you do not change anything about it.</strong>
</p></blockquote>
<p>This is important&#8211;and categorized as a law&#8211;because defects violate our purpose of <a href="/archives/21">helping people</a>. If something is a defect, by definition it is not helpful to people, and we need to avoid it.</p>
<p>This is also sometimes stated more informally as &#8220;You can&#8217;t introduce new bugs if you don&#8217;t add or modify code.&#8221; I&#8217;m not sure that &#8220;code&#8221; entirely covers &#8220;anything about it,&#8221; so I didn&#8217;t state it that way.</p>
<p>Of course, the reverse would be:</p>
<blockquote><p>
It is possible to introduce defects into your software if you change something about it.
</p></blockquote>
<p>Which leads to:</p>
<blockquote><p>
The more changes you make, the more likely you are to introduce a defect.
</p></blockquote>
<p>The funny thing is that this seems to be in conflict with the <a href="/archives/18">second law</a>, and in fact it is. <span id="more-19"></span> It&#8217;s the balancing act between the second and third law that requires your intelligence as a software designer.</p>
<p>Combining all three laws, we get:</p>
<blockquote><p>
The best design is the one that allows for the most change in the environment with the least change in the software.
</p></blockquote>
<p>And that, pretty simply, sums up my design philosophy.</p>
<p>However, it&#8217;s important to limit that somewhat. Although that may be the best <em>code</em> design, that rule doesn&#8217;t necessarily lead to the best <em>user-facing</em> design. An equivalent law for users would be something like, &#8220;If you never use the program it won&#8217;t break,&#8221; but I&#8217;m not sure that&#8217;s so useful. This third law is about preventing bugs, not about making things work <em>nicely</em>. You still want things to work nicely and do what people want&#8211;I&#8217;m just telling you here how to avoid <em>bugs</em>.</p>
<p>Another thing to know here is that, given our first two laws, it&#8217;s an error to write a system that &#8220;does everything we could ever possibly need,&#8221; but not make it flexible enough to cope with future change. That might seem like a good way to &#8220;avoid future changes in the software&#8221;, but really you&#8217;re just bringing all that change into the <em>present</em>, introducing the same number of bugs, and then not allowing any room to grow. And no program will do everything you could <em>ever</em> possibly need&#8211;there will always be future requirements that you cannot predict. This is covered more in <a href="/archives/6">Designing Too Far Into The Future</a>.</p>
<p>On the other hand, you can <a href="/archives/12">overengineer</a> to the point where your design is <em>so</em> flexible that creating and maintaining it is extremely difficult. That would be the point where you reach a level of flexibility that is not necessary to the real future (thinking about this in relation to the First Law).</p>
<p>However, overengineering is a much less common error than designing too far into the future. When in doubt, expect change, and plan your code in ways that will make change as simple and small as possible.</p>
<p>-Max</p>
<p><a href="http://www.codesimplicity.com/archives/19#comments">Comments: 7</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codesimplicity.com/archives/19/feed</wfw:commentRss>
		</item>
		<item>
		<title>The Second Law of Software Design</title>
		<link>http://www.codesimplicity.com/archives/18</link>
		<comments>http://www.codesimplicity.com/archives/18#comments</comments>
		<pubDate>Mon, 03 Mar 2008 19:00:52 +0000</pubDate>
		<dc:creator>Max Kanat-Alexander</dc:creator>
		
		<category><![CDATA[Laws of Software]]></category>

		<category><![CDATA[change]]></category>

		<category><![CDATA[first law]]></category>

		<category><![CDATA[second law]]></category>

		<guid isPermaLink="false">http://www.codesimplicity.com/archives/18</guid>
		<description><![CDATA[Now that we know that the future is important, our second law answers the question, &#8220;What&#8217;s going to happen in the future?&#8221; To any programmer who&#8217;s worked for any amount of time, this law will be obviously true once you see it, but it&#8217;s still good to derive and prove it.
This law is derived from [...]]]></description>
			<content:encoded><![CDATA[<p>Now that we know that <a href="/archives/17">the future is important</a>, our second law answers the question, &#8220;What&#8217;s going to happen in the future?&#8221; To any programmer who&#8217;s worked for any amount of time, this law will be obviously true once you see it, but it&#8217;s still good to derive and prove it.</p>
<p>This law is derived from things that we know about the physical universe. From physics we know:</p>
<blockquote><p>
Nothing stays still.
</p></blockquote>
<p>That is, there is no matter or energy anywhere that isn&#8217;t <em>moving</em>. Even the atoms in your desk are vibrating furiously, back and forth. It is actually impossible to make them stand still.</p>
<p>So, from that we can then assume:</p>
<blockquote><p>
Anything that exists in the physical universe will change.
</p></blockquote>
<p>Now, that might not be so obvious in some respects. <span id="more-18"></span> After all, couldn&#8217;t you just have something vibrate back and forth forever in one space? Well, let&#8217;s ignore that that vibration is &#8220;change&#8221;, because it&#8217;s not really the kind of change I&#8217;m talking about. You have to look at it this way: as soon as a vibrating object strikes another vibrating object, one of the vibrations will change. With enough objects in the universe, change then becomes unavoidable. There are enough objects in this universe (particularly the world we live in every day) that change is thus extremely common and likely. Also, <em>people</em> change things, above and beyond these physical laws.</p>
<p>So, you can guarantee this:</p>
<blockquote><p>
The world around your program is going to change.
</p></blockquote>
<