<?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>klauskomenda.com &#187; Programming</title>
	<atom:link href="http://www.klauskomenda.com/archives/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klauskomenda.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 14 Dec 2011 23:58:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Boost the performance of your mobile web app using YUI Compressor</title>
		<link>http://www.klauskomenda.com/archives/2011/12/14/boost-the-performance-of-your-mobile-web-app-using-yui-compressor/</link>
		<comments>http://www.klauskomenda.com/archives/2011/12/14/boost-the-performance-of-your-mobile-web-app-using-yui-compressor/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 23:58:03 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=1069</guid>
		<description><![CDATA[This article describes how to reduce HTTP requests by integrating YUI Compressor into Xcode build settings.]]></description>
			<content:encoded><![CDATA[<p>From well established <a href="http://developer.yahoo.com/performance/rules.html">web performance guidelines</a>, we learned a few years ago that it has certain enhancing effects to the performance of a website if the number of <a href="http://en.wikipedia.org/wiki/Http"><abbr title="Hypertext Transfer Protocol">HTTP</abbr></a> requests made to external assets is reduced and their content is stripped of any unnecessary characters or content. This is commonly referred to as concatenation and minification of, in our case, JavaScript and CSS files. Knowing that byte size and HTTP requests matter even more on mobile devices, the following article attempts to explain how to achieve such performance boost using <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> in an Xcode project. </p>
<p>While working on version 2 of <a href="/apps/bikenav/">BikeNav</a>, I attempted to make some improvements not only to the app itself, but also to my development and build environment. Streamlining the process of minification was one of the goals I had in mind. The following step-by-step guide illustrates how I integrated YUI Compressor into the BikeNav Xcode project, which in itself is a <a href="http://phonegap.com/">PhoneGap</a> project. Nevertheless, this can be applied to any mobile web application that stores assets (HTML, CSS and JavaScript) on the device itself.</p>
<h2>Step 1: Download YUI Compressor</h2>
<p>Obviously we need to <a href="http://yuilibrary.com/download/yuicompressor/">download</a> YUI Compressor first. After downloading and extracting the ZIP file, we end up with a folder <span class="code">yuicompressor-[version-number]</span>. I decided to copy that folder into my iOS project folder into a directory <span class="code">tools</span>, that I had created earlier. The final path to the YUI Compressor folder would be:</p>
<pre><code>/Users/komenda/Documents/PhoneGapApps/BikeNav2/tools/yuicompressor-2.4.2</code></pre>
<h2>Step 2: Create a Shell Script File</h2>
<p>Since YUI Compressor only handles minification for us, we need to make sure that our JavaScript and CSS files are concatenated into one file each before fed to the Compressor. Also, in order to include this step into the iOS build process, we need to point the build settings to some file it can execute. I decided to create another folder in my iOS project directory called <span class="code">scripts</span> in which I created a shell script called <span class="code">bikenav_build.sh</span> which will hold the shell commands to concat the files first and then call YUI Compressor to minify them.</p>
<pre><code>$ pwd
/Users/komenda/Documents/PhoneGapApps/BikeNav2/scripts
$ ls -l
total 8
-rwxrwxrwx@ 1 komenda  _lpoperator  1098 Nov  8 15:51 bikenav_build.sh</code></pre>
<h2>Step 3: The Build Script</h2>
<h3>rsync</h3>
<p>In order to be able to do development in the browser before pushing anything on to the iOS Simulator or the device, I had set up my dev environment in such a way that I am serving all the BikeNav code from within my local Apache DocumentRoot (since there is no server-side processing involved, Apache is not even necessary, but because I store all my other projects in there as well, it keeps things nice and tidy). The path and folder structure looks like this:</p>
<pre><code>$ pwd
/Users/komenda/Webroot/BikeNav
$ ls -l
total 264
drwxr-xr-x  18 komenda  _lpoperator     612 Nov  8 16:35 audio
drwxr-xr-x   5 komenda  _lpoperator     170 Oct 24 17:11 css
drwxr-xr-x  27 komenda  _lpoperator     918 Oct 29 16:46 img
-rw-r--r--   1 komenda  _lpoperator   12497 Nov  8 17:48 index.html
drwxr-xr-x  13 komenda  _lpoperator     442 Nov  8 15:49 js
-rw-r--r--   1 komenda  _lpoperator  116575 Aug 17 17:33 phonegap-1.0.0.js</code></pre>
<p>Once I reach a certain point during development where I feel it is time to try things out on simulator or device, I sync this directory with the <span class="code">www</span> directory inside the iOS/PhoneGap project. A great tool to do this is rsync, which already comes with Mac OSX. The following command is how I run rsync when working on BikeNav (from inside the <span class="code">scripts</span> directory in the iOS project). For details on rsync command line options please refer to the <a href="http://www.samba.org/ftp/rsync/rsync.html">documentation</a>.</p>
<pre><code>rsync -avz --exclude 'index.html' --delete ~/Webroot/BikeNav/ ../www/</code></pre>
<p>This is also the first thing I put into the <span class="code">bikenav_build.sh</span> script:</p>
<pre><code>#!/bin/bash

echo "Custom BikeNav build script"
echo "==========================="

echo "Step 1: rsync files from web directory"

rsync -avz --exclude 'index.html' --delete ~/Webroot/BikeNav/ ../www/</code></pre>
<h3>Concatenation</h3>
<p>As mentioned above, we need to concatenate our JavaScript and CSS files into one single file each before passing it on to the YUI Compressor for minification. For this, we simply use the Unix <span class="code">cat</span> command like so:</p>
<pre><code>cat ../www/js/one.js ../www/js/two.js ../www/js/three.js &gt; ../www/js/combined.js
cat ../www/css/one.css ../www/css/two.css &gt; ../www/css/combined.css</code></pre>
<p>These two commands create two new files, <span class="code">combined.js</span> and <span class="code">combined.css</span>, each holding the contents of the JavaScript and CSS files, respectively. With that, we are now ready to give the YUI Compressor something to&#8230;well&#8230;compress.</p>
<h3>Minification</h3>
<p>Now we can send YUI Compressor to work to give us a nicely minified JavaScript and CSS files:</p>
<pre><code>java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/js/bikenav.min.js ../www/js/combined.js
java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/css/bikenav.min.css ../www/css/combined.css</code></pre>
<p>This will create <span class="code">bikenav.min.js</span> and <span class="code">bikenav.min.css</span> in their respective directories, based on the concatenated files created in the previous step. With some additional output and commenting as well as deleting the concatenated files after minification (since we don&#8217;t need them any more after that) the final <span class="code">bikenav_build.sh</span> script looks like this:</p>
<pre><code>#!/bin/bash

echo "Custom BikeNav build script"
echo "==========================="

echo "Step 1: rsync files from web directory"

rsync -avz --exclude 'index.html' --delete ~/Webroot/BikeNav/ ../www/

echo "Step 2: minify JavaScript and CSS files"

echo "=== JavaScript ==="
echo "concatinating files"

cat ../www/js/one.js ../www/js/two.js ../www/js/three.js &gt; ../www/js/combined.js

echo "minifying files"

java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/js/bikenav.min.js ../www/js/combined.js

echo "removing combined.js"

rm ../www/js/combined.js

echo "=== CSS ==="
echo "concatinating files"
cat ../www/css/one.css ../www/css/two.css &gt; ../www/css/combined.css

echo "minifying files"

java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/css/bikenav.min.css ../www/css/combined.css

echo "removing combined.css"

rm ../www/css/combined.css</code></pre>
<h2>Step 4: Integration into iOS Build Settings</h2>
<p>Now that we got our build script ready, we need to integrate it into the build process of our project in Xcode. The following instructions are based on the Xcode 4 user interface. </p>
<ol>
<li>After opening the project, make sure that the &#8220;Project Navigator&#8221; view is selected</li>
<li>Select the top level project, in my case it would be BikeNav</li>
<li>In the project editor window, select the target, BikeNav in my case</li>
<li>Select &#8220;Build Phases&#8221;</li>
<li>In the lower right corner, select the + sign labeled &#8220;Add Build Phase&#8221; and select &#8220;Add Run Script&#8221;</li>
</ol>
<p>After going through these steps, a new bar in the sequence of Build Phases will show up labeled &#8220;Run Script&#8221;. Because we want to run our build script before any data is copied onto the simulator or device, we need to move it up in the sequence (I put it right after &#8220;Target Dependencies&#8221;). Now we only need to specify the path to the build script and how to run it. Therefor, in the text area inside that &#8220;Run Script&#8221; phase, I put the following:</p>
<pre><code>cd /Users/komenda/Documents/PhoneGapApps/BikeNav2/scripts
./bikenav_build.sh</code></pre>
<p>For better illustration, have a look at this <a class="lightbox" title="Custom Build Script integration" href="http://www.klauskomenda.com/wp-content/uploads/2011/12/xcode_800.png">screenshot</a>, showing how that &#8220;Build Phase&#8221; section should look like after you added our build script.</p>
<h2>Step 5: Testing</h2>
<p>To test whether everything works correctly, build and run your project either on the iOS Simulator or an actual device. To verify that the script is being run, select the &#8220;Log Navigator&#8221; in the Xcode UI and then &#8220;Build [Projectname]&#8221; in the left sidebar. In the &#8220;Build target [projectname]&#8221; section in the log output you should see an entry &#8220;Run custom shell script &#8216;Run Script&#8217;&#8221;, which should show the familiar commenting messages we put in the shell script.</p>
<p>As a sidenote, of course in order to use the minified files, these need to be properly referenced in the <span class="code">index.html</span> of your project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/12/14/boost-the-performance-of-your-mobile-web-app-using-yui-compressor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BikeNav: My first iPhone App</title>
		<link>http://www.klauskomenda.com/archives/2011/04/29/bikenav-my-first-iphone-app/</link>
		<comments>http://www.klauskomenda.com/archives/2011/04/29/bikenav-my-first-iphone-app/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 05:35:04 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bicycle]]></category>
		<category><![CDATA[bike]]></category>
		<category><![CDATA[cycling]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[sports]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=922</guid>
		<description><![CDATA[I am giving some insights into the decisions that went into building BikeNav, my first iPhone application, using jQuery Mobile and PhoneGap. ]]></description>
			<content:encoded><![CDATA[<p>I have been intrigued by mobile application development ever since working on <a href="http://www.amazon.com/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X">my thesis</a> in 2006. Lots of time has passed and so much has changed since then. 5 years back, I had to revert to <a href="http://en.wikipedia.org/wiki/J2me">J2ME</a> to get an application working on a Nokia <a href="http://en.wikipedia.org/wiki/Series_60">Series 60</a> phone. These days, I can use <a href="http://en.wikipedia.org/wiki/HTML5">HTML5</a> (in conjunction with <a href="http://www.phonegap.com/">PhoneGap</a>) to deploy a native-like application to the Apple App Store to offer it on the iPhone market. However, it was important to me to pick an application that I would use personally and so I came up with <a href="http://www.klauskomenda.com/apps/bikenav/">BikeNav</a>, the route planner for your next bike ride to work, to shop for groceries or to visit a friend. </p>
<h2>What is it?</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/04/bikenav_logo.png" alt="" title="bikenav_logo" width="147" height="147" class="img-right" />I really like to use my bike as a clean way of transportation but when going from A to B by bike, it is especially vital in car-dominated USA to pick a route that preferably has some sort of bike lane in order for the cars to give you some space or where the speed limit is at a reasonable level (i.e. residential streets). The native map application on the iPhone already has routing functionality built in for public transport, walking and when driving with your car, but not for biking. Interestingly though, the desktop version of <a href="http://maps.google.com/">Google Maps</a> has this functionality (<a href="http://google-latlong.blogspot.com/2010/03/its-time-to-bike.html">launched in March 2010 for several cities in the US and Canada</a>). So in order to fill this gap, I had the idea for BikeNav, which uses this Google Maps functionality to give the user the most bicycle friendly route from A to B. </p>
<p>Further details about the features of the application as well as screenshots can be found on the <a href="http://itunes.apple.com/us/app/bikenav/id428665758">App Store</a> as well as on my <a href="http://www.klauskomenda.com/apps/bikenav/">support page</a>. Below I will focus more on an overview of the technical implementation of the application.</p>
<h2>The Tech</h2>
<p>After looking into Objective-C and native iPhone development, it became clear to me rather quickly that I should stay with what I am good at, meaning web development technologies. Objective-C as well as how all the different pieces fit together in XCode was just hugely confusing, which made me decide that if I can somehow use web technologies to achieve what I want then I am certainly going to go for that <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<h3>jQuery Mobile</h3>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/04/jquery_mobile_logo.png" alt="" title="jquery_mobile_logo" width="293" height="101" class="img-left" />I had to do some research at work on Mobile JavaScript Frameworks and looked into two of them that got mentioned quite a lot: <a href="http://jquerymobile.com/">jQuery Mobile</a> and <a href="http://www.sencha.com/products/touch/">Sencha Touch</a>. I had never really worked with jQuery and Sencha was completely new to me, but looking at jQuery Mobile, I realized that it might give me more freedom than Sencha with regards to being able to easily style and access the interface elements that I needed for the application. The only downside I could see was that, at the time, it was in Alpha 1 release, indicating that there might still be some bugs (which turned out to be true and I had to work around them while developing). As of this writing, jQuery Mobile is now in <a href="http://jquerymobile.com/blog/2011/04/07/jquery-alpha-4-1-maintenance-release/">Alpha 4.1</a>.</p>
<h3>PhoneGap</h3>
<p><img width="293" height="109" class="img-right" alt="" src="http://www.klauskomenda.com/wp-content/uploads/2011/01/phonegap_logo.jpg">Because I wanted to deploy my application on the Apple App Store, I had to find a way to somehow turn my mobile application into a native(-like) app. PhoneGap to the rescue. PhoneGap gives the developer the ability to wrap a web application (written in HTML, CSS and JavaScript) into a native shell that gives it the needed characteristics in order to push it to the App Store, the same way as you would if it were an Objective-C application. In addition, PhoneGap provides a JavaScript bridge, that lets you access native device capabilities (i.e. access to the contact list on the device) from within your application using JavaScript.</p>
<h2>Lessons learned and &#8220;What&#8217;s next?&#8221;</h2>
<p>Initially I made the decision to go with jQuery Mobile because I felt it would give me more flexibility with regards to being able to easily build up my interface elements, since the framework lets you build a mobile web app very much the same way you would build a web site or web app for the desktop. With Sencha Touch, it seemed that it would have been more difficult to come up with a non-standard interface (like I wanted to use) for my app, since all the control is in JavaScript, with very few things defined in HTML and CSS. Alternatively, I probably could have used <a href="http://www.appcelerator.com/products/titanium-mobile-application-development/">Titanium</a> as well, but again, I felt it would have been more of a challenge to get the positioning and styling of all the elements the way I wanted it&mdash;since Titanium also has an &#8216;all JavaScript&#8217; approach. </p>
<h3>Adopting early has its downsides</h3>
<p>As I mentioned earlier, the slight downside to using jQuery Mobile was (and still is) that it was in an early Alpha release. I actually started developing with Alpha 1, meanwhile it is in Alpha 4.1. I only tried to upgrade once, about half-way through development, and noticed that lots of things had been broken by the update. So I reverted back to Alpha 1, and worked my way around the bugs and the missing features that just weren&#8217;t there at the time. Since I would like to also offer the application on Android phones at some point, I need to upgrade eventually, but I think I will wait until the framework is at least out of its Alpha state. </p>
<h3>Bridging the gap</h3>
<p>I am, however, very pleased so far with PhoneGap. Getting it installed was easy and building the application out of XCode code is very straight forward as well. All I had to do was copy my HTML, CSS, JavaScript and image files into the www folder of the project and hit &#8216;build &#038; run&#8217;. Granted, I am not using the PhoneGap JavaScript bridge in this application to access native device features (yet) and I also haven&#8217;t used PhoneGap for building BikeNav for Android (yet), so there might be potential hurdles to overcome in this regard. But from what I have seen so far, the combination of jQuery Mobile and PhoneGap works very well for me. </p>
<p>In terms of new features, I would love to do some research on what options there are (if any) to do &#8216;text to speech&#8217; in JavaScript (for reading out driving directions) as well as integration of <a href="http://en.wikipedia.org/wiki/Google_Street_View">Google Street View</a> images into the application. If you like to bike (and you own an iPhone and live in the US or Canada), I would certainly encourage you to download it, try it out and <a href="http://www.klauskomenda.com/contact/">give me feedback</a>! Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/04/29/bikenav-my-first-iphone-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Map API Showdown</title>
		<link>http://www.klauskomenda.com/archives/2011/01/21/the-map-api-showdown/</link>
		<comments>http://www.klauskomenda.com/archives/2011/01/21/the-map-api-showdown/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 02:10:00 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[map api]]></category>
		<category><![CDATA[ovi maps]]></category>
		<category><![CDATA[yahoo maps]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=881</guid>
		<description><![CDATA[Three and a half years after I had last looked in detail at the big Map APIs, I felt it was time for another look at the current Map API landscape.]]></description>
			<content:encoded><![CDATA[<p>In an <a href="/archives/2007/07/22/google-maps-api-vs-yahoo-maps-api/">article I published more than 3.5 years ago</a> (my god, time is flying), I compared the states of the <a href="http://code.google.com/apis/maps/">Google</a> and <a href="http://developer.yahoo.com/maps/">Yahoo Maps APIs</a>, particularly looking at their geocoding capabilities and performance. A lot of time has passed since then and I felt it is time to assess the Map API landscape once again, this time bringing two new players to the game: <a href="http://www.microsoft.com/maps/developers/web.aspx">Bing Maps API</a> (by <a href="http://www.microsoft.com/">Microsoft</a>) and <a href="http://api.maps.ovi.com/">Ovi Maps API</a> (by <a href="http://www.nokia.com/">Nokia</a>). I will not go into as much detail as with my old post, but rather trying to convey how each API &#8216;feels&#8217; (regarding ease-of-use, documentation etc.) from a developers point of view.</p>
<blockquote class="pullquote appear-right">
<p class="pullquote">
Kamarov: Give me a stopwatch and a map, and I&#8217;ll fly the Alps in a plane with no windows.
</p>
<p>
<cite>from <a href="http://www.imdb.com/title/tt0099810/">The Hunt for Red October</a></cite>
</p>
</blockquote>
<p>While there are great posts out there that look at the <a href="http://www.41latitude.com/post/2072504768/google-maps-label-readability">visual appearance of the map imagery and their readability</a> the topic of this post are the APIs themselves, their capabilities and features and how easy they are to use from a developers perspective. I have put together <a href="http://www.klauskomenda.com/lab/map-api-showdown/">a little side-by-side comparison</a>, inspired by <a href="http://www.sergeychernyshev.com/maps.html">Sergey Chernychev&#8217;s work</a>, to see how common tasks can be performed with the different APIs.</p>
<h2>Ovi Maps API</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/ovi.jpg" alt="" title="ovi" width="293" height="186" class="img-left" /><a href="http://www.ovi.com/">Ovi</a>, Nokia&#8217;s brand for their internet services, opened up its Ovi Maps API and their documentation just recently, in <a href="http://blogs.forum.nokia.com/blog/nokia-developer-news/2010/12/23/ovi-maps-api">December 2010</a>. The API documentation consists of a <a href="http://api.maps.ovi.com/devguide/index.html">Developer&#8217;s Guide</a>, <a href="http://api.maps.ovi.com/playground2/playground.html">Maps API Playground</a> and <a href="http://api.maps.ovi.com/apireference/index.html">API Documentation</a>. The Developer&#8217;s Guide gives a short overview over the API and its capabilities with little code snippets. The aim of the API Playground is to give the developer an interactive interface to play around with code examples and edit code on the fly and see how it impacts the behavior of the example. Finally, the API documentation lists the class hierarchy and methods available for the developer as part of the API.</p>
<p>While I can see the good intentions of providing that API Playground, I actually believe it does more harm than good. For me personally, the way Ovi presents these examples and then having to click on a &#8220;code&#8221; button to see the code (without being able to easily do &#8220;view source&#8221;), is frankly, quite annoying. Also, there are not that many examples to begin with, compared to <a href="http://code.google.com/apis/maps/documentation/javascript/examples/index.html">what Google Maps offers</a>. I feel that having separate, distinct URLs for each example (as opposed to a sophisticated JavaScript-heavy interface), where you can do &#8220;view source&#8221; and easily follow what is going on, is much more helpful. Additionally, compared to how many classes and functions are available in the API documentation, this is, by no means, reflected in the examples. There is also no search functionality in the API docs, which makes them quite cumbersome to use.</p>
<p>With regards to the code, I noticed that upon instantiation of the Ovi map, the developer has to add the zoom control as well as the map type selector (for map, satellite and terrain view) in additional steps in the code, as well as the actual ability for the user to drag the map. I feel like these should come by default when instantiating the map. </p>
<pre><code>// instantiate the map
ovimap = new ovi.mapsapi.map.Display(Y.Node.getDOMNode(Y.one('#ovimap')), {
    zoomLevel: mapOptions.zoom,
    center: [mapOptions.lat, mapOptions.lng]
});

//add direct mouse interaction
ovimap.components.add(new ovi.mapsapi.map.component.Behavior());

//add the zoom bar
ovimap.components.add(new ovi.mapsapi.map.component.ZoomBar());

// add map type selector (for map, satellite and hybrid view)
ovimap.components.add(new ovi.mapsapi.map.component.TypeSelector()); </code></pre>
<p>I also encountered a weird behavior, which I feel is a bug: when zooming into the map, either by double-clicking with the mouse or using the zoom control, the zoom control disappears (at least in my comparison example). But I would attribute that to the fact that this API is very new and I would think this will be fixed soon. Looking at the playground, Ovi Maps seems to offer some interesting features in addition to standards like <a href="http://api.maps.ovi.com/playground2/playground.html?example=20">routing</a>, <a href="http://api.maps.ovi.com/playground2/playground.html?example=7">placement of markers</a>, <a href="http://api.maps.ovi.com/playground2/playground.html?example=12">rendering geo shapes</a> and <a href="http://api.maps.ovi.com/playground2/playground.html?example=41">exposing map events</a> in JavaScript. Included in the API are the abilities to <a href="http://api.maps.ovi.com/playground2/playground.html?example=25">render SVG and text inside a graphics context</a> (which might just be an abstraction layer to native SVG capabilities in the browser), as well as an <a href="http://api.maps.ovi.com/playground2/playground.html?example=24">abstraction layer for canvas</a> (at least I believe that is what this is). </p>
<p>The quality of the imagery is not that outstanding, however, the satellite images Ovi has for Europe are much better than what, e.g. Google offers. You can see for yourself if you search for Helsinki <a href="http://www.klauskomenda.com/lab/map-api-showdown/">in my comparison example</a> and zoom in to the max on both the Google and the Ovi Map.</p>
<h3>Resources</h3>
<ul>
<li><a href="http://api.maps.ovi.com/">Ovi Maps API</a></li>
<li><a href="http://api.maps.ovi.com/playground2/playground.html">Ovi Maps API Playground</a></li>
<li><a href="http://api.maps.ovi.com/apireference/index.html">Ovi Maps API documentation</a></li>
</ul>
<h2>Yahoo Maps API</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/yahoo.png" alt="" title="yahoo" width="293" height="42" class="img-left" />The <a href="http://developer.yahoo.com/maps/">Yahoo Maps API</a> has not received an update for quite a while, the version I had included in my old post was 3.4, the most current one is 3.8. Besides the <a href="http://developer.yahoo.com/maps/ajax/">Ajax API</a>, Yahoo Maps still offers the <a href="http://developer.yahoo.com/flash/maps/">Flash version</a> (although one could argue how useful this still is, considering how powerful JavaScript has become in recent years), as well as a <a href="http://developer.yahoo.com/maps/rest/V1/">REST API</a> for requesting <a href="http://gws.maps.yahoo.com/mapimage?MAPDATA=8Z8wped6wXWCiOAsIjnwUKLbMhPVbCoQ6JDLHQzxjKI43Ol1yV_R91BqMW2iaH_DsVmFvJBHRzPdbTeXZQ7QTLJ_LCXhW_WfjZk94iEDERqpTYCHw8FE0UfTG3lvwBGPUggmzSx0jMjpq.gPw8tkyIY-&#038;mvt=m&#038;cltype=onnetwork&#038;.intl=us&#038;appid=YD-bGrhXEw_JXyniyYzf1l6_NzPNWbPu6Ey5Q--&#038;oper=&#038;_proxy=ydn,xml">static map images</a> (great for non-JS solutions) and <a href="http://developer.yahoo.com/maps/georss/">support for GeoRSS</a>. </p>
<p>The landing page for the Ajax API documentation has a lot of copy &#038; paste examples right there, including a small description and <a href="http://developer.yahoo.com/maps/ajax/V3.8/example/controls.html">a unique URL to display the full example</a>. They also offer a bunch of cheat sheets, which I personally don&#8217;t use because they get outdated quickly (I&#8217;d rather have good up-to-date online documentation with explanatory examples and well-structured API docs). You can download the examples plus the cheat sheets <a href="http://developer.yahoo.com/maps/ajax/V3.8/yahoo_maps_ajax_api_reference_bundle.zip">bundled together in one zip file</a> to explore on your own machine.</p>
<p>The <a href="http://developer.yahoo.com/maps/ajax/V3.8/index.html">actual API documentation</a> is, by far, not as fancy as Ovi&#8217;s, but it somehow serves me much better. For example, if you would like to know which method to call in order to set the zoom level on the map, I just use Strg+F (or ⌘+F on Mac) searching for &#8216;zoom&#8217; in the browser. After a few hits on &#8216;next&#8217;, I found <span class="code">setZoomLevel(zlevel)</span>. Without having to click myself through a class hierarchy structure.</p>
<p>Similar to Ovi, Yahoo Maps requires that type, zoom and pan controls are added separately and are not part of the initial instantiation. </p>
<pre><code>// instantiation
ymap = new YMap(Y.Node.getDOMNode(Y.one('#ymap')), YAHOO_MAP_REG, new YSize(500, 300));

// center on default location
ymap.drawZoomAndCenter(new YGeoPoint(mapOptions.lat, mapOptions.lng), 8);

// add controls as ymaps does not provide them per default
ymap.addTypeControl();     

// Add the zoom control. Long specifies a Slider versus a "+" and "-" zoom control
ymap.addZoomLong();            

// Add the Pan control to have North, South, East and West directional control
ymap.addPanControl(); </code></pre>
<p>Together with Bing Maps, Yahoo Maps also requires an API key in order to actually use the API. The key needs to be part of the URL when requesting the Yahoo Maps API JavaScript.</p>
<p>It terms of available functionality, one can tell that this API has not received any major updates in a while. Apart from the what you would expect from a maps API (display of markers, info windows, polyline overlays), it does not have any outstanding additional functionality, in fact, it actually lacks the ability to get directions (even though the <a href="http://maps.yahoo.com/">web interface</a> offers that). And looking at the map imagery, especially looking at the satellite images, other providers provide much more detail.</p>
<p>Another interesting fact is that the Yahoo API is the only one amongst the 4 whose zoom level scale is somewhat reversed, meaning a zoom level of 1 corresponds to the closest view, whereas zoom level 16 means zoomed out to continent level. What I find really nice though, is that the Yahoo API has a geocoder built-in, in contrast to some of the other APIs. So if I have a location input field, I can just pass whatever the user typed in to the <span class="code">drawZoomAndCenter</span> function, like so:</p>
<pre><code>ymap.drawZoomAndCenter(
    "San Francisco",
    zoomLevel
);</code></pre>
<h3>Resources</h3>
<ul>
<li><a href="http://developer.yahoo.com/maps/">Yahoo Maps Web Services</a></li>
<li><a href="http://developer.yahoo.com/maps/ajax/">Yahoo! Maps AJAX API Getting Started Guide</a></li>
<li><a href="http://developer.yahoo.com/maps/ajax/V3.8/index.html">API Reference Manual</a></li>
</ul>
<h2>Bing Maps API</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/bing.png" alt="" title="bing" width="293" height="81" class="img-left" />With the launch of its search engine Bing, Microsoft also redid what was Live Search before and released <a href="http://www.bing.com/maps/">Bing Maps</a>. The <a href="http://msdn.microsoft.com/en-us/library/gg427610.aspx">API</a>, to develop web applications, is currently in its 7.0 version and its MSDN style documentation still makes me think I am in the year 2000&mdash;despite visual changes and redesign of the MSDN site. The first thing Microsoft points out in the <a href="http://msdn.microsoft.com/en-us/library/gg427605.aspx">&#8220;Getting Started&#8221; guide</a> is that you should please sign up for an API key. The documentation provides <a href="http://msdn.microsoft.com/en-us/library/gg427606.aspx">a few examples</a>, which should be taken with a grain of salt, as all of them include the Bing Maps JavaScript in the <span class="code">&lt;head&gt;</span> of the document, which is <a href="http://developer.yahoo.com/performance/rules.html#js_bottom">a bad idea for performance reasons</a>. It is also kinda tedious that they don&#8217;t provide the developer with actual pages where they can see the examples in action, but instead they make you copy and paste the example to your own machine and fill in your personal API key in order to see what is happening. The <a href="http://msdn.microsoft.com/en-us/library/gg427611.aspx">API reference</a> is fairly well structured and clear, however it also lacks a search functionality (although, because it is not that massive, it might not be required).</p>
<p>Instantiation of the map is pretty standard, however centering the map on a new location based on user input is not. In fact, what you need to do is include a script element dynamically, which points to the Bing geocoder webservice, and provide a JavaScript callback for the <a href="http://remysharp.com/2007/10/08/what-is-jsonp/">JSON-P</a> response (as shown in <a href="http://msdn.microsoft.com/en-us/library/gg427601.aspx">this example</a>) Something that should really be abstracted within the API. </p>
<p>In addition to the standard map functionality, Bing Maps also offers <a href="http://msdn.microsoft.com/en-us/library/gg427607.aspx">a directions service</a>, <a href="http://msdn.microsoft.com/en-us/library/gg427619.aspx">custom tile layers</a> and <a href="http://msdn.microsoft.com/en-us/library/gg427600.aspx">displaying localized maps</a>. </p>
<p>In the interface itself, the API offers a so-called Bird&#8217;s eye view, which is essentially a hybrid view (satellite plus road data/labels) which switches over to an angled view, similar to what can be seen in <a href="http://maps.google.com/">Google Maps</a> and <a href="http://www.google.com/earth/index.html">Google Earth</a>, when the zoom level is high enough. I was very impressed by the image quality here, for both cities in the US and Europe (you can see for yourself, searching again for &#8220;Helsinki&#8221; in <a href="http://www.klauskomenda.com/lab/map-api-showdown/">my example</a> and zooming in to the maximum level on Bing Maps, with the map type set to &#8220;Bird&#8217;s eye&#8221;). </p>
<h3>Resources</h3>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/dd877180.aspx">Bing Maps APIs Overview</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/gg427610.aspx">Bing Maps AJAX Control, Version 7.0</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/gg427611.aspx">API reference</a></li>
<li><a href="http://en.wikipedia.org/wiki/Bing_Maps">Wikipedia article on Bing Maps</a></li>
</ul>
<h2>Google Maps API</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/google.png" alt="" title="google" width="293" height="61" class="img-left" /> Last, but not least, in my personal opinion the Google Maps API is still king amongst all the Maps APIs out there. The amount of functionality offered by the<a href="http://code.google.com/apis/maps/">Google Maps API family</a> and the <a href="http://code.google.com/apis/maps/documentation/javascript/">JavaScript API</a> itself never ceases to amaze me. With the current version 3, no API key is required any more, which makes inclusion of the JavaScript and getting started even easier.</p>
<p>Google is often criticized for is very developer centric approaches and interfaces, but the sheer amount of documentation they provide for developers plus they way they present it makes it very smooth and easy to use their API. The have a <a href="http://code.google.com/apis/maps/documentation/javascript/basics.html">guide for new developers</a> that covers the basics and standard functionality and an <a href="http://code.google.com/apis/maps/documentation/javascript/reference.html">API reference</a> (similarly structured like the one from Yahoo). But probably the best part of the docs are the <a href="http://code.google.com/apis/maps/documentation/javascript/examples/index.html">examples</a>. Well structured, with <a href="http://code.google.com/apis/maps/documentation/javascript/examples/icon-complex.html">unique URLs</a> for the developer to look at with just one click and digging deeper by doing a simple &#8216;view source&#8217;.  </p>
<p>With regards to functionality, the Google API really offers everything you could ask for from a Maps API&mdash;and more. Just to name a few that strike me as quite impressive are additional map layers, provided by <a href="http://code.google.com/apis/maps/documentation/javascript/examples/layer-kml.html">KML</a> or <a href="http://code.google.com/apis/maps/documentation/javascript/examples/layer-fusiontables-simple.html">Google Fusion Tables</a> as well as <a href="http://code.google.com/apis/maps/documentation/javascript/examples/layer-bicycling.html">Bike Paths</a> and <a href="http://code.google.com/apis/maps/documentation/javascript/examples/directions-travel-modes.html">Routes</a></a>. You can create a <a href="http://code.google.com/apis/maps/documentation/javascript/examples/maptype-styled-complex.html">custom map type with different styles</a>, <a href="http://code.google.com/apis/maps/documentation/javascript/examples/elevation-paths.html">get the elevation along a certain path</a> and include the all so beloved <a href="http://code.google.com/apis/maps/documentation/javascript/examples/streetview-simple.html">Street View</a>. In addition, the API <a href="http://code.google.com/apis/maps/documentation/javascript/basics.html#Mobile">performs great on mobile devices</a>. </p>
<p>The imagery of the satellite images is still very good and the readability of the map view <a href="http://www.41latitude.com/post/2072504768/google-maps-label-readability">has already been discussed on 41latitude.com</a>. It would be great if Google would expose Google Earth views through the JavaScript API as well (for angled views, similar to what Bing offers), but this is exposed through the <a href="http://code.google.com/apis/earth/">Earth API</a>, which is separate from the JS API. It is however seems to be possible to integrate the JS API with the Earth API, although <a href="http://earth-api-samples.googlecode.com/svn/trunk/demos/mapsapi/index.html">the example</a> is referencing the JS API version 2, which is deprecated.</p>
<h3>Resources</h3>
<ul>
<li><a href="http://code.google.com/apis/maps/">Google Maps API Family</a></li>
<li><a href="http://code.google.com/apis/maps/documentation/javascript/">Google Maps JavaScript API V3</a></li>
<li><a href="http://code.google.com/apis/maps/documentation/javascript/reference.html">Google Maps Javascript API V3 Reference</a></li>
<li><a href="http://code.google.com/apis/maps/documentation/javascript/examples/index.html">Google Maps Javascript API V3 Examples</a></li>
</ul>
<h2>Conclusion</h2>
<p>If you are looking for a generic map solution for your site or application, the <span class="highlight">Google Maps API</span> is the way to go. It incorporates features that will most likely cover close to 90 percent of the use cases out there that relate to map applications. However, you might have very specific requirements, that Google Maps might not be able to fulfill to the fullest extent. If you need an API that provides great map data for Europe, then you might want to consider the <span class="highlight">Bing Maps API</span>, which has great satellite imagery of European cities. The <span class="highlight">Ovi Maps API</span> has just been released, but has some innovative approaches in there, whereas the <span class="highlight">Yahoo Maps API</span>, because it has been neglected for quite some time, has been falling a little bit behind when it comes to state-of-the art features. If you want to read more about the topic of maps, especially regarding their readability and quality of imagery, I suggest you check out <a href="http://www.41latitude.com/">Justin O&#8217;Beirne&#8217;s site</a>, where he shares a lot of his thoughts on this topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/01/21/the-map-api-showdown/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A look at PhoneGap and Appcelerator Titanium</title>
		<link>http://www.klauskomenda.com/archives/2011/01/17/a-look-at-phonegap-and-appcelerator-titanium/</link>
		<comments>http://www.klauskomenda.com/archives/2011/01/17/a-look-at-phonegap-and-appcelerator-titanium/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 23:09:28 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[framworks]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mobile development]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[phonegap]]></category>
		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=853</guid>
		<description><![CDATA[Having been interested into mobile development for quite a while, I had a chance to look at two frameworks that make developing apps for web developers much easier. Without Objective-C or Java.]]></description>
			<content:encoded><![CDATA[<p>Ever since I had started working on my project for my diploma thesis, I was fascinated by the capabilities of smart phones (at the time, in 2006, 3G had just come out in Austria). Even though I had a lot of fun, learned a lot and <a href="archives/2008/12/13/location-based-services-my-book-on-amazon/">even got my thesis published</a>, for one reason or the other, I never really dared to venture into the whole mobile application development sphere professionally, thinking I should stay where I feel comfortable&mdash;web development. However, the developments over the last years, mainly around the <a href="http://www.apple.com/iphone/">iPhone</a>, but also recently regarding <a href="http://www.android.com/">Android</a>, brought me back to this topic I have always been very interested in. Being a web developer (and far away from a &#8220;proper&#8221; Computer Engineer), however, I still can&#8217;t wrap my head around certain technologies, i.e. languages. <a href="http://en.wikipedia.org/wiki/Java_%28software_platform%29">Java</a> is my <a href="http://en.wikipedia.org/wiki/Mount_Whitney">Mt. Whitney</a>, but <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> is more like a <a href="http://en.wikipedia.org/wiki/Mount_Everest">Mt. Everest</a> to me. So I was very happy to see that there are people that acknowledged that this is a problem and developed <a href="http://en.wikipedia.org/wiki/Multiple_phone_web_based_application_framework">phone web based application frameworks</a> that people with a web development background can take and build mobile applications with. Without having to learn Objective-C. And right there they caught my attention once again.</p>
<h2>What are phone web based application frameworks?</h2>
<p>Essentially, these are frameworks that provide developers coming from a web development background a certain set of tools to use their current skillset (HTML, CSS, JavaScript) to build native or native-like mobile applications. <a href="http://www.phonegap.com/">PhoneGap</a> and <a href="http://www.appcelerator.com/">Appcelerator Titanium</a> are the most popular amongst all the frameworks out in the wild. I got to play around with both of them recently and I am going to share a summary of my findings and a look from 10,000 feet at the two below.</p>
<h2>PhoneGap</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/phonegap_logo.jpg" alt="" width="293" height="109" class="img-left" /><a href="http://phonegap.com/">PhoneGap</a>, developed by <a href="http://www.nitobi.com/">Nitobi Software</a>, gained a lot of popularity in the web development world, because of exactly what got me interested myself. On their website, it says &#8220;Build apps in HTML and JavaScript and still take advantage of core features in iPhone/iPod touch, iPad, Google Android, Palm, Symbian and Blackberry SDKs.&#8221;. Sounded exactly what the web developer but wannabe-mobile-developer needs.</p>
<p>PhoneGap projects require the underlying SDKs (e.g. iOS SDK) to be installed and typically building the application happens from an IDE, e.g. Xcode. The developer puts his files into a <span class="code">www</span> folder in the project directory. When building, PhoneGap then renders these files inside a native WebView provided by the OS-specific language (either <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html">Objective-C</a> or <a href="http://developer.android.com/reference/android/webkit/WebView.html">Java</a>). It exposes access to certain native device features, like Contacts, Accelerometer, Camera and Notifications, through the <a href="http://docs.phonegap.com/">PhoneGap JavaScript API</a>.</p>
<p>The actual interface of the app, however, is styled with &#8216;the usual suspects&#8217;, meaning HTML and CSS. Because of the fact that UI elements are styled with CSS, these can look significantly different to native OS interface elements (e.g. buttons), as well as the performance might be not as good as if native elements were used. </p>
<p>In the end, a PhoneGap application is essentially still a web application, wrapped inside a WebView. It still remains a web application that is displayed through rendering of HTML, CSS and JavaScript using a browser instance on a mobile device. It currently supports development for the iPhone, Google Android, Symbian OS, BlackBerry and Palm operating systems.</p>
<h3>Example</h3>
<p>The following example code is taken from <a href="http://docs.phonegap.com/phonegap_contacts_contacts.md.html#contacts.find">PhoneGaps API documentation</a> to illustrate the syntax of how a PhoneGap application is put together. In this specific case, the API is used to find all contacts with the name &#8216;Bob&#8217; in any name field:</p>
<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Contact Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="phonegap.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for PhoneGap to load
    //
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // PhoneGap is ready
    //
    function onDeviceReady() {
        // find all contacts with 'Bob' in any name field
        var options = new ContactFindOptions();
        options.filter="Bob";
        var fields = ["displayName", "names"];
        navigator.service.contacts.find(fields, onSuccess, onError, options);
    }

    // onSuccess: Get a snapshot of the current contacts
    //
    function onSuccess(contacts) {
        for (var i=0; i&lt;contacts.length; i++) {
            console.log("Display Name = " + contacts[i].displayName);
        }
    }

    // onError: Failed to get the contacts
    //
    function onError() {
        alert('onError!');
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="onLoad()"&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;Find Contacts&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>
<h2>Appcelerator Titanium</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/appcelerator_logo.png" alt="" width="293" height="100" class="img-left" /><a href="http://www.appcelerator.com/products/titanium-mobile-application-development/">Appcelerator Titanium</a> was <a href="http://www.appcelerator.com/2008/12/titanium-introduction/">launched with the same promise</a> like PhoneGap, namely to provide web developers, familiar with HTML, CSS and JavaScript, a tool to use these technologies to develop mobile applications on iOS and Android. In a way, Titanium reminds me of <a href="http://www.j2mepolish.org/cms/leftsection/introduction.html">J2ME Polish</a>, a library for Java Development on mobile devices that enables the developer to <a href="http://www.j2mepolish.org/cms/leftsection/documentation/design/visual-guide.html">create native UI elements</a> and style them using a <a href="http://www.j2mepolish.org/cms/leftsection/documentation/design/css-basics.html">CSS-like syntax</a>. Similar to PhoneGap, Titanium provides a binding layer that maps JavaScript function calls to natively available APIs. However, here is where the similarities end. The main differences to PhoneGap are:</p>
<ul>
<li><span class="highlight">Truly native applications</span>. Unlike PhoneGap, <a href="http://developer.appcelerator.com/guides/en/architecture.html">Titanium actually translates the code into native application code</a>. The application code, written in JavaScript, is being interpreted during runtime and through a bridge layer, function calls to <span class="code">Titanium.some_function</span> invoke native application code under the hood.</li>
<li><span class="highlight">Just JavaScript, no more HTML &amp; CSS</span>. Previous to version 1.0 (current version is 1.5), Titanium followed a similar approach to what PhoneGap was doing. The application code would consist of HTML, CSS and JavaScript, whereas native device services were exposed using a Titanium specific <a href="http://developer.appcelerator.com/apidoc/mobile/latest">JavaScript API</a>.  With version 1.0, HTML and CSS are gone. Code is written in pure JavaScript, using mainly functions that the Titanium API exposes. Apart from using it to access special device features (such as the camera), it also enables the developer to render native UI elements (such as tables, buttons, native maps etc.).</li>
</ul>
<p>The obvious advantage of a native application is performance. The UI will perform much better if native OS elements are used, compared to rendering HTML, CSS and JavaScript in a browser instance to e.g. create a button. As a side effect, the native look-and-feel can easily be maintained.</p>
<p>Unlike PhoneGap, building and packaging does not happen inside an IDE, but through a special piece of software called <a href="http://www.klauskomenda.com/wp-content/uploads/2011/01/titanium_developer_ss.gif" class="lightbox" title="Titanium Developer Screenshot">Titanium Developer</a>. This is the tool to set up new projects, configure, test and package them. Any IDE of your choice can be used to write the application code. </p>
<h3>Example</h3>
<p>Appcelerator provides a plethora of examples, all bundled up in their <a href="http://developer.appcelerator.com/guides/en/kitchensink.html">Kitchen Sink demo application</a>, which can be downloaded from <a href="http://github.com/appcelerator/KitchenSink">GitHub</a>. The following example, <a href="https://github.com/appcelerator/KitchenSink/blob/master/KitchenSink/Resources/examples/shake.js">taken from Kitchen Sink</a>, shows how to hook up an event listener, using the Titanium API, and display an alert window:</p>
<pre><code>var win = Titanium.UI.currentWindow;

var l = Titanium.UI.createLabel({
	text:'Shake your phone',
	top:10,
	color:'#999',
	height:'auto',
	width:'auto'
});

win.add(l);

Ti.Gesture.addEventListener('shake',function(e)
{
	Titanium.UI.createAlertDialog({title:'Shake',message:'it worked!'}).show();
});</code></pre>
<h2>Conclusion</h2>
<p>Both Phone Gap and Appcelerator Titanium give web developers the opportunity to create mobile applications without the need to learn Objective-C or Java. After the build process, both frameworks provide the developer with a packaged application that can be installed  on an actual physical device and published (e.g. using the Apple AppStore). </p>
<p><span class="highlight">PhoneGap</span> supports more Operating Systems and lets the developer essentially set up his application project like he would set up a website (e.g. with <span class="code">index.html</span>, <span class="code">css</span>, <span class="code">img</span> and <span class="code">js</span> folder etc.). PhoneGap applications are then wrapped by the framework inside a WebView during build time. This means that, upon execution, the rendering still happens inside a browser instance, which interprets the HTML, CSS and JavaScript. Compared to a truly native application, this likely means slow performance and additional effort to re-create a native experience.</p>
<p><span class="highlight">Appcelerator Titanium</span> only supports iOS and Android. Any application code is (as of version 1.0) written in pure JavaScript using mainly Titaniums JavaScript API. It seems more like a native code (Objective-C or Java) abstraction layer than code that resembles anything someone would recognize from the web development world. Unlike with PhoneGap, the developer ends up with a final software product that is truly native to the respective operating system. Because native elements are used for the interface (e.g. buttons, tables, views), the performance is better and no effort needs to be put in to recreate any native experience using HTML, CSS and JavaScript. </p>
<p>Finally, it highly depends on the requirements of the product which framework to go with. If the goal is to support as many operating systems as possible, then PhoneGap is probably the way to go. If true native-ness and performance is important, then Titanium will be the better choice. It is also important to note that only PhoneGap still holds true to their promise that a web developer can quickly jump in and use his skills to develop a mobile app. With Titanium, all the application code will be JavaScript, even the styling of elements happens through function calls (which is, arguably, still better to having to use Objective-C). An important factor for deciding which way to go would also be whether the respective JavaScript API provided offers the functionality needed for the application.</p>
<h2>Resources</h2>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Multiple_phone_web_based_application_framework">Wikipedia: multiple phone web based application framework</a> </li>
<li><a href="http://phonegap.com/">PhoneGap</a></li>
<li><a href="http://docs.phonegap.com/">PhoneGap JavaScript API docs</a></li>
<li><a href="http://appcelerator.com/">Appcelerator Titanium</a></li>
<li><a href="http://developer.appcelerator.com/guides/en/architecture.html">Overview over the Appcelerator Titanium architecture</a></li>
<li><a href="http://developer.appcelerator.com/apidoc/mobile/latest">Titanium JavaScript API docs</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/01/17/a-look-at-phonegap-and-appcelerator-titanium/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Book Review: Object-Oriented JavaScript</title>
		<link>http://www.klauskomenda.com/archives/2009/04/25/book-review-object-oriented-javascript/</link>
		<comments>http://www.klauskomenda.com/archives/2009/04/25/book-review-object-oriented-javascript/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 16:07:34 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=752</guid>
		<description><![CDATA[If you ever wanted a JavaScript book that talks about intermediate to advanced, cutting-edge and state-of-the-art techniques, this is the one. Your newly acquired knowledge might also get you nice looks from all the ladies at the next YUI party. Who knows.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/object-oriented-javascript-applications-libraries/book/mid/030309lf8ofn"><img src="/wp-content/uploads/2009/03/oo_js_cover.jpg" width="235" height="298" class="img-right" /></a>It has been a while since the late nineties in which JavaScript was (ab)used in a very hacky way, i.e. having to work around browser vendor proprietary code (Internet Explorer and Netscape) and, because it provided such a nice variation to otherwise static pages, adding the most useless features to a webpage. Anyone remember the snowflakes following the mouse cursor? Quite some time passed since then and thankfully, JavaScript grew out of puberty and has, in recent years, reached a quite significant stage of adulthood.</p>
<p>Stoyan Stefanov, a colleague of mine at <a href="http://yahoo.com">Yahoo!</a>, recently published <a href="http://www.packtpub.com/object-oriented-javascript-applications-libraries/book/mid/030309lf8ofn">Object-Oriented JavaScript</a>. Personally, the book about JavaScript I was waiting for. A while back, I read and reviewed Jeremy Keith&#8217;s <a href="/library/jeremy-keith/dom-scripting-web-design-with-javascript-and-the-document-object-model/">DOM Scripting</a>, which is the perfect introduction as to how developers should use JavaScript these days in a browser environment. Progressive Enhancement was one of the key concepts in there. So after getting the basics covered, my expectation was that Stoyan&#8217;s book provides me with supporting material for intermediate to advanced JavaScript programming tasks. Does it deliver? We will come to that very shortly.</p>
<h2>Contents</h2>
<p>Chapters 1 to 4 in his book cover a brief history about JavaScript and the basic elements of the language, like variables, primitive data types, conditions and loops as well as functions and objects. The latter already have their specialties in JavaScript and Stoyan explains those special characteristics. </p>
<p>Chapters 5 and 6 are devoted to prototype and how inheritance works in JavaScript, a very essential thing to cover when we are talking about advanced techniques. </p>
<p>Chapter 7 talks about what readers of DOM Scripting might still remember, namely how JavaScript can be used to access and manipulate specific elements in the DOM. The author also takes a look at Events and the ever popular XMLHttpRequest.</p>
<p>And finally, the highlight comes last, Chapter 8 deals with what hardcore programmers were waiting for: Coding and Design Patterns. <a href="/code/javascript-programming-patterns/">Having done a little research about this myself</a>, I found it great that Stoyan documents concepts that have become good practice in the JavaScript world, like namespacing and creating public and private properties and methods. In the design patterns part, he talks about Singletons amongst various other patterns at the programmers disposal. </p>
<p>The book closes with a quite comprehensive appendix, which includes listing reserved words, referencing built-in functions and objects and regular expressions in JavaScript. </p>
<h2>Rating and Reasoning</h2>
<h3 title="My Rating: 9 out of 10" class="rating rating-level-9">My Rating: 9 out of 10</h3>
<p>Even though it states that &#8220;no prior JavaScript knowledge is required&#8221;, I would say that is a bit of an understatement. If DOM Scripting was your first JavaScript book then I would put the following equation on the board: DOM Scripting + experience with these techniques in The Real World (meaning on actual live projects) = ready for Object-Oriented JavaScript. Don&#8217;t get me wrong, Stoyan covers the basics (variables, conditions etc.) in the first few chapters, but after that, the learning curve gets pretty steep and I believe it is safe to say, without <em>any</em> prior knowledge, you will put this book back on the shelf, left frustrated. </p>
<p>I have worked on a couple of minor web projects before <a href="http://uk.yahoo.com">Yahoo! Europe</a> hired me in May 2007, so to this date, I believe I was able to acquire some experience when it comes to using JavaScript on high-scale websites. From my perspective, the first couple of chapters was a nice refresh on the topic, but only then, in Chapters 5 to 8, things got interesting with bits and pieces in there that helped me closing some knowledge gaps about certain concepts, which is really great. This, again, supports my feeling that this book is not meant for <em>every</em> JavaScript developer out there, independent of whether it is a newbie or an advanced developer. I feel that people with probably a couple of years experience might get more out of it than someone who just delved into JavaScript a month ago. </p>
<p>It is difficult to come up with concrete examples to explain this, and this observation is highly subjective of course, but I feel that the way the book is done and written, it feels a lot &#8220;drier&#8221; and less &#8220;exciting&#8221; to read compared to DOM Scripting. Which, again, if this targets JavaScript beginners, should not be the case. But I believe the more complex the material gets, the harder the job becomes of having to thrill and excite the reader. </p>
<p>What I really like about the book is that basically all the examples Stoyan gives, you can type into the Firebug console right away to try out for yourself. As I am a believer that you learn new skills most effectively by actually <em>doing</em> something and play with it, I am pretty sure this is a good way of imparting knowledge. </p>
<h2>Conclusion</h2>
<p>If you are a Web Developer with several years of experience on the job and with JavaScript and you want to move your knowledge level up a notch or two, this book is for you. If you want to play with the cool kids, then <a href="http://www.packtpub.com/object-oriented-javascript-applications-libraries/book/mid/030309lf8ofn">get this book</a>. If you are more or less new to the JavaScript world, you might want to consider starting with DOM Scripting first and getting experience using those techniques on real world projects, before diving into the advanced concepts discussed in Object-Oriented JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2009/04/25/book-review-object-oriented-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Location Based Services &#8211; my book on Amazon</title>
		<link>http://www.klauskomenda.com/archives/2008/12/13/location-based-services-my-book-on-amazon/</link>
		<comments>http://www.klauskomenda.com/archives/2008/12/13/location-based-services-my-book-on-amazon/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 22:22:36 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Life in General]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=728</guid>
		<description><![CDATA[Seeing your work published and being available on Amazon.com is something you don't really think about when writing your diploma thesis. But somehow it happened that my work about Location Based Services is now available on Amerca's largest online retailer website. I am stunned.]]></description>
			<content:encoded><![CDATA[<p>I graduated from <a href="http://www.en.fhv.at/">University</a> in 2006 in Austria and wrote my diploma thesis on <a href="http://en.wikipedia.org/wiki/Location_Based_Services">Location Based Services</a>. I talked about the foundations and technologies that need to be in place in order to provide such a service to users of cell phones and mobile devices. To round it up, I developed a prototype for a Location Based Service (a restaurant guide) in <a href="http://en.wikipedia.org/wiki/J2me">J2ME</a> as well as a corresponding website. </p>
<p><a href="http://www.amazon.de/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1229204521&#038;sr=8-1"><img src="http://www.klauskomenda.com/wp-content/uploads/2008/12/lbs_book_cover.gif" alt="" class="img-right" /></a>The application on the mobile phone would give you a list of restaurants, bars, cafes etc. in your proximity, as well as details about their type of cuisine, opening hours, price range etc. and how other people have rated that particular place. Based on whatever the occasion was&mdash;whether you are planning a relaxed dine-out with your family or having a more intoxicated night with friends&mdash;the tool would recommend you the best place in your area.</p>
<p>While I was working on the prototype, writing my thesis and then putting the layout together in <a href="http://www.adobe.com/de/products/indesign/">InDesign</a>, I wasn&#8217;t thinking that a publisher would ever get interested in my work. </p>
<p>But the less you expect something, the happier you are when it actually happens. About 2 months ago I received an email from <a href="http://www.vdm-verlag.de/">VDM Verlag</a> in Germany saying that they found my thesis in the library of the university and would be interested in publishing it. &#8220;How awesome is that!&#8221;, was about the reaction I had. After putting all the required details about the book into their online system and reformatting a few things to fit their requirements, I got the confirmation that everything looks good and it is off to the printers.</p>
<p>And now, just in time for Christmas <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , I am happy to see my book being available on <a href="http://www.amazon.com/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1229204532&#038;sr=8-1">Amazon.com</a> and <a href="http://www.amazon.de/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1229204521&#038;sr=8-1">Amazon.de</a>. It is in German, so sorry to my non-German-speaking friends. I will most likely never reach the author status of my colleague <a href="http://www.wait-till-i.com/">Christian Heilmann</a>, who wrote <a href="http://www.amazon.com/s/ref=nb_ss_b?url=search-alias%3Dstripbooks&#038;field-keywords=christian+heilmann&#038;x=0&#038;y=0">about 167 books about web development related topics</a>, but I am very happy to see this and it makes me feel proud to see that all the work I put in at that time is now available to a wider audience. It is a really great feeling and I feel very content how it all turned out.</p>
<p>I would like to take this opportunity to thank <a href="http://www2.staff.fh-vorarlberg.ac.at/~kw/">Karl-Heinz Weidmann</a>, who was my thesis advisor, and <a href="http://www.linkedin.com/pub/1/b79/615">Werner Flatz</a>, who I worked together with during the development of my application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/12/13/location-based-services-my-book-on-amazon/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

