<?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>Safe from the Losing Fight</title>
	<atom:link href="http://losingfight.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://losingfight.com/blog</link>
	<description>making matt mullenweg regret his role as an enabler</description>
	<lastBuildDate>Fri, 09 Apr 2010 15:14:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom:link rel='hub' href='http://losingfight.com/blog/?pushpress=hub'/>
		<item>
		<title>Tracking iPhone Ads to App Sales</title>
		<link>http://losingfight.com/blog/2010/04/09/tracking-iphone-ads-to-app-sales/</link>
		<comments>http://losingfight.com/blog/2010/04/09/tracking-iphone-ads-to-app-sales/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 15:14:27 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Marketing]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=386</guid>
		<description><![CDATA[When trying to promote your iPhone app it helps to know which efforts are actually producing a result. It&#8217;s little tricky with iPhone apps to know which ads or promotions are converting into actual sales, thanks to the black box that is the App Store. However, it is possible using LinkShare. I found the process [...]]]></description>
			<content:encoded><![CDATA[<p>When trying to promote your iPhone app it helps to know which efforts are actually producing a result. It&#8217;s little tricky with iPhone apps to know which ads or promotions are converting into actual sales, thanks to the black box that is the App Store. However, it is possible using LinkShare. I found the process a little under-documented, so I&#8217;ll describe the necessary steps.</p>
<h2>Step 1: Sign up as an iTunes Affiliate</h2>
<p>First you&#8217;ll need an affiliate account, so go to Apple&#8217;s <a href="http://www.apple.com/itunes/affiliates/">iTunes Affiliates page</a> and click on &#8220;Apply to be an affiliate,&#8221; which will take you to LinkShare. The sign up process asks for your company and website information.</p>
<p>You&#8217;ll need to apply to advertise for &#8220;Apple iTunes.&#8221; I don&#8217;t remember how long it took me to be approved, but I think it was less than 24 hours. They do check the website you provided to make sure it is legit. I have heard that they will reject your application if the website is just a placeholder or if it has trademarked names in the URL, such as &#8220;iPhone.&#8221;</p>
<p>You need a LinkShare account because Apple has provided LinkShare hooks into the App Store so it knows when a click turns into an actual sale. As a bonus you&#8217;ll earn a 5% commission.</p>
<h2>Step 2: Create a LinkShare link for your app</h2>
<p>Next, you&#8217;ll need to create a LinkShare link to your app in the App Store. Using this link will allow LinkShare to magically know if a click turns into a sale.</p>
<p>In LinkShare, select the Links &gt; Deep Linking menu item, and select Apple iTunes as the advertiser. Enter your app&#8217;s iTunes URL in the URL field. Don&#8217;t worry about the U1 Value field right now, you can just leave it blank. Click Create Link and copy the resulting URL.</p>
<p>On your product page, wherever you link to your app in the App Store, use your LinkShare link instead. If you stop here, LinkShare will be able to track how many clicks from your product page result in sales. This is useful in itself, but it would be even better if you could track each promotion separately, and know how many sales a specific ad resulted in.</p>
<p>LinkShare supports ad/promotion tracking through &#8220;signatures&#8221; which is what the U1 Value field above was all about. Signatures are simply a user defined string that are passed to LinkShare via in the <var>u1</var> URL parameter.</p>
<h2>Step 3: Tracking referrers through the product page</h2>
<p>When creating ads or links to your product, you&#8217;ll probably want to direct potential customers to your app&#8217;s product page on your website instead of directly to the App Store. This allows you to provide a video of your app, cross promote other products or services, or actually use HTML formatting. The complication that arises from this is remembering which ad the user clicked on to get to your product page by the time they get to the App Store.</p>
<p>The first step here is to know how the potential customer got to your product page to begin with. The easiest way to do that is to simply add on a URL parameter for the referrer and give each ad or promotion a different parameter value, which we&#8217;ll call a &#8220;signature.&#8221; For example, an ad for Hearts Attack could use this URL:</p>
<p><code></p>
<pre>

http://www.orderndev.com/hearts-attack.html?u1=GAD001
</pre>
<p></code></p>
<p>Here the referrer parameter name is <var>u1</var>, just to be consistent with LinkShare, and the ad signature is GAD001.</p>
<p>Next, you need to get the ad signature passed on to LinkShare. This is done through the <var>u1</var> URL parameter, so you will need to modify any LinkShare URLs on your product page based on the signature parameter. You can do this either server side or client side in JavaScript. Dan Wood talks about <a href="http://www.karelia.com/mac_indie_marketing/track-your-new-customers-wi.html">how to track referrers server side</a> for Mac apps, and his examples can be modified to work here. I chose to modify the LinkShare URLs client side using JavaScript. The basic algorithm is:</p>
<ol>
<li>Check for the <var>u1</var> URL parameter. If it exists save it off into a cookie.</li>
<li>Check for the signature cookie. If it exists, append &#8220;&amp;u1=<var>signature</var>&#8221; to the LinkShare URLs.</li>
</ol>
<p>At the bottom of my product page, I have code that looks like this:</p>
<p><code></p>
<pre>
	&lt;script type="text/javascript"&gt;
		saveParameterInCookie('u1', 'hearts-attack-src');
		restoreCookieToParameterInAnchor('u1', 'hearts-attack-src', 'buy-link');
		restoreCookieToParameterInAnchor('u1', 'hearts-attack-src', 'app-store-link');
	&lt;/script&gt;
</pre>
<p></code></p>
<p>The first line saves the URL parameter named <var>u1</var> into a cookie named &#8216;hearts-attack-src.&#8217; The next two lines update anchor tags in the HTML by appending the value of the signature cookie as an URL parameter. The second line says: update the &#8216;buy-link&#8217; anchor tag by taking the contents of the &#8216;hearts-attack-src&#8217; cookie as the value for the &#8216;u1&#8242; parameter and appending it to the anchor tag&#8217;s URL. </p>
<p>Here&#8217;s the code for implementing saveParameterInCookie and restoreCookieToParameterInAnchor:</p>
<p><code></p>
<pre>
function getURLParameter(name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&amp;]"+name+"=([^&amp;#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null)
		return null;
	else
		return results[1];
}

function addParameterToURL(url, name, value) {
	if ( value == null )
		return url;
	return '' + url + '&amp;' + name + "=" + value;
}

function saveParameterInCookie(parameterName, cookieName) {
	var parameter = getURLParameter(parameterName);
	if ( parameter == null )
		return;

	createCookie(cookieName, parameter, 180);
}

function restoreCookieToParameterInAnchor(parameterName, cookieName, anchorName) {
	var cookie = readCookie(cookieName);
	if ( cookie == null )
		return;

	link = document.getElementById(anchorName);
	link.href = addParameterToURL(link.href, parameterName, cookie);
}
</pre>
<p></code></p>
<p>Hopefully the code is self-explanatory. It relies on functions createCookie and readCookie, which I got from <a href="http://www.quirksmode.org/js/cookies.html">this article on JavaScript cookies</a>. I should also point out I am not a professional JavaScripter, so there may be bugs in the code. I make no guarantees about this code.</p>
<p>As complicated as all that might have seemed, you are now tracking potential customers from your ads or promotions, to your product page, to the App Store where LinkShare knows if they are actually buying or not.</p>
<h2>Step 4: Tracking the performance of ads or promotions</h2>
<p>The final step is viewing the results of your ad or promotion in LinkShare. LinkShare will be able to tell you how many visitors actually made it to the App Store, and how many of those actually bought something. To know how many visitors an ad or promotion is driving to your product page, you&#8217;ll need to use something like <a href="http://www.haveamint.com/">Mint</a> or <a href="http://www.google.com/analytics/">Google Analytics</a>.</p>
<p>In LinkShare select the Reports &gt; Advanced Reports menu item. Select the &#8220;Signature Activity&#8221; report type, and click View Report. You&#8217;ll get a table that looks like this:</p>
<p><img src="/blog/wp-content/uploads/2010/04/linkshare-sales.png" alt="linkshare-sales.png" border="0" width="393" height="111" /></p>
<p>The Member ID column is where your ad or promotion signature will show up. It will be whatever you pass to LinkShare via the <var>u1</var> URL parameter. It also shows how many clicks the link got, and how much sales it generated. As you can see, my ads aren&#8217;t doing so hot, but at least I know that now.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2010/04/09/tracking-iphone-ads-to-app-sales/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launching Hearts Attack, An iPhone Game</title>
		<link>http://losingfight.com/blog/2010/04/08/launching-hearts-attack-an-iphone-game/</link>
		<comments>http://losingfight.com/blog/2010/04/08/launching-hearts-attack-an-iphone-game/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 19:03:55 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Marketing]]></category>
		<category><![CDATA[Order N]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=383</guid>
		<description><![CDATA[The first week of sales for Hearts Attack finished up earlier this week. It was a typical first week for an iPhone app; that is, a large spike of sales followed by a rapid crash to nothing. Here&#8217;s a graphic illustrating this:

Oops, sorry, wrong graphic. I meant this one:

Hmmm&#8230; not much difference really. As you [...]]]></description>
			<content:encoded><![CDATA[<p>The first week of sales for <a href="http://www.orderndev.com/hearts-attack.html?u1=LFIGHT">Hearts Attack</a> finished up earlier this week. It was a typical first week for an iPhone app; that is, a large spike of sales followed by a rapid crash to nothing. Here&#8217;s a graphic illustrating this:</p>
<p><img src="/blog/wp-content/uploads/2010/04/car-crash.jpg" alt="Car Crash" border="0" width="455" height="342" /></p>
<p>Oops, sorry, wrong graphic. I meant this one:</p>
<p><img src="/blog/wp-content/uploads/2010/04/first-week-sales.png" alt="First Week Sales Graph" border="0" width="444" height="322" /></p>
<p>Hmmm&#8230; not much difference really. As you can see I actually sold nothing on Sunday. Apparently everyone was interpreting &#8220;day of rest&#8221; as &#8220;don&#8217;t buy any iPhone apps today.&#8221;</p>
<p>This article is kind of a postmortem for the launch of Hearts Attack. I attempted a few different things in order to drum up sales. Some were more successful than others.</p>
<ul>
<li>
<p>One of the things I did before the launch was some search engine optimization on the Hearts Attack product page. <a href="http://twitter.com/danwood">Dan Wood</a> of <a href="http://www.karelia.com/">Karelia</a> has some <a href="http://www.karelia.com/mac_indie_marketing/eleven_really_useful_free_m.html">good resources on how to do SEO</a>.</p>
<p>I was fairly pleased with the results. The product page ended up on the first results page for a few of the keywords I was targeting. It could be better, but not bad for a PageRank amateur such as myself.</p>
</li>
<li>
<p>On the day of launch, I issued a <a href="/blog/2010/03/30/hearts-attack-1-0-announced-fun-card-game-for-the-iphone/">press release</a> through <a href="http://prmac.com">prMac</a>. I opted for their &#8220;extended press release&#8221; which sends the press release the same day and to more people. It&#8217;s only $20 so it&#8217;s low risk.</p>
<p>I did see a couple of obvious benefits from this. The first benefit is &#8220;link juice&#8221; to the Hearts Attack product page and our company website in general. I had done some SEO earlier and discovered the biggest thing we were in need of was links. This helped immensely with that.</p>
<p>Secondly, I mentioned in the press release that promotional codes were available upon request. Only three people ever asked for them, but I happily gave them away. I have not seen any reviews as a result, but hopefully at least I garnered some good will among reviewers.</p>
<p>Speaking of reviewers, one thing I did not have ready at launch, that I should have, was a press kit. I kept mine simple in that it just contains screenshots and images of the app icon. I should have linked to it in the press release and product page, because it was something the reviewers immediately asked for.</p>
<p>It terms of how many sales were made because of the press release, I don&#8217;t know. It did noticeably increase traffic to our site, but I didn&#8217;t have <a href="http://www.apple.com/itunes/affiliates/">LinkShare</a> hooked up at the time, so I don&#8217;t know how many of those visitors became customers.</p>
</li>
<li>
<p>I wrote about Hearts Attack here and tweeted about it. I both published my own press release and then followed up with the story about Hearts Attack came about.</p>
<p>This drove a decent amount of traffic to our website, and resulted in a few sales from my friends and other people who follow me on Twitter. Like the press release, it also helped with the &#8220;link juice&#8221; of our website.</p>
</li>
<li>
<p>I asked my wife, Elaine, to write about it on Facebook since she has approximately 30 bazillion friends on there and I have none. Some say this is because I haven&#8217;t even created an account, but I think Facebook is just being stuck up.</p>
<p>Anywho, this didn&#8217;t create much traffic, but it did create a couple of sales from friends who follow Elaine on Facebook, but not me on Twitter.</p>
</li>
</ul>
<p>Of course the biggest driver of sales is being listed at the top in the App Store, which by default is sorted by the release date. Unfortunately being at the top is fated to be temporary, and I could easily tell when I fell down the list by looking at my sales.</p>
<p>In summary, I learned: I should have had LinkShare up and running to begin with so I could properly track conversions and know what approach is the most successful as far as sales. Second, I should have a press kit ready at launch and linked to it from the press release.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2010/04/08/launching-hearts-attack-an-iphone-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Story of Hearts Attack</title>
		<link>http://losingfight.com/blog/2010/03/30/the-story-of-hearts-attack/</link>
		<comments>http://losingfight.com/blog/2010/03/30/the-story-of-hearts-attack/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 22:30:31 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Order N]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=379</guid>
		<description><![CDATA[I&#8217;ve already posted the press release for Hearts Attack, but I thought I&#8217;d share a little about how Hearts Attack came about.
Way back in 2008 the original iPhone SDK came out, and I, like a lot of people, was excited about developing apps for the iPhone. My company is primarily a software development services company [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve already posted the <a href="/blog/2010/03/30/hearts-attack-1-0-announced-fun-card-game-for-the-iphone/">press release for Hearts Attack</a>, but I thought I&#8217;d share a little about how <a href="http://www.orderndev.com/hearts-attack.html">Hearts Attack</a> came about.</p>
<p>Way back in 2008 the original iPhone SDK came out, and I, like a lot of people, was excited about developing apps for the iPhone. My company is primarily a <a href="http://www.orderndev.com">software development services company</a> so I was mainly interested in learning the SDK so we could pick up iPhone contracts in addition to Mac ones. It also happens to be the case that my favorite card game is hearts, so I decided a good way to learn the iPhone SDK was to write my own hearts game. </p>
<p>After a couple of weeks I had the basic functionality implemented, and noticed I was playing it a lot. I realized then that I could probably make this into a product. Furthermore, releasing an iPhone app through the App Store seemed like a good way for us as a company to begin making the transition from a services based company to a product based one.</p>
<p>If I was going to release Hearts Attack as a published app, I knew the UI and presentation had to be greatly improved. I went through a lot of mockups for the main playing view, including one where everyone&#8217;s cards &mdash; all 52 of them &mdash; were always visible somewhere on the table (a truly horrible idea). Unfortunately I don&#8217;t seem to have most of the mockups around anymore, but I found a couple which you can see below. (See the <a href="http://www.orderndev.com/hearts-attack.html">product page</a> for the end result.)</p>
<table>
<tr>
<td><a href="/blog/wp-content/uploads/2010/03/HorizontalLayout.jpg"><img src="/blog/wp-content/uploads/2010/03/HorizontalLayout.jpg" alt="HorizontalLayout.jpg" border="0" width="240" height="160" /></a></td>
<td><a href="/blog/wp-content/uploads/2010/03/VerticalLayout.jpg"><img src="/blog/wp-content/uploads/2010/03/VerticalLayout.jpg" alt="VerticalLayout.jpg" border="0" width="160" height="240" /></a></td>
</tr>
<tr>
<td><a href="/blog/wp-content/uploads/2010/03/VerticalLayout3.jpg"><img src="/blog/wp-content/uploads/2010/03/VerticalLayout3.jpg" alt="VerticalLayout3.jpg" border="0" width="160" height="240" /></a></td>
<td><a href="/blog/wp-content/uploads/2010/03/HorizontalLayout3.jpg"><img src="/blog/wp-content/uploads/2010/03/HorizontalLayout3.jpg" alt="HorizontalLayout3.jpg" border="0" width="240" height="160" /></a></td>
</tr>
</table>
<p>The biggest challenge I had was fitting everything on the screen and it still being legible and usable. By trial and error I figured out how small I could make the cards and still make them tappable, as well as their optimal position to make them accessible with one hand.</p>
<p>I began thinking about what would make Hearts Attack unique or different from its competitors. Back then there were literally just two iPhone hearts games in the App Store, and I felt pretty confident that what I had was already better than them, but I wanted to be sure. I decided on: oddball talking computer opponents, a tutorial that gave not only card suggestions but the rationale behind the choice (a pet peeve of mine), and multiple undo support for mis-taps and tactical errors.</p>
<p>The last step was to get professionals to do the sound and graphics. I ended up hiring a sound designer, a graphics designer, and a character illustrator. The <a href="/blog/2008/12/13/experiences-with-a-sound-designer/">sound design went smoothly</a>, but getting the graphics done was a lot more involved than I anticipated, which is another story for another day. Jordan of <a href="http://onetoad.com">OneToad Design</a> created the app icon, playing backgrounds, and the special card backgrounds for the queen of spades and jack of diamonds. Lara Kehler did the character illustrations, which turned out great.</p>
<p>Unfortunately, Hearts Attack went on hiatus in early 2009. I was working full time on an iPhone contract, and simply didn&#8217;t have a lot of time to put into Hearts. Secondly, I had lost all desire in finishing it. It was becoming increasingly apparent that iPhone users didn&#8217;t want to pay more than $0.99 for anything, despite <a href="/blog/2008/11/15/how-to-price-your-iphone-app-out-of-existence/">all the whining I did about it</a>. I convinced myself it wasn&#8217;t worth releasing Hearts because it would never make back the money it cost us to make. Hearts stayed dormant for an entire year.</p>
<p>A couple of months ago, I decided to pick Hearts Attack back up again. I had the time and, as someone pointed out to me, it would never make money if I didn&#8217;t release it. I was tempted to update the app to the latest SDK (I started Hearts back before you could even use nibs on the iPhone) and add some features. I decided against this, because I really just wanted to ship it. I did have to update it to the 2.2.1 SDK because the current Xcode tools no longer ship with the 2.0 SDK.</p>
<p>Instead I focused on fixing the bugs and adding polish. Fortunately for me my wife happens to be a professional software tester with iPhone experience, so I got lots of good bugs to fix. I also prepared a press release, created a website, and otherwise got ready for the release. After I felt the app was stable enough, I submitted it to Apple on Friday. It was approved on Monday.</p>
<p>At this point, I&#8217;m still not convinced I&#8217;ll ever make back the money we spent on sound and graphic designers. A hearts card game simply is never going to be a big seller, and price point isn&#8217;t high enough to make up for that. Right now, I&#8217;m tending to think pessimistically about sales, but I&#8217;m going to do what I can to drum up sales and see how things go. </p>
<p>It&#8217;s a &#8220;wait and see&#8221; situation as to if we develop any more iPhone applications to sell ourselves. Of course, regardless of how well Hearts Attack does, we&#8217;d be <a href="http://www.orderndev.com/hire.html">happy to develop your iPhone app</a> for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2010/03/30/the-story-of-hearts-attack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hearts Attack 1.0 Announced &#8211; Fun Card Game for the iPhone</title>
		<link>http://losingfight.com/blog/2010/03/30/hearts-attack-1-0-announced-fun-card-game-for-the-iphone/</link>
		<comments>http://losingfight.com/blog/2010/03/30/hearts-attack-1-0-announced-fun-card-game-for-the-iphone/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 15:13:33 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Order N]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=375</guid>
		<description><![CDATA[Dallas, TX &#8211; Order N Development today announces Hearts Attack 1.0 for the iPhone and iPod touch. Hearts Attack allows users to play any of the common variations of the hearts card game, such as omnibus, shooting the sun, and spot hearts against a variety of zany computer opponents. Hearts Attack includes a full in-game [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Dallas, TX</strong> &#8211; <a href="http://www.orderndev.com">Order N Development</a> today announces <a href="http://www.orderndev.com/hearts-attack.html">Hearts Attack 1.0</a> for the iPhone and iPod touch. Hearts Attack allows users to play any of the common variations of the hearts card game, such as omnibus, shooting the sun, and spot hearts against a variety of zany computer opponents. Hearts Attack includes a full in-game tutorial, suggestions, and multiple level undo, allowing beginners to easily pick up the game. It provides four difficulty levels to challenge even experienced players.</p>
<p>The player competes against three of seven possible colorful computer opponents, each of which has their own distinct looks and personality. The personalities range from a communist kitten trying to overthrow oppressive humans to a vegetarian vampire to a pacifist pirate who sells insurance. They always have something interesting to say about how they and their opponents are playing. The computer opponents can be configured to play at trivial, easy, normal, or hard difficulty levels.</p>
<p>Unique to Hearts Attack is its in-depth tutorial system. The tutorial begins by giving the player a brief introduction to the rules and strategies of hearts. Throughout the game it offers suggestions for which cards to pass or play, including the rationale for choosing those cards. The suggestions are useful to beginners learning how to play, and to more advanced players looking to improve their game. The suggestions can be used apart from the tutorial.</p>
<p>Since players always have their favorite way of playing hearts, Hearts Attack allows flexible configuration of the rules. Players can choose how cards are passed, which player leads and with what card, how penalty and bonus cards are scored, and what is required to shoot the moon or the sun.</p>
<h3>Device Requirements</h3>
<ul>
<li>iPhone or iPod touch</li>
<li>Requires iPhone OS 2.2.1 or later</li>
<li>4.7 MB</li>
</ul>
<h3>Pricing and Availability</h3>
<p>Hearts Attack 1.0 is $2.99 (USD) and available exclusively through the App Store in the Games category. <a href="http://www.orderndev.com/support.html">Review copies are available upon request.</a></p>
<h3>Links</h3>
<ul>
<li><a href="http://www.orderndev.com">Order N Development, LLC</a></li>
<li><a href="http://www.orderndev.com/hearts-attack.html">Hearts Attack 1.0</a></li>
<li><a href="http://itunes.apple.com/us/app/hearts-attack/id364674253?mt=8">Purchase and Download</a></li>
</ul>
<h3>Company Information</h3>
<p>Order N Development, LLC is a software engineering company providing contracting services for the Macintosh, iPhone, and iPad platforms. Order N Development was founded in 2002 in Dallas, TX by a small band of experienced Mac developers. Copyright 2002-2010 Order N Development, LLC. All Rights Reserved. Apple, and the Apple logo are registered trademarks of Apple Computer in the U.S. and/or other countries.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2010/03/30/hearts-attack-1-0-announced-fun-card-game-for-the-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Distributed Version Control and Other Religions</title>
		<link>http://losingfight.com/blog/2010/03/22/distributed-version-control-and-other-religions/</link>
		<comments>http://losingfight.com/blog/2010/03/22/distributed-version-control-and-other-religions/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 07:07:30 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Writing]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=371</guid>
		<description><![CDATA[Lately it seems there&#8217;s been a lot of talk about distributed version control systems &#8212; especially git and Mercurial &#8212; and how they&#8217;re the bee&#8217;s knees or possibly even the cat&#8217;s pajamas.
But at the risk of having my programmer&#8217;s license revoked, I have to confess I don&#8217;t really care about version control systems. I mean, [...]]]></description>
			<content:encoded><![CDATA[<p>Lately it seems there&#8217;s been a lot of talk about distributed version control systems &mdash; especially <a href="http://git-scm.com/">git</a> and <a href="http://mercurial.selenic.com/">Mercurial</a> &mdash; and how they&#8217;re the bee&#8217;s knees or possibly even the cat&#8217;s pajamas.</p>
<p>But at the risk of having my programmer&#8217;s license revoked, I have to confess I don&#8217;t really care about version control systems. I mean, I think it&#8217;s important to use version control, but I don&#8217;t get all excited about the latest ideas in version control technology or the newest VCS on the block. It&#8217;s just a tool. It keeps versions of all my code, and allows me to revert to previous versions, see when and how things changed, and collaborate with other programmers working in the same codebase. Beyond that I don&#8217;t much care.</p>
<p>The tools don&#8217;t make the programmer.</p>
<p>What&#8217;s new with DVCS is the proponents seem to think they need to evangelize their system. Unfortunately they rather suck at it, and their arguments usually leave me feeling that I don&#8217;t want to use software used by such jerks, on account that it might make me into a jerk. Or at least a bigger one.</p>
<p>However, I do think that a DVCS can be a really useful tool so I&#8217;ve come up with some suggestions for those wanting to effectively evangelize their favorite version control system, or at least annoy me less when they talk.</p>
<ol>
<li>
<h2>Don&#8217;t be condescending or insulting</h2>
<p>I think it&#8217;s part of human nature &mdash; or at least programmer nature &mdash; to assume you&#8217;re the smartest guy in the room, and think that anyone who disagrees with you is a real buffon. Programmers seem to take great pleasure in showing that the other person is an idiot, or didn&#8217;t know something they did, or is at least not as clever as they are. A lot of arguments for git or Mercurial seem to revolve around explaining how git or Mercurial are so clearly superior that only morons would use something else.</p>
<p>While this works great for rallying the troops, it&#8217;s counterproductive when trying to win someone over to your side.</p>
<p>Think of it this way: suppose someone comes to your door to tell you about their religion. During the discussion they are self righteous and condescending; they don&#8217;t listen to your arguments, but are only interested in proving that they&#8217;re right. Are you likely to be swayed to believe in their religion? If you&#8217;re like the other hairless bipedal mammals inhabiting this planet you won&#8217;t be, even if they had some valid points.</p>
<p>As soon as you become insulting or condescending, your arguments will be rejected out of hand. I know this will upset some programmers because they believe if you show your argument is superior, everyone will accept it. But that&#8217;s not the way people work.</p>
</li>
<li>
<h2>Try to be helpful</h2>
<p>The best way to introduce someone to your DVCS is by trying to help them. Not in the &#8220;I have all the answers&#8221; way, but in the &#8220;I&#8217;ve dealt with that before, and here&#8217;s what I did&#8221; kind of way. People <em>will</em> run into the kinds of problems that DVCS are good at solving. When they do, you can helpfully suggest a solution.
<p>However, some care should be taken so the suggestion doesn&#8217;t come off the wrong way.</p>
<table>
<tr>
<th>Wrong</th>
<th>Right</th>
</tr>
<tr>
<td>Dude, why are you using subversion?</td>
<td>I&#8217;ve run into that problem before. I solved it by using feature X of git/hg in this way.</td>
<tr>
<td>Dude, just use git/hg.</td>
<td>You smell nice.</td>
</tr>
</table>
<p>Be aware that people may not know where their pain points are. I&#8217;ve seen customers jump through some excruciating hoops to get a piece of software to do something when there was an easier way. People get used to pain and begin to assume it&#8217;s normal. If you notice something like that, even if they&#8217;re not complaining about it, you can politely suggest a better way.</p>
<p>Instead of a list of features that a DVCS provides or abstract arguments as to why they should be using it, people respond better to concrete examples of how a piece of software can make their lives better. People are also more responsive when they know you&#8217;re on their side, trying to help them, even if they don&#8217;t &mdash; or currently can&#8217;t &mdash; take your suggestion. Keep in mind switching VCS in the middle of product cycle is likely something most people can&#8217;t do.</p>
<p>The right attitude is that of trying to help a friend, not conquer an enemy.</p>
</li>
<li>
<h2>Be willing to answer questions, even dumb ones</h2>
<p>Distributed version control works differently from centralized version control, and it does require a different way of thinking. I know I was confused by it when I first started looking into it. A lot of tutorials jump into the mechanics of how to perform certain tasks, but rarely talk about the philosophy of the system or why things are the way they are. If you want to successfully persuade people that your DVCS is the best then you need to be willing to do a lot of patient education.</p>
<p>I say &#8220;patient&#8221; because after using centralized version control they might have difficulty switching over to a new mental model. Or they might have heard a lot of <a href="http://en.wikipedia.org/wiki/Fear,_uncertainty_and_doubt">FUD</a> about your DVCS that you need to put to rest. It&#8217;s important to do this patiently, respectfully, and not insultingly because they&#8217;ve picked up misinformation or don&#8217;t immediately &#8220;get it&#8221; like you do. Otherwise they might ignore your DVCS so they don&#8217;t have to deal with people who look down on them because they don&#8217;t &#8220;get it.&#8221;</p>
</li>
<li>
<h2>Make it trivial to install and use</h2>
<p>This seems like a no brainer, but it is an important part of any software. If it&#8217;s hard to try out and use your DVCS, it simply won&#8217;t get used. I think that for the most part both git and Mercurial succeed in this respect. My only complaint is neither has a good Mac GUI client. Contrast that with Subversion which has both <a href="http://versionsapp.com/">Versions</a> and <a href="http://www.zennaware.com/cornerstone/">Cornerstone</a> on the Mac. You shouldn&#8217;t underestimate the draw of an easy to use, beautiful GUI.</p>
</li>
</ol>
<p>I think <a href="http://www.joelonsoftware.com/">Joel Spolsky</a> has given the best example of how to properly promote and evangelize a DVCS. He wrote a blog post &mdash; <a href="http://www.joelonsoftware.com/items/2010/03/17.html">Distributed Version Control is here to stay, baby</a> &mdash; about how he came to learn and use DVCS. It&#8217;s well written, and instead of condescending, he&#8217;s actually humble and admits he was wrong about DVCS to begin with. Joel also created a site called <a href="http://hginit.com">HgInit</a> that does an amazing job of explaining the philosophy behind Mercurial and gives a solid introduction to right way to use it. It&#8217;s actually the site that convinced me to start using Mercurial for real.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2010/03/22/distributed-version-control-and-other-religions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redesigning a Software Contractor&#8217;s Website</title>
		<link>http://losingfight.com/blog/2010/03/05/redesigning-a-software-contractors-website/</link>
		<comments>http://losingfight.com/blog/2010/03/05/redesigning-a-software-contractors-website/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 07:50:17 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Order N]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=366</guid>
		<description><![CDATA[It&#8217;s been about eight years since our company website has had a major redesign. But that changed today. 
The old design  simply wasn&#8217;t meeting our needs. Specifically:

It didn&#8217;t communicate clearly what exactly we do here.
It had a search box which, as far as I can tell, didn&#8217;t, and has never, worked.
It had several pages [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been about eight years since <a href="http://orderndev.com">our company website</a> has had a major redesign. But that changed today. </p>
<p>The <a href="http://web.archive.org/web/20070523020320/http://www.orderndev.com/">old design </a> simply wasn&#8217;t meeting our needs. Specifically:</p>
<ul>
<li>It didn&#8217;t communicate clearly what exactly we <em>do</em> here.</li>
<li>It had a search box which, as far as I can tell, didn&#8217;t, and has never, worked.</li>
<li>It had several pages describing services we don&#8217;t perform, at least not when a cop is around. Some of these pages just had boilerplate text in them. e.g. &#8220;Item 1&#8243;, &#8220;Item 2&#8243;, etc</li>
<li>The visual design was really old and unprofessional. The new is at least not old.</li>
<li>The old feedback form demanded a lot of extraneous information like title, company, telephone number, home address, when you shower, etc.</li>
<li>It had a copyright date at the bottom of 2002, which caused people to ask: &#8220;Are you guys still in business?&#8221; This was apparently a barrier to them sending us money.</li>
</ul>
<p>Fortunately, we mainly rely on word of mouth to get clients, but a bad website certainly doesn&#8217;t help our business. We could be missing out on clients who find our website, but don&#8217;t contact us for any of the reasons listed above.</p>
<p>I&#8217;ve recently had some time between contracts, which I used to think about how a software contractor&#8217;s website should be structured and what kind of information it should present. Also, I slept in late a lot. I came to some conclusions:</p>
<ul>
<li>It should immediately obvious to a visitor what the company does, no matter what page they land on.</li>
<li>It should have a portfolio so the visitor can see what kind of work we have done in the past, and see if that matches up with what they want done at the quality level they want.</li>
<li>A brief description of services that we do provide, explained in layman&#8217;s terms.</li>
<li>It should be obvious and easy to get in touch with us. The form for submitting a message should have as few requirements as possible.</li>
<li>It should contain a brief overview of the company, and the people in it. It should put a human face to the company.</li>
<li>Noon really is not a bad time to wake up.</li>
</ul>
<p>I also decided to add a page for products, mainly for future use.</p>
<p>Overall the project was a fun &mdash; and hopefully financially rewarding &mdash; exercise. It was interesting to think about what would induce a visitor to stick around on our site, and then actually contact us. I&#8217;m not sure if I got it completely right, but it&#8217;s at least a step in the right direction.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2010/03/05/redesigning-a-software-contractors-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling OpenCL Kernels with Xcode</title>
		<link>http://losingfight.com/blog/2009/12/17/compiling-opencl-kernels-with-xcode/</link>
		<comments>http://losingfight.com/blog/2009/12/17/compiling-opencl-kernels-with-xcode/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 23:49:44 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=358</guid>
		<description><![CDATA[The talk I&#8217;m working on for NSConference 2010 involves a decent amount of OpenCL kernel code. Originally, I thought I would develop the kernel code the same way I develop Core Image kernel code: build the kernel in Quartz Composer and then copy paste the code into Xcode when I got it working. 
Unfortunately, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>The talk I&#8217;m working on for <a href="http://www.nsconference.com">NSConference 2010</a> involves a decent amount of OpenCL kernel code. Originally, I thought I would develop the kernel code the same way I develop Core Image kernel code: build the kernel in Quartz Composer and then copy paste the code into Xcode when I got it working. </p>
<p>Unfortunately, I&#8217;ve not had much luck with Quartz Composer in way of meaningful compiler errors. Sometimes it returns good errors, sometimes inscrutable ones.</p>
<div align="center">
<a href="/blog/wp-content/uploads/2009/12/QuartzComposer1.png"><img src="/blog/wp-content/uploads/2009/12/QuartzComposer1.png" alt="Quartz Composer" border="0" width="259" height="320" /></a></p>
<div style="font-size:0.7em;">Composer: Wait, wait, I remember this&#8230; it&#8217;s COBOL, right?</div>
</div>
<p>&nbsp;</p>
<p>However, I&#8217;ve found debugging OpenCL kernels to be much easier thanks to the invention of a function I like to call &#8220;printf.&#8221; If you run your kernel on the CPU, then you can print out values just like in C. With debugging solved, I just needed to figure out how to find compiler errors without having to run my code.</p>
<p>Unlike Core Image, OpenCL actually requires you to compile your kernel code explicitly before using it. The API&#8217;s required to do this will return nice compiler error messages and everything. The obvious thing to do would be wrap up these API&#8217;s in a command line tool and invoke the tool from Xcode, which is what I did.</p>
<h2>The Code</h2>
<p>You can download the Xcode project for <a href="/blog/wp-content/uploads/2009/12/clc.zip" title="clc.zip">clc, the OpenCL Compiler here</a>. It requires Mac OS X 10.6 Snow Leopard and the associated Xcode tools. To install, just build the project and copy the resulting binary into your path somewhere. I used ~/bin.</p>
<p>Most of the code is self explanatory, with the possible exception of the output. Unlike most compilers, clc doesn&#8217;t output object code because the host and runtime CPU/GPU&#8217;s could easily be different. It could simply copy the source code as is for the output, but that was a little too obvious for my tastes. Instead clc compresses the source code and stuffs it into a binary plist. It has the slight benefit of potentially being smaller on disk, and making your source code negligibly less accessible to prying eyes, if you&#8217;re into that sort of thing.</p>
<p>There are definite possibilities for improvement. For example, there could be an option to encrypt the source code to be more &#8220;secure.&#8221; Or it could store the binary code generated by the host machine in the output on the chance that the host and runtime machines have the same hardware.</p>
<h2>Setting up Xcode</h2>
<p>To use clc, you&#8217;ll need to set up a build rule in your app&#8217;s target settings to run all OpenCL source files through it. Selecting the menu item Project &gt; Edit Active Target, and then selecting the Rules tab, should land you here:</p>
<p><img src="/blog/wp-content/uploads/2009/12/TargetSettings.png" alt="TargetSettings.png" border="0" width="577" height="306" /></p>
<p>Add another rule, set it to process OpenCL source files using a Custom script. For the custom script enter:</p>
<p><code>~/bin/clc ${INPUT_FILE_PATH} -o ${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/Contents/Resources/${INPUT_FILE_BASE}.clar</code></p>
<p>Finally, you&#8217;ll need to tell Xcode where you&#8217;re putting the output file, which is:</p>
<p><code>${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/Contents/Resources/${INPUT_FILE_BASE}.clar</code></p>
<p>By default, Xcode won&#8217;t put OpenCL source files (.cl) into the target, meaning they won&#8217;t get compiled. For each of your OpenCL source files<br />
you&#8217;ll need to explicitly add them to your target. There are several ways to do this, but the easiest is probably selecting all of them, and doing a Get Info (File &gt; Get Info). Switch to the Targets tab and check the target they should be compiled into.</p>
<h2>Runtime Code</h2>
<p>At runtime, it&#8217;s pretty easy to retrieve the original OpenCL source code using the <var>+ (NSString *) openCLSourceWithData:(NSData *)data error:(NSError **)error;</var> method on <var>ONOpenCLArchive</var>. However, there are a couple of convenience methods on NSBundle that makes retrieving the kernel easier. For example:</p>
<p><code></p>
<pre>
#import "ONOpenCLArchive.h"

NSString *kernelSource = [[NSBundle mainBundle] openCLResource:@"MyKernel"];
</pre>
<p></code></p>
<p>That&#8217;s pretty much all there is to it.</p>
<h2>Conclusion</h2>
<p>Although not ground breaking, this little tool has certainly been helpful to me by finding compiler errors at compile time instead of runtime. Hopefully it will be useful to other people as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2009/12/17/compiling-opencl-kernels-with-xcode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NSConference 2010 Quiz</title>
		<link>http://losingfight.com/blog/2009/12/15/nsconference-2010-quiz/</link>
		<comments>http://losingfight.com/blog/2009/12/15/nsconference-2010-quiz/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 03:49:44 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=347</guid>
		<description><![CDATA[For the uninformed, NSConference is a Mac developer&#8217;s conference put on by Scotty &#8220;The Scottster&#8221; Scott and his faithful sidekick, Tim &#8220;The Faithful Sidekick&#8221; Isted. They&#8217;re kind of the Batman and Robin of the Mac programming conference world, but have a slightly lower probability of bat-gassing you than the real dynamic duo.
This year they aren&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>For the uninformed, <a href="http://www.nsconference.com">NSConference</a> is a Mac developer&#8217;s conference put on by Scotty &#8220;The Scottster&#8221; Scott and his faithful sidekick, Tim &#8220;The Faithful Sidekick&#8221; Isted. They&#8217;re kind of the Batman and Robin of the Mac programming conference world, but have a slightly lower probability of bat-gassing you than the real dynamic duo.</p>
<p>This year they aren&#8217;t content with bringing conference justice to only the UK, so they&#8217;re branching out to the good &#8216;ole U.S. of A. by way of Atlanta, GA. To help you decide which conference you should attend, US or Europe, I&#8217;ve prepared the following quiz:</p>
<ol>
<li>
<p>What is your opinion of Seattle?</p>
<ol>
<li>It&#8217;s nice, but isn&#8217;t nearly rainy or dreary enough.</li>
<li>I like their coffee.</li>
<li>The residents have too many teeth.</li>
</ol>
</li>
<li>
<p>Describe your driving habits</p>
<ol>
<li>I like to drive on the left side of the road.</li>
<li>I like to drive on both sides of the road.</li>
<li>I like to merge right six lanes without signaling while going 147 mph on the off ramp and giving the finger with both hands in my black Camaro.</li>
</ol>
</li>
<li>
<p>The pinnacle of human achievement is&#8230;</p>
<ol>
<li><a href="http://en.wikipedia.org/wiki/Tea_(meal)">Afternoon tea</a></li>
<li>Sliced bread</li>
<li><a href="http://en.wikipedia.org/wiki/Hee_Haw">Hee Haw</a></li>
</ol>
</li>
</ol>
<p>Scoring: Give yourself -1 points for any <strong>1</strong> answer, 0 points for any <strong>2</strong> answer, and 1 point for any <strong>3</strong> answer.</p>
<p>If you scored is less than zero, you should attend NSConference Europe; if greater than zero, NSConference USA. If you scored exactly zero, you are truly a cultured individual and should attend both.</p>
<p>Personally, I&#8217;ll be attending both, and not just because of peer pressure and insightful quizzes. I&#8217;ll be presenting a talk on how to implement a watercolor brush using Core Image and OpenCL and maybe some duct tape. If you enjoy the graphics articles that I post here, you&#8217;ll probably enjoy my presentation. If not, I hear Steve &#8220;I&#8217;m Batman&#8221; Scott does a mean <a href="http://en.wikipedia.org/wiki/Adam_West">Adam West</a> impression.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2009/12/15/nsconference-2010-quiz/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Implementing AppleScript Recordability</title>
		<link>http://losingfight.com/blog/2009/11/02/implementing-applescript-recordability/</link>
		<comments>http://losingfight.com/blog/2009/11/02/implementing-applescript-recordability/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 05:13:59 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=340</guid>
		<description><![CDATA[For one of my side projects that I&#8217;m currently working on, I decided to implement an AppleScript interface. Designing and implementing one wasn&#8217;t that bad, although Apple&#8217;s AppleScript documentation was sometimes confusing. Fortunately, CocoaDev has a good overview on how to implement AppleScript support.
However, one of my frustrations with working with other app&#8217;s AppleScript interfaces [...]]]></description>
			<content:encoded><![CDATA[<p>For one of my side projects that I&#8217;m currently working on, I decided to implement an AppleScript interface. Designing and implementing one wasn&#8217;t <em>that</em> bad, although <a href="http://www.red-sweater.com/blog/195/we-need-a-hero">Apple&#8217;s AppleScript documentation was sometimes confusing</a>. Fortunately, CocoaDev has a good <a href="http://www.cocoadev.com/index.pl?HowToSupportAppleScript">overview on how to implement AppleScript support</a>.</p>
<p>However, one of my frustrations with working with other app&#8217;s AppleScript interfaces was trying to figure out how the interface was intended to be used. Sure, the AppleScript Editor would show me all the actions and classes, but it isn&#8217;t always obvious how things are supposed to fit together. Something that would help in these cases is AppleScript recording. I could record the app performing the actions I cared about, then examine how the app itself used the actions and classes. Unfortunately, it seems like only the Finder and <a href="http://www.barebones.com/products/bbedit/">BBEdit</a> ever got around to implementing AppleScript recording.</p>
<p>In the hopes of increasing the number of apps with AppleScript recordability, I&#8217;m going to document my approach to implementing it. For brevity, I&#8217;ll assume you&#8217;ve already an AppleScript interface implemented for your Cocoa app.</p>
<h2>Thinking Big Design Thoughts</h2>
<p>If you have an AppleScript interface for your application, you may think of your app architecture as something like this:</p>
<p><img src="/blog/wp-content/uploads/2009/11/TraditionalModel1.png" alt="Traditional Model for Implementing AppleScript" width="301" height="246" /></p>
<p>Here your AppleScript interface and graphical interface are independent peers, and both modify your model classes directly to accomplish your application&#8217;s tasks. Each interface is separate and largely ignorant of the other.</p>
<p>However, when implementing AppleScript recordability it is helpful to think about your app&#8217;s architecture in a different way:</p>
<p><img src="/blog/wp-content/uploads/2009/11/RecordableModel1.png" alt="Recordable Model for Implementing AppleScript" width="300" height="294" /></p>
<p>In this case the GUI is dependent on, and implemented in terms of, the AppleScript interface. The general guideline is that anything the GUI does that mutates or alters the model goes through the AppleScript interface. However, if the GUI simply needs to access or get information from the model, it would go directly to the model, not through the AppleScript interface. Accessing the model can happen at seemingly random times to the user, and spamming the AppleScript Editor with these accesses when recording only confuses the user.</p>
<p>Suppose an application has table view and a button that deletes the currently selected item in that table view. The table view data source would be implemented the standard way, simply going directly to the model, bypassing the AppleScript layer. However, the delete button, since it alters the model, would be implemented by invoking the AppleScript delete command on the object represented by the current table row.</p>
<p>This design has some other benefits besides recordability. Notably it helps test your AppleScript interface design and implementation. If you find that implementing a GUI feature in terms of your AppleScript interface is impossible or difficult, congratulations, you found a bug! Also, merely testing your GUI also exercises your AppleScript interface. It is not a replacement for testing your AppleScript interface explicitly, but it certainly helps.</p>
<h2>Implementation Hardships</h2>
<p>Everything I&#8217;ve talked about so far hasn&#8217;t been all that novel, and probably has been met with large bucket fulls of &#8220;well, duh&#8221;s by anyone who&#8217;s ever looked into implementing AppleScript recording. The problem isn&#8217;t thinking about how to design in recordability, but actually implementing recordability.</p>
<p>As things stand now, doing something as simple as &#8220;invoking the AppleScript delete command on the object represented by the current table row&#8221; is incredibly involved and painful. You have to manually build up the AppleEvent that represents the delete command and the target model object using functions like <var>AEBuildAppleEvent</var> or classes like <var>NSAppleEventDescriptor</var>. Then you have to remember to target your app by specifying the kCurrentProcess process serial number (specifying kCurrentProcess as the ProcessSerialNumber is currently the only way to enable recording. Bundle identifiers, urls, and pid_t&#8217;s do not work.), and parse the AppleEvent you get back into something useful. You&#8217;d have to do this for <strong>every</strong> property or method on your model object you want exposed for recordability.</p>
<h3>Dreaming of Ponies</h3>
<p>The thing is, the Cocoa runtime has a lot of the AppleScript information from your SDEF file at its disposal and could theoretically generate these interfaces for you. In the ideal hypothetical situation, invoking the delete action via AppleScript inside your app could be as simple as:</p>
<p><code></p>
<pre>
// Suppose ONEmployee is our model object, with the appropriate AppleScript interface implemented
ONEmployee *employee = [_employees objectAtIndex:0];
ONEmployeeASProxy *proxy = employee.appleScriptInterface;
[proxy delete];
</pre>
<p></code></p>
<p>Here, any object that implemented the <var>objectSpecifier</var> method for AppleScript support would automatically get an <var>appleScriptInterface</var> property. The object returned by <var>appleScriptInterface</var> would be a proxy object implementing the same methods and properties as the original object. The proxy object would implement these methods by building up the appropriate AppleEvents, sending them, and parsing the resulting event back into a usable object.</p>
<p>Apple actually gets tantalizingly close to this with the Scripting Bridge. Outside users of your app can run your SDEF file through the <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/sdp.1.html">sdp</a> command line tool and get a nice Objective-C interface of proxy objects that build, send, and parse AppleEvents to and from your app. However, there is not currently a way tell these proxy objects to target kCurrentProcess, or to initialize one of the proxy objects by passing in a model object that implements <var>objectSpecifier</var>. (I&#8217;ve written this up as <a href="rdar://problem/7359646">rdar://problem/7359646</a>.)</p>
<h3>Harsh Reality</h3>
<p>Since I didn&#8217;t want to wait on Apple to extend the Scripting Bridge to make my life easier, I decided to write a couple of classes to help out. You can <a href="/blog/wp-content/uploads/2009/11/ASObject.zip" title="ASObject.zip">download the code here</a>. The code is under the <a href="/blog/2007/09/05/license-for-sample-code/">MIT license</a>.</p>
<p>The classes work similar to the <var>SBObject</var> and <var>SBElementArray</var> classes in the Scripting Bridge framework. Using these classes, you can invoke the delete AppleScript method like so:</p>
<p><code></p>
<pre>
// Suppose ONEmployee is our model object, with the appropriate AppleScript interface implemented
ONEmployee *employee = [_employees objectAtIndex:0];
[ASObj(employee) invokeCommand:@"delete"];
</pre>
<p></code></p>
<p>The <var>ASObj</var> function creates an <var>ASObject</var> proxy object for any NSObject that implements <var>objectSpecifier</var>. <var>invokeCommand</var> takes care of marshalling the parameters into an AppleEvent, sending it, and unmarshalling the return value into an NSObject. The name of the command is the name of the name used in AppleScript, not the Cocoa implementation.</p>
<p><var>invokeCommand</var> can take parameters, although it gets more tricky:</p>
<p><code></p>
<pre>
ONEmployee *employee = [_employees objectAtIndex:0];
[ASObj(employee) invokeCommand:@"giveRaise" with:[NSNumber numberWithInt:10], @"Percent", nil];
</pre>
<p></code></p>
<p>First, the parameters must be named (it&#8217;s not done by parameter order), and those names must match the Cocoa Key in the SDEF, not the user visible parameter name. Second, the marshalling code (from random NSObjects to AppleEvents) is a bit sparse. I&#8217;ve only added code for the types I needed for my project. If you use it, you may need to add support for other types. The same goes for return values; I only added support for the types that I use.</p>
<p><var>ASObject</var> also has support for properties. For example this marks an employee as exempt:</p>
<p><code></p>
<pre>
ONEmployee *employee = [_employees objectAtIndex:0];
[ASObj(employee) setObject:[NSNumber numberWithBool:YES] forProperty:@"isExempt"];
</pre>
<p></code></p>
<p>The same type restrictions for parameters apply to properties as well. The Cocoa Key for the property must be used here, the same as parameters.</p>
<p>Elements also have basic support, which is where the <var>ASElementArray</var> comes in. Right now the only interesting thing to do with an element array is retrieve a reference to a specific element:</p>
<p><code></p>
<pre>
ONEmployee *employee = [_employees objectAtIndex:0];
ASObject *dependent = [[ASObj(employee) elementForKey:@"dependents"] objectAtIndex:0];
[dependent setObject:[NSNumber numberWithBool:YES] forProperty:@"insured"];
</pre>
<p></code></p>
<p>Unlike other methods, <var>ASElementArray</var>&#8217;s <var>objectAtIndex</var> does not execute an AppleEvents or otherwise take any actions. Instead it constructs an object specifier (i.e. an ASObject) for the given element.</p>
<p>The code is still somewhat rough and incomplete, but should help with anyone wanting to implement AppleScript recording. If nothing else, it should serve as a starting point or sample code for anyone rolling their own solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2009/11/02/implementing-applescript-recordability/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Contracting talk from C4[2]</title>
		<link>http://losingfight.com/blog/2009/09/22/contracting-talk-from-c42/</link>
		<comments>http://losingfight.com/blog/2009/09/22/contracting-talk-from-c42/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 03:49:17 +0000</pubDate>
		<dc:creator>andy</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Contracting]]></category>
		<category><![CDATA[Order N]]></category>

		<guid isPermaLink="false">http://losingfight.com/blog/?p=216</guid>
		<description><![CDATA[In preparation for C4[3], Wolf has put up videos of the talks from C4[2], including the one I did on contracting. Hopefully someone will find it useful.

]]></description>
			<content:encoded><![CDATA[<p>In preparation for <a href="http://rentzsch.com/c4/threeOpen">C4[3]</a>, <a href="http://rentzsch.com/">Wolf</a> has put up <a href="http://rentzsch.com/c4/c42VideosAvailable">videos of the talks from C4[2]</a>, including the one I did on contracting. Hopefully someone will find it useful.</p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="545" height="429" id="viddler_7b6bf318"><param name="movie" value="http://www.viddler.com/simple/7b6bf318/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/simple/7b6bf318/" width="545" height="429" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_7b6bf318"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://losingfight.com/blog/2009/09/22/contracting-talk-from-c42/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.504 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 23:55:42 -->
