<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mockery Blog &#187; programming</title>
	<atom:link href="http://getmockery.com/blog/archives/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://getmockery.com/blog</link>
	<description>GetMockery.com company blog - Mockery, UI, and more.</description>
	<lastBuildDate>Sat, 21 Aug 2010 17:32:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>1.1.0 Is Out! What the Hell Took So Long?</title>
		<link>http://getmockery.com/blog/archives/130</link>
		<comments>http://getmockery.com/blog/archives/130#comments</comments>
		<pubDate>Tue, 10 Aug 2010 23:21:55 +0000</pubDate>
		<dc:creator>Joel Anair</dc:creator>
				<category><![CDATA[Site News]]></category>
		<category><![CDATA[Startups]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[advice]]></category>
		<category><![CDATA[anecdotes]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[mistakes]]></category>
		<category><![CDATA[Mockery]]></category>
		<category><![CDATA[not-invented-here]]></category>
		<category><![CDATA[releases]]></category>

		<guid isPermaLink="false">http://getmockery.com/blog/?p=130</guid>
		<description><![CDATA[The moral of the story is this: think very seriously about what you're doing before you set about reimplementing anything non-trivial. You're not just risking the time it takes to re-write what someone else already wrote; you're risking the time it will then take you to integrate what you should have used in the first place. ]]></description>
			<content:encoded><![CDATA[<p>After several months, we released <a title="UI Prototypes and Mockups Made Easy" href="http://getmockery.com">Mockery</a> 1.1.0 last night. There are a lot of big changes:</p>
<ul>
<li>New and much improved rich text widget (based on TinyMCE)</li>
<li>Awesome new data grid editor/builder</li>
<li>Improved look and feel</li>
<li>Much better stability, particularly on Macs and with large documents</li>
</ul>
<p>You&#8217;ll find lots of other fixes and tweaks; it&#8217;s our biggest update yet. But you may wonder why it took nearly 5 months. Well, for me the central character in the story is <a title="Not Invented Here Syndrome" href="http://en.wikipedia.org/wiki/Not_Invented_Here">Not Invented Here Syndrome</a>.</p>
<p>Now, you&#8217;re probably all familiar with this nefarious malady that we developers suffer. In case any of you aren&#8217;t, it&#8217;s a term to describe reluctance to use technologies that were not developed in-house. There are a lot of justifications for it, and <a title="Joel On Software Discussion" href="http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&amp;ixPost=112">it doesn&#8217;t always cause problems</a>, but what is important to consider is that if it bites you, <em>it&#8217;s probably going to bite you twice</em>.</p>
<p>What does that mean? Take the example of Mockery&#8217;s rich text editor control. When we started Mockery, we built what we thought was a robust and powerful editor. Why didn&#8217;t we use a free, open source, off-the-shelf solution? Well, the options we had were mostly web-based, and Mockery isn&#8217;t really a web app, and we were sure we could do a better job&#8230;and so on. At least part of the reasoning was (I&#8217;m sure) that it would be fun to write a WYSIWYG.</p>
<p>It was, and it wasn&#8217;t. But that doesn&#8217;t matter, because either way <em>it was a lot of work.</em> So we stuck it out, but eventually it became clear that we did not have the focus, resources, or motivation to compete with <a title="TinyMCE" href="http://tinymce.moxiecode.com/">TinyMCE</a>. The only answer that made sense was to bite the bullet and just use it. No big deal, right? We&#8217;ll just throw our stuff out and integrate the new stuff, no problem, right?</p>
<p>Unfortunately, we&#8217;d already painted ourselves into a bit of a corner with our own tool. It had features that no off-the-shelf system had, had a different input and output model, fired different events, accepted different commands&#8230;incorporating a 3rd party tool into an existing app is not an easy task.</p>
<p><strong>The moral of the story is this: </strong>think very seriously about what you&#8217;re doing before you set about reimplementing anything non-trivial. You&#8217;re not just risking the time it takes to re-write what someone else already wrote; you&#8217;re risking the time it will then take you to integrate what you should have used in the first place.</p>
<p>I know I&#8217;ll be heeding this advice, and I know <a title="UI Mockups and Prototypes Made Easy" href="http://getmockery.com">Mockery</a> will be much better for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://getmockery.com/blog/archives/130/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Today&#8217;s fun JavaScript trick: switch(true)</title>
		<link>http://getmockery.com/blog/archives/80</link>
		<comments>http://getmockery.com/blog/archives/80#comments</comments>
		<pubDate>Sat, 21 Nov 2009 02:07:55 +0000</pubDate>
		<dc:creator>Joel Anair</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[switch]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://getmockery.com/blog/?p=80</guid>
		<description><![CDATA[Programmers who are new to JavaScript but familiar with other C-syntax languages like C or Java are definitely familiar with the switch statement, but may not be aware of how much more flexible this construct is in JavaScript. In fact, I&#8217;ve heard experienced programmers claim that they never use switch statements!
One major difference in the [...]]]></description>
			<content:encoded><![CDATA[<p>Programmers who are new to JavaScript but familiar with other C-syntax languages like C or Java are definitely familiar with the switch statement, but may not be aware of how much more flexible this construct is in JavaScript. In fact, I&#8217;ve heard experienced programmers claim that they never use switch statements!</p>
<p>One major difference in the JavaScript switch statement  is the fact that the condition can be any type of variable, not just numeric types. Most obviously, this allows you to use a string or an object, which provides a lot of flexibility. So much flexibility, in fact, that when used with a boolean condition the JavaScript switch can provide a very different type of program flow control.</p>
<p>For example, consider a case where we want to take different actions, respectively, if a number is greater than 100, less than -100, or equal to 0. We could write it as a series of if/else ifs, like this:</p>
<pre name="code" class="javascript">if(x &gt; 100) {
    doSomething();
} else if (x &lt; -100){
    doSomethingElse();
} else if (x == 0){
    doAThirdThing();
}</pre>
<p>Using a switch statement, this block becomes:</p>
<pre name="code" class="javascript">switch(true){
    case (x &gt; 100):
        doSomething();
    break;
    case (x &lt; -100):
        doSomethingElse();
    break;
    case (x == 0):
        doAThirdThing();
    break;
}</pre>
<p>Is that any better? Probably not. In fact, it&#8217;s a little more clever, which may make it a little harder for other programmers to maintain, which would actually make it worse. However, consider the case where we want to take a specific action if x is greater than 100 <strong>or</strong> y is greater than 200, <strong>or</strong> z is less than -100, <strong>or</strong> if (x + y + z) is greater than 500. We could write this:</p>
<pre name="code" class="javascript">if(x&gt;100 || y &gt; 200 || z &lt; -100 || (x + y + z) &gt; 500){
    // um, what?
    doSomething();
}</pre>
<p>Using the switch statement, that same code looks like this:</p>
<pre name="code" class="javascript">switch(true){
    case x &gt; 100:
    case y &gt; 200:
    case z &lt; -100:
    case (x + y + z) &gt; 200:
        doSomething();
    break;
}</pre>
<p>I find the second block much more readable. Is it groundbreaking or radically new? No, but this is just another case where the flexibility of JavaScript&#8217;s syntax provides an interesting opportunity for more maintainable, readable code.</p>
]]></content:encoded>
			<wfw:commentRss>http://getmockery.com/blog/archives/80/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A faster horse</title>
		<link>http://getmockery.com/blog/archives/68</link>
		<comments>http://getmockery.com/blog/archives/68#comments</comments>
		<pubDate>Sat, 31 Oct 2009 19:08:18 +0000</pubDate>
		<dc:creator>Joel Anair</dc:creator>
				<category><![CDATA[GUI]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[customers]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[quote]]></category>
		<category><![CDATA[requirements]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://getmockery.com/blog/?p=68</guid>
		<description><![CDATA[“If I’d asked people what they wanted, they would have said a faster horse.”
- Henry Ford
I just heard that quote yesterday from a pretty smart guy, and I really like it. Some people disagree, but I couldn&#8217;t agree more. Sliced Bread Design had a great and very detailed take on it. My favorite bit from [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>“If I’d asked people what they wanted, they would have said a faster horse.”</em></p>
<p><em>- Henry Ford</em></p></blockquote>
<p>I just heard that quote yesterday from <a title="Rob's very interesting blog" href="http://blog.founddrama.net">a pretty smart guy</a>, and I really like it. <a title="An argument against Henry Ford's point" href="http://findsubstance.com/2007/09/10/henry-ford-was-asking-the-wrong-question/">Some people disagree</a>, but I couldn&#8217;t agree more. Sliced Bread Design had <a title="Sliced Bread Design's blog post on Henry Ford's quote" href="http://www.slicedbreaddesign.com/blog/index.php/2009/10/a-faster-horse-when-not-to-listen-to-users/">a great and very detailed take</a> on it. My favorite bit from it:</p>
<blockquote><p>So, what should Henry Ford have been asking his customers? Instead of, “What do you want?” he could have asked, “Is there anything you particularly like or don’t like about your horse and wagon?”</p></blockquote>
<p>You can probably very easily ask someone what software they want you to build, bang out the code, and deliver exactly what they asked for. They might even be really happy with it. But if that&#8217;s all you&#8217;re doing, what separates you from everyone else? What we need to do is break down user requests into desired implementations and desired results.</p>
<h3>Implementations are a means to an end.</h3>
<p>Customers are not going to make clear distinctions in feature requests between desired implementations and desired outcomes. It is up to us to do make that distinction, because <em>if we can come up with a better implementation that produces the same result, we both win</em>. A customer may ask for a dialog, but what he/she&#8217;s really asking for is <em>whatever that dialog lets them do</em>.</p>
<p>Applying this to Henry Ford&#8217;s quote, if we had a customer ask us for a faster horse, we could simply break down the request into implementation and outcome. The desired outcome is fairly clear; <em>get me and my stuff from point a to point b faster</em>. The desired implementation? Some kind of rocket-powered superhorse. The outcome is what the customer is willing to pay for, though; the implementation is merely a suggestion. If you can can come up with a better implementation (and Henry Ford sure did), people will not be disappointed.</p>
<p>As a developer, it&#8217;s easy to become fixated on details; they&#8217;re our bread and butter. That&#8217;s why it&#8217;s important to take a step back when analyzing customer requests and remember that users have exactly the opposite fixation. They&#8217;re willing to work with just about any implementation that lets them accomplish their task. We need to give them what they really <strong>want</strong>, whether or not it&#8217;s what they asked for.</p>
]]></content:encoded>
			<wfw:commentRss>http://getmockery.com/blog/archives/68/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An operator from Groovy that I wish was in JavaScript</title>
		<link>http://getmockery.com/blog/archives/60</link>
		<comments>http://getmockery.com/blog/archives/60#comments</comments>
		<pubDate>Thu, 22 Oct 2009 23:23:05 +0000</pubDate>
		<dc:creator>Joel Anair</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[operators]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://getmockery.com/blog/?p=60</guid>
		<description><![CDATA[First off, keep in mind that I&#8217;ve never used Groovy, just skimmed a couple of language references, but people I know have used it and like it. In case anyone is not familiar, Groovy is a dynamic language implemented on the JavaVM. It&#8217;s commonly used for web development, especially with the Grails framework.
Anyway, having established [...]]]></description>
			<content:encoded><![CDATA[<p>First off, keep in mind that I&#8217;ve never used Groovy, just skimmed a couple of language references, but people I know have used it and like it. In case anyone is not familiar, <a title="Groovy's Wikipedia entry" href="http://en.wikipedia.org/wiki/Groovy_%28programming_language%29">Groovy</a> is a dynamic language implemented on the JavaVM. It&#8217;s commonly used for web development, especially with the Grails framework.</p>
<p>Anyway, having established that I don&#8217;t know much about Groovy, I do know that it has a feature that I really wish we had in JavaScript. It&#8217;s called the <strong>Safe Navigation Operator</strong>, and it&#8217;s represented as ?. in the code. Quoting <a title="The Groovy Reference" href="http://groovy.codehaus.org/Operators#Operators-SafeNavigationOperator%28%3F.%29">the Groovy reference</a>:</p>
<blockquote><p>The Safe Navigation operator is used to avoid a NullPointerException. Typically when you have a reference to an object you might need to verify that it is not null before accessing methods or properties of the object. To avoid this, the safe navigation operator will simply return <tt>null</tt> instead of throwing an exception[.]</p></blockquote>
<p>If it&#8217;s not clear from that, here&#8217;s a real-world example. Let&#8217;s say you have a <strong>customer </strong>object. That object has an optional attribute <strong>address</strong>, which is itself an object, and in turn has <strong>city</strong>, <strong>state</strong>, and <strong>postal code</strong> attributes, which are strings. In JavaScript, you could access the State like this:</p>
<pre name="code" class="js">var state = customer.state.address;</pre>
<p>No problem, but what if the customer object doesn&#8217;t have an address? That line will throw an exception. We can work around it like this:</p>
<pre name="code" class="js">var customerState= customer.state ? customer.state.address : null;</pre>
<p>But if we get deeply nested objects, the syntax gets really muddy. Using Groovy&#8217;s Safe Navigation Operator, we could just do this:</p>
<pre name="code" class="js">var customerState= customer?.state?.address;</pre>
<p>Now, if <strong>customer</strong> is defined, and <strong>state</strong> is defined, and <strong>address</strong> is defined, then <strong>customerState</strong> has the customer&#8217;s state. Otherwise, it contains null. Either way, it never throws an exception, even if none of those objects are defined.</p>
<p>Cases where this could come in handy are data retrieved from deep XML hierarchies, complex nested JSON objects returned by web services, and unpredictable user-entered data.  I&#8217;m sure that if JavaScript supported a similar operator I would use it all the time. Kudos to Groovy&#8217;s designer, Guillaume Laforge.</p>
]]></content:encoded>
			<wfw:commentRss>http://getmockery.com/blog/archives/60/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A couple of useful links regarding shell scripting</title>
		<link>http://getmockery.com/blog/archives/55</link>
		<comments>http://getmockery.com/blog/archives/55#comments</comments>
		<pubDate>Sun, 18 Oct 2009 14:39:36 +0000</pubDate>
		<dc:creator>Joel Anair</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://getmockery.com/blog/?p=55</guid>
		<description><![CDATA[I probably shouldn&#8217;t admit this, but I&#8217;m not any good at shell scripting. It&#8217;s one of a few things I&#8217;m not good at that mean I&#8217;m not a &#8220;real&#8221; programmer (the others being regular expressions and SQL queries&#8230;good thing I&#8217;m into UI). But I have hope that I will get good at shell scripting.
So I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I probably shouldn&#8217;t admit this, but I&#8217;m not any good at shell scripting. It&#8217;s one of a few things I&#8217;m not good at that mean I&#8217;m not a &#8220;real&#8221; programmer (the others being regular expressions and SQL queries&#8230;good thing I&#8217;m into UI). But I have hope that I will get good at shell scripting.</p>
<p>So I&#8217;m pretty psyched that <a title="Stumble Upon" href="http://stumbleupon.com">StumbleUpon</a> came through for me with a couple of useful links related to shell scripting. Here they are. Enjoy!</p>
<p><a title="Basic Shell Scripting Questions" href="http://www.techinterviews.com/basic-shell-scripting-questions">http://www.techinterviews.com/basic-shell-scripting-questions</a></p>
<p><a title="18 Useful bash scripts for web developers" href="http://blog.emson.co.uk/2009/06/18-useful-bash-scripts-for-web-developers/">http://blog.emson.co.uk/2009/06/18-useful-bash-scripts-for-web-developers/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://getmockery.com/blog/archives/55/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
