Monday, August 19, 2013

Getting Started with Mobility, Part 3: Native Android

In this series, we're introducing mobile development by looking at a variety of platforms. In Part 1, we provided an overview of the mobile landscape, and in Part 2 we explored Native iOS development. Here in Part 3, we'll introduce you to native development for Android phones and tablets.

Android, the Market Leader
Android from Google currently has the largest portion of the mobility market, which automatically makes it an important platform to develop for; Google bills it as "the most popular mobile platform in the world." Unlike Apple, which controls both the hardware and software, Google provides the Android platform and works with multiple manufacturers and carriers. This is why there is a multitude of phones and tablets available for Android.

Android: Variety, Variety, Variety

The Computer You'll Develop on: A Mac or a PC
One of the nice things about Android development is how approachable it is: whereas other mobile platforms force you to develop on a Mac (iOS) or a (Windows Phone, Windows 8), you can develop Android apps using either a Mac or a PC.

Developer Tools: Eclipse, IntelliJ, or Android Studio
The longtime-favorite for Android development has been Eclipse, and most of the tutorials you'll find online assume Eclipse. However, IntelliJ has been steadily displacing Eclipse as a favored IDE--and IntelliJ Community Edition is free. Moreover, the future of Android development is "Android Studio", based on IntelliJ CE and available now in an "Early Access Preview". Android Studio is what I use.

Whatever IDE you choose, you'll need to install it--and that's going to involve obtaining a number of software bits, installing them, and getting them to reference each other. Because Android development is based on Java, you'll need to install Java from Oracle. Then you'll need the Android Developer Kit (ADK) from developer.android.com. Lastly, you'll need your IDE.

Android Studio IDE

Programming: XML, Java, and Android APIs
To develop for Android, you will work in XML, Java, and the Android APIs.

In Android projects you define many things in XML, including your application manifest, layouts, menus, and resources. Below is a sample Android screen layout, containing a text field and a button.

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"&gt;
     <EditText

        android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />
    <Button

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send" />


You will also write code in Java. The choice of Java is one of the things that makes Android easy to learn: many developers already know Java, or a similar language like C#. Below is an example of the Java code for an Android activity (view).

package davidpallmann.tutorial01;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.content.Intent;
import android.widget.EditText;

public class DisplayMessageActivity extends Activity {

   
@SuppressLint("NewApi")
   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView
(R.layout.activity_display_message);

       
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
       
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
           
// Show the Up button in the action bar.
            getActionBar
().setDisplayHomeAsUpEnabled(true);
       
}
   
}

   
@Override
   
public boolean onOptionsItemSelected(MenuItem item) {
       
switch (item.getItemId()) {
       
case android.R.id.home:
           
NavUtils.navigateUpFromSameTask(this);
           
return true;
       
}
       
return super.onOptionsItemSelected(item);
   
}
}

Some things you'll deal with in Android development include the following:
  • Namespace: having to know the right namespaces to reference in your Java code.
  • Choice of tools: there's more than one IDE out there, so tutorials and guidance don't always match the tool you're using.
  • Immense variety: dealing with a large variety of devices and dimensions.
  • Versioning: deciding how much to support in terms of older Android devices.

Testing Your Apps: the Android Emulator
You can test your apps on the Android Emulator and/or connect an actual device to your computer. The Android emulator is a bit slow, so you'll need patience to use it. The emulator supports a variety of devices, and you can set up multiple configurations for a mix of devices (for example, several different phones and tablets).

Android Emulator

To connect an actual device to your computer, you'll need to set up your device for development, which involves setting it to enable USB debugging.

Online Resources
The Android developer center at http://develop.android.com is nicely set up, with design and develop resources such as guidance, training, tools downloads, and documentation.

Android Developer Center
 
Key areas to visit:
Design Principles
Developer Training
API Guides
Developer Tools
Samples

Tutorials
The Training section on developer.android.com has good, attractive materials. However, you'll find the "tutorials" here to be a mixed bag: some of them give you step-by-step instructions and have downloadable code, while others are more like "how to guides" that don't specify exact steps and lack complete code listings or downloads. Accordingly, you'll find them to be useful but will almost certainly want to supplement with additional learning materials. If you prefer video tutorials to written tutorials, you might check out the Android learning materials from Treehouse.

1. Building Your First App

This first of the tutorials on developer.android.com will walk you through creating a simple project with a text box and button, that passes on the text you enter to a second screen. It's a simple but effective introduction to Android development that will give you exposure to XML layout, Java code-behind classes, Intents (action messages), and string resources. Time: 1-2 hours.

Building Your First App Tutorial

The follow-on training topics at developer.android.com discuss how to augment this simple app in a number of ways.


2. Android 4.2 App Development

This book, available in hardcopy and Kindle form, is a great way to learn Android development. One of it's many useful tutorials is on the Master-Detail flow project template, which is also available online at at Techotopia. It will acquaint you with the Master-Detail Android project template and have you customize it to track web sites. One of the nice things about this project template is that it uses an alternate layout for phones vs. tablets to take advantage of available screen real-estate intelligently.

Master-Detail Project Template
 
By the time you're finished with the tutorial, you'll have modified the item data model and the detail view will display web content.
 
Master-Detail Flow Tutorial
 
3. Capturing Photos Tutorial

In this tutorial you develop the ability to take pictures (and video) using the camera. It includes downloadable source code. You'll first learn how to request camera permissions, take a photo, view the photo, save the photo, add the photo to a gallery, and decode a scaled image. Then you'll move on to recording and viewing video. Lastly you'll learn how to directly control the camera.

Tutorials and samples are great for learning and getting started, but you'll ultimately want to move past looking at someone else's work and develop your own apps.

Summary: Native Android Development
Android is one of the key mobile platforms you will want to target due to its strong position in the market. It is also one of the easier platforms to get started with, because of the availability of tools for computers (Mac, PC) and its use of the well-known Java programming language. Like any mobile platform, however, it will take an ongoing investment to learn its conventions and APIs well.

Next: Getting Started with Mobility, Part 4: Native Windows Phone

Saturday, August 17, 2013

Getting Started with Mobility, Part 2: Native iOS Development

In this series, we're introducing mobile development by looking at a variety of platforms. In Part 1, we provided an overview of the mobile landscape, and discussed various types of client app development (native, hybrid, mobile web) and supporting back-end services. Here in Part 2, we'll introduce you to native development for iOS (iPhone and iPad).

iOS, The Innovator
Apple bills iOS as "the world's most advanced mobile operating system." iOS and the iPhone occupy a special place in the history of mobile devices, having set the standard for what a smartphone should be--and heavily inspiring the design choices of the competition. The iPad similarly caused a revolution, establishing the smart touch tablet as an essential device. Although facing heavy competition from Google's Android, the iPhone and iPad are considered by many to be the premium mobile devices available today. Apple provides both the iOS operating system and the iPhone/iPad hardware, which puts them in full control of the experience.



The Computer You'll Develop on: A Mac
For native iOS development, you need a Mac, period.

Developer Tools: XCode
XCode is the Apple development environment, and it gives you everything you need for iOS development including an iPhone/iPad simulator. You don't need to sign up as an Apple developer to develop iOS apps and run them in the simulator, but you do need to join up (currently $99/yr) in order to run them on an actual device.

There's a lot in XCode: it gives you a very complete environment that includes a code editor, Interface Builder (a user interface editor), and various wizards / assistants / dialogs for setting properties, wiring up events, and so on. However, expect that it's going to take you some time to really learn your way around it.

XCode Development Environment

Programming: Objective-C and Cocoa Touch
You'll be programming in a language named Objective C and working with Cocoa Touch--a family of frameworks for iOS development. Cocoa Touch provides services such as user interface, animation, media, and data management.

As its name implies, Objective-C is yet another object-oriented, C-dervived programming language; however, it comes from the SmallTalk school of object orientation which means there are differences from what you may be used to if your prior experience is with C++, C#, or Java. Here's an example of Objective-C code to give you idea of what it looks like:

#import "BirdSightingDataController.h"
#import "BirdSighting.h"

@interface BirdSightingDataController()
- (void)initializeDefaultDataList;
@end

@implementation BirdSightingDataController
- (void)initializeDefaultDataList {
    NSMutableArray *sightingList = [[NSMutableArray alloc] init];
    self.masterBirdSightingList = sightingList;
    BirdSighting *sighting;
    NSDate *today = [NSDate date];
    sighting = [[BirdSighting alloc] initWithName:@"Pigeon" location:@"Everywhere" date:today];
    [self addBirdSightingWithSighting:sighting];
}

- (void)setMasterBirdSightingList:(NSMutableArray *)newList {
    if (_masterBirdSightingList != newList) {
        _masterBirdSightingList = [newList mutableCopy];
    }
}

- (id)init {
    if (self = [super init]) {
        [self initializeDefaultDataList];
        return self;
    }
    return nil;
}

- (NSUInteger)countOfList {
    return [self.masterBirdSightingList count];
}

- (BirdSighting *)objectInListAtIndex:(NSUInteger)theIndex {
    return [self.masterBirdSightingList objectAtIndex:theIndex];
}

- (void)addBirdSightingWithSighting:(BirdSighting *)sighting {
    [self.masterBirdSightingList addObject:sighting];
}
@end

Some things about Objective C that initially trip up new developers include the following:

  • An interface is what you may be used to calling a class.
  • A protocol is what you may be used to calling an interface.
  • You refer to a current object as self (this in many other languages).
  • You use nil for no value (null in many other languages).
  • You use the constants YES and NO for 1 and 0 (true and false in many other languages).
  • All methods (functions) are public.
  • Methods defined with a leading minus sign (-) are instance methods.
  • Methods defined with a leading plus sign (+) are class (static) methods.
  • Square brackets indicate message passing, which is how you invoke a method on an object rather than the dot notation you encounter in many other languages.
  • You have to be careful about memory management, you don't have garbage collection like you do in C# and Java. You'll want to take advantage of a feature called Automatic Reference Counting (ARC) to simplify your memory management obligations.
  • There's an at-sign (@) statement syntax for declaring things like interfaces and implementations, reflecting Objective-C's original roots as a C preprocessor.
  • In an interface or implementation, properties and variables go within a block of curly braces, while methods go outside it.
  • You need to keep declarations (in a .h file) separate from your implementation (.m file), as in C++.
Like anything else, once you get used to Objective-C you can be effective in it.

Testing Your Apps: The iOS Simulator
The iOS Simulator allows you to easily test your iPhone and iPad apps right on your Mac. Command-R out of XCode invokes the simulator.
iOS Simulator

Online Resources
There are many good tutorials and reference materials to be found at developer.apple.com. Start here, at Start Developing iOS Apps Today.

Apple Developer Center
 
Also be sure to check out these online references:
iOS Technology Overview
User Experience Starting Point for iOS
iOS Human Interface Guidelines
Write Objective-C Code
Core Data Starting Point
Data Management Starting Point
Graphics and Animation Starting Point
Audio and Video Starting Point
Networking and Internet Starting Point
Performance Starting Point for iOS
Sample Code

Tutorials
You can find many different suggestions online for which books, courses, and sites are most useful for learning iOS.

1. Ray Wenderlich iOS Tutorials

Even if you're an experienced developer, you may find Objective C to be quite a hurdle at first. For that reason, I suggest swallowing your pride a bit and starting with some very basic tutorials that lead you by the hand, step-by-step. Personally, I've found the tutorials at http://www.raywenderlich.com to be well-written and a good way to learn the basics quickly while building apps.

Learn to Code iOS Apps 1: Welcome to Programming
Learn to Code iOS Apps 2: Strings, Arrays, Objects and Classes
Learn to Code iOS Apps 3: Your First App
Learn to Code iOS Apps 4: Making it Beautiful

By the time you make your way through these first four tutorials, you'll have created a game with audio.
Result of Learn to Code iOS Apps 4 Tutorial

There are plenty of intermediate and advanced tutorials also available from the same site.


2. Apple iOS Tutorials

I've also found the tutorials at developer.apple.com to be very good. Here are links to the first three:

Your First iOS App

In this tutorial you receive an introduction to Xcode, and develop a simple app with a text box, label, and button. This is meant to have you walk before you run, doesn't assume much in the way of prior knowledge, and only takes 1-2 hours. It will give you a good grounding in learning your way around XCode.



Your Second iOS App: Storyboards

In this tutorial you develop a birdwatching app with master-detail views and multiple storyboard scenes. You'll be spending a lot of time with the storyboard editor as well as writing code. This is a much more involved tutorial than the first one. Here, you create an app using a master-slave project template, define a new data model, and create multiple scenes (master, detail, add), linked with segues. In this tutorial you're getting an excellent grounding in things you will need to do frequently in real iOS apps. It's well worth the time. Time: 4-8 hours. 



Your Third iOS App: iCloud

In this tutorial you develop an app that creates and manages text files in Apple's iCloud storage. Unlike the previous two tutorials, this one doesn't spell every little step out for you and is also slightly out of date, so it may challenge you a bit; if you run into trouble with it, refer to the complete code listings at the end to get your project right. Unlike the previous labs, you'll be registering your app with the Apple developer center and will run it on an actual iPhone rather than in the simulator. Time: 4-8 hours.
There are plenty of other good tutorials online beyond these. At some point, you'll move behind prepared tutorials and develop your own apps--perhaps beginning with making your own variations to the tutorials. There's lots of good forum support online so you won't be alone in your journey.

Summary: Native iOS Development
It definitely takes a substantial investment to become a proficient native iOS developer: it won't come overnight, and it may feel like you're making slow progress at first--but stay with it, and you'll be amply rewarded. Given the importance of the iOS platform, it's a wise career move to develop iPhone and iPad programming skills.

Next: Getting Start with Mobility, Part 3: Native Android Development

Tuesday, August 13, 2013

Getting Started with Mobility, Part 1: Understanding the Landscape

In this series of posts, we're looking at how to get started as a mobile developer. Here in Part 1 we'll provide an overview of the landscape; in subsequent posts, we'll get down to the details of working in various platforms.

Part 2: Native iOS Development
Part 3: Native Android Development
Part 4: Native Windows Phone Development
Part 5: Native Windows 8 Development
Part 6: Hybrid Development in C# with Xamarin
Part 7: Hybrid Development in JavaScript with Titanium
Part 8: Hybrid Development in HTML5 with Icenium
Part 9: Mobile Web with Responsive Web Design
Part 10: A Back-end in the Cloud with Windows Azure Mobile Services

As a mobile developer, you may find yourself specializing in one particular platform (e.g. "I'm an Android developer") or perhaps supporting all of them ("I'm a mobile web developer") or specializing in mobile back-ends (services, data, security, and cloud). All of these are important.

The Front-End
You can develop mobile client apps natively, using a hybrid approach, or via mobile web. Let's look at them, one by one:
  • In native development, you are using a tool and language espoused by a mobile platform vendor as the official way to develop for their platform. Depending on the platform, there may be several endorsed languages or development environments to choose from. Native development is often considered the high road, because alternative approaches can sometimes compromise performance, limit fidelity to platform usability conventions, or restrict the functionality available to apps. However, native development can also be expensive and may be a mismatch for the skills known to your developers. 
  • In hybrid development, a third-party provides tools and a framework that allow to develop for a platform using an alternative approach. This may allow your developers to work in a familiar language or development tool. Some hybrid solutions generate a native application as their output; others execute within an execution layer or browser contained in a native application shell. Hybrid solutions are sometimes considered risky because the third-party may not be able to stay in alignment with mobility platforms.
  • In mobile web development, you develop a web site intended for consumption on mobile devices via their browsers. You detect device size and other characteristics and the web experience adapts accordingly. A mobile web approach is not always a suitable experience, but at times it can be. From a skills standpoint, mobile web is very approachable due to the large number of web developers in existence. An economical advantage to mobile apps is that you develop a single solution, rather than separate apps for each platform.
Many people have strong opinions about which approach is best, but be sure to consider the nuances of experience, device features needed, performance, skills alignment, risk, and development cost rather than making a snap decision.

The Back-End
Most mobile solutions involve more than just the app(s), that visible part you interact with on mobile devices. There often needs to be a back-end that provides one or more of the following:
  • Security - user authentication and authorization.
  • Storage - persistent data storage.
  • Notifications - event notifications.
  • Processing - you may need server-side processing to augment what the limited processing available on mobile devices.
  • Integration - coordination with other systems in the enterprise or on the Internet.
  • Cloud - use of cloud computing can make your back-end available across a wide geography or worldwide.
Table: Mobile Client App Development Choices
The table below shows some of the choices available to you when you are targeting Android, Apple, Windows Phone, and/or Windows 8 devices.

 
In Part 2, we'll look at what it takes to develop native applications for iOS.
 

Saturday, February 23, 2013

Glass Half Empty: Understanding Cloud Computing SLAs

Let's talk about Cloud SLAs - a subject that is very important, but nevertheless is frequently  misunderstood,  over-simplified, or even outright ignored.


As I write this, Windows Azure has had an "up and down" week: on Tuesday 2/19/13, Windows Azure Storage was declared the leader in Cloud Storage by an independent report. A few days later on Friday 2/22/13, Windows Azure Storage suffered a worldwide outage - which shows you what a difference a couple of days can make to cloud vendor reputations. 

Given the events of this week, it seems timely to say some things about Cloud SLAs and correct some faulty reasoning that seems prevalent.

Service Level Agreements and High Availability
A service-level agreement is a contract between IT and a business to provide a certain level of service. In an enterprise an SLA could cover many things, including availability, response time, maintenance windows, and recovery time. In today's cloud computing environments, SLAs are largely about availability (uptime). So, let's talk about high availability.

Non-technical people say they want things up "all the time". Of course they do - but that's not reality. The chart below shows the "9s" categories for availability and what that means in terms of uptime.

Availability % Downtime/year Downtime/month
90% ("one 9") 36.5 days 72 hours
99% ("two 9's") 3.65 days 7.20 hours
99.9% ("three 9's") 8.76 hours 43.8 minutes
99.95% ("three and a half 9's") 4.38 hours 21.56 minutes
99.99% ("four 9's") 52.56 minutes 4.32 minutes
99.999% ("five 9's") 5.26 minutes 25.9 seconds

The key thing to understand is that as you increase the number of 9's the expense of meeting the SLA increases dramatically. Except for very simple systems or individual components, 4 9's is extremely expensive, and not available today in the public cloud. 5 9's or better is prohibitively expensive and quite rare.

Typical Availability Provided in the Cloud is 99.9% to 99.95%
Cloud platforms have individual SLAs for each service. The majority of cloud services have an SLA of 3 9's (99.9%), and some computing services offer 3.5 9's (99.95%). That means, a cloud service could be down 43 minutes a month and still be within its SLA. Is that an acceptable level of service? It depends. It could be a step up for you or a step down for you depending on what SLA you're used to - what does your local enterprise deliver? Interestingly, when I ask this question of clients the answer I receive most often is, "We don't know what our current SLA is"!

Availability Interruptions Don't Play Nice
The table above might lead you to believe that outage time is somehow evenly distributed but there's no guarantee of when an outage will occur or that outages will politely schedule themselves in small pockets of time over the course of the year. A service with a 99.9% SLA could be down 10 minutes a week, but it could also be down 43 minutes a month or even 8 hours straight once a year. You should assume the worst: an outage will occur during business hours on the day you can least afford it. Most cloud SLAs measure the SLA at a monthly level and provide some recompense if it is not met.

SLAs are not guarantees. Every cloud provider has missed meeting its SLA at times.

The Subtlety of SLAs by Service: Your Cloud Service SLA is not your Solution's SLA
Nearly all solutions in the cloud use multiple cloud services (for example, a web site might use Compute, Storage, and Database services). Note that the cloud providers do not provide an SLA for your solution, only for the individual services you consume.

An easy trap to fall into is assuming the minimum SLA for the cloud services you are using translates into an overall SLA for your solution. Let's demonstrate the fallacy of that thinking. Let's say your solution makes use of three cloud services, each with a monthly SLA of 99.9%. On the first day of the month, the first cloud service has a 40-minute outage but is otherwise up the remainder of the month - its still within its SLA. Now let's say the exact thing happens on the second day of the month to the second cloud service. And then, the same thing happens on the third day with your third cloud service. None of those services has violated its SLA, but your solution has been down 120 minutes that month.

The more services you use, the less uptime you can count on. Unless you're feeling lucky.


Using Multiple Data Centers Does Not Magically Increase 9's
I'm often asked if a 4 9's arrangement can be had by leveraging multiple data centers for failover. The answer is NO: while using multiple data centers and having good failover mechanisms in place does increase your likelihood of uptime, it is not a guarantee. Let's consider the best case and worst case scenario where you are using a primary cloud data center and have a failover mechanism in place for a secondary data center that is ready to take over at a moment's  notice. In the best case scenario, you experience no downtime at all in the primary data center, never need that second data center, and life is good. It could go that way. In the worst case scenario, you experience downtime in your primary data center and failover to the second data center -- but then that second data center fails too soon thereafter. If you don't think that could happen, consider that some of the cloud outages have been worldwide ones where all data centers are unavailable simultaneously.

Leveraging multiple data centers is a good idea - but don't represent that as adding more 9's to your availabiility. It's not a supportable claim.

How to Approach Cloud SLAs: Pessimistically
The only sane way to approach cloud computing SLAs (or any SLA for that matter) is to be extremely pessimistic and assume the worst possible case. If you can design mitigations and contingency plans for the worst case, you are well-prepared for any eventuality. If on the other hand you are "hoping for the best", your plans are extremely shaky. Murphy's Law should dominate your thinking when it comes to designing for failure.

Do not forget that Cloud SLAs are not a promise, they are a target. There may be some consequences such as refunds if your cloud vendor fails to meet their SLA, but that is usually little consolation for the costs of your business being down.


Cloud SLA Planning Best Practices
1. Become fully familiar with the SLA details of each cloud service you consume.
2. Keep in mind many cloud services are in preview/beta and may not be backed by any SLA.
3. Don't think of an SLA as a guarantee; your cloud provider will not always meet their SLA.
4. Do not confuse the availability SLA for individual cloud services with the overall uptime for your solution. There is no SLA for your solution, and the more services you use, the less uptime you are likely to have.
5. Do not plan on being lucky.
6. Build in contingency planning for a data center failure that allows you to fail-over to another data center. Yes, this will be extra work and increase your costs. Yes, it is worth it.
7. Remember that worldwide outages can occur, and you need a contingency plan for that scenario as well.

To Cloud, or Not to Cloud?
Does all of this mean the cloud is a bad place to run your applications? Not at all - it could well be an improvement over what your local experience is. And, there are significant benefits to running in the cloud that may more than offset the inconvenience of occasional downtime. The important thing is that you approach the cloud eyes-open and with realistic expectations.

Monday, February 11, 2013

Microsoft Certification Exam 70-481: Essentials of Developing Windows Store Apps using HTML5 and JavaScript

I am working toward the MCSD Windows Store Apps (Windows 8) certification, which is available in two flavors (JavaScript and XAML). Today I took and passed the second of three exams on the JavaScript track, 70-481: Essentials of Developing Windows Store Apps using HTML5 and JavaScript.

I'm not allowed to share details about the exam, of course, but I can share how I prepared for it. The first thing I'll say is that it is not an easy exam. I took it and narrowly missed passing a week ago, and on my re-take today I passed. So the first bit of advice is, be sure to get a Second Shot voucher from Prometric when you're signing up to take the exam - you might need it.

I chose the WinJS exam track because I've been deep on HTML5, CSS, and JavaScript for the last two years - my JavaScript skills are fresh and my XAML is a bit rusty. The first exam in the MCSD Windows Store Apps WinJS track is the same first exam of the MCSD Web Applications track, 70-480, which I'd already taken and blogged about. That's a convenient arrangement if you want to go for a "double major": a dual MCSD in Web Apps and Windows Store Apps. Here are the three exams in the MCSD Windows Store Apps WinJS track:

70-480: Programming in HTML5 with JavaScript and CSS
70-481: Essentials of Developing Windows Store Apps using HTML5 and JavaScript
70-482: Advanced Windows Store App Development using HTML5 and JavaScript

I think the main reason I found the exam difficult is that it was so comprehensive: there's an awful lot going on in Windows 8 and the exam covered a lot of territory. You can see the list of what's covered here in the Skills Measured section. Secondly, I think I faltered a bit the first time around on namespaces - I memorized them more solidly for the second time and I think that helped me better discern right answers from wrong ones.

Here's what I did to prepare for the exam:

• Develop Windows 8 Apps
I've authored about 5 "real" Windows 8 apps, several of which have gone through the Windows Store process successfully. I think you need this hands-on experience in order to be prepared for the exam.

• WinJS Samples
The WinJS samples are really valuable. There are many of them, - most of them short and to the point -- and they are a tremendous learning aid.

• Documentatio
Read the documentation. Sure, some of the doc pages are dry or just list class details without much of an explanation - but there are also great conceptual pages.

• Blogs
I also found a lot of good information in blogs when I searched on various topics.


• Walk the Skills Measured List
I went through the Skills Measured checklist and ensured I knew the basics about each skill listed.

• Microsoft Virtual Academy
There are 8 hours or so of videos on Microsoft Virtual Academy to prep for this exam by Jeremy Foster and Michael Palermo - watch them. It's called the Developing Windows 8 Apps with HTML5 Jump Start (note: there's also a jump start course available for the first exam, 70-480).



• CodeShow
Jeremy Foster's CodeShow solution contains lots of great samples, all in one Visual Studio solution.



Well, there you have it. Next month I hope to summon the nerve to go for the Advanced exam and obtain my MCSD for Windows Store Apps.

Tuesday, January 22, 2013

The Mobility Iceberg

Doing Mobility well requires first of all that you build a fantastic app, and that needs to include designing a great user experience, making the app useful and productive, and a smooth deployment system such as an App Store or enterprise distribution. But those are just the visible, tangible parts of an app. There's a lot more that goes on behind the scenes, as the iceberg diagram below shows. Let's take a look at the ingredients of a superior mobile app.

There's more than meets the eye to mobile app development

User Experience
A compelling user experience is an absolute requirement: a high bar has been set for apps, and apps that don't meet expectations rarely get invoked a second time. A compelling experience, in contrast, will instill user loyalty. User experience design, as any UX designer will tell you, involves more than graphic and visual design and layout: there's also the user research that goes into ensuring the user audience and their objectives are well-understood.

The rest doesn't matter if the experience is not compelling
 
Good user experience design can turn a mundane app into an exciting one. One technique for this is gamification, in which a fun factor and element of competition is injected into the experience. For example, an app for field salespeople might include a leaderboard to show who is on top and encourage others to vie for the top spot. Or, your app might award badges based on achieving objectives.

Functionality
A beautiful app that doesn't perform useful work isn't much good: you need both form and functionality.

Good mobile apps require deliberate design: a mobile app that is merely a bolt-on to your web presence may not be very usable if screens are hard to make out, controls are too small for touch, data entry is overly-complex, or forms have to be filled out in a single sitting. Mobile First by Luke Wroblewski is suggested reading.

Although many apps are consumer-oriented or about entertainment, mobile apps can serve business well. Below is a sales battlecard app we equip our sales staff with, which describes the service lines, showcase gallery, and leadership team for each of our consulting practices.

     
Mobile apps are for business, too

The above app is useful, but even more useful are apps that let you get work done.

The app shown below is used for talent acquisition, namely interviewing and evaluation of candidates. This process involves multiple interviews of a candidate (by phone or in-person), then integrating and considering everyone's feedback. Sometimes this takes longer than it should because people are busy or traveling--an opportunity for a mobile app to shave time off the process. By focusing on just this part of the talent acquisition process, the UI can use a simple approach: thumbs up/down and comments from each interviewer. By being able to register evaluations immediately even when not near a computer, the evaluation process advances more rapidly.

Great business mobile apps let you get work done
 
Distribution
Your app needs to be distributed in a way that makes it easily discoverable, and it needs lifecycle management.

You'll typically use an App Store or enterprise method of mobile distribution on the deployment side. You'll want to ensure there are mechanisms for feedback and support for your app and that someone is servicing them.


Application Lifecycle Management (ALM) involves putting in place a process for handling updates that includes build automation, testing, deployment, and the store acceptance process. From revising the code to getting vetted app updates in the hands of users should be a well-defined process.

Back-end Services
It takes back-end services to properly support the digital lifestyle. With users expecting to get at their apps and data anytime and anywhere, on any convenient device, back-end services and data provide the highly-available backbone that makes it all possible. They need to be written for scale and reliability.

Global Infrastructure
There's no better place for your mobile back-end than in the cloud. The cloud gives you high-availability, redundancy of app servers and storage, and affordable global presence. It's the nature of mobile/social apps that usage can suddenly burst or just as suddenly deflate, and often the user audience is geographically dispersed. The cloud is perfect for fluctuating load and global reach because of its easy scale, consumption-based pricing, and worldwide collection of data centers.

Business Intelligence
Capturing and analyzing the activity of a mobile app across its user base can provide great insights for a business. For example, if you released an app and saw it being more frequently used in a particular geography or demographic, that would tell you something. If some of your app's features are used much more than others, that would likewise inform you. With sufficient tracking and analysis, you may realize great insights about your market, customers or employees.

Mobile apps are hot, but don't forget the mobility iceberg: a successful mobile app requires work and attention to detail in many areas. The outcome of all that work is worth it, but you shouldn't underestimate what's involved.

Monday, January 14, 2013

Adventures in Windows 8: Task Board, Part 2: An HTML5-JavaScript Windows Store App

I've been learning Windows 8 for the last year, and I blogged about the first serious app I developed last April: Adventures in Windows 8: Task Board, Part 1: An HTML5-JavaScript Metro App. Here finally is Part 2, where I'll describe what I did to bring the app from a prototype created during the preview days of Windows 8 to a functional app now listed in the Windows Store.

Project Task Board app in Windows Store Today

Original Version
You have to walk before you can run, and this app was never meant to be more than a simple one: if you have a project with tasks, being able to show them as "cards on a wall" is often useful to project teams. Implementing this would give me a good start on Windows 8 app development, as I'd need to learn app basics like the App Bar, handling different screen sizes and orientations, touch interaction, and styling. And, of course, there's that process of getting into the Windows Store. My goal was to have my app in before the end of 2012. I made it, but not without a certain amount of work.

I had to choose a development language: WinJS/HTML5, C#/XAML, or C++/XAML. I had equally good backgrounds in the first two, but as I've been immersed in HTML5 and JavaScript for the last year it made sense to go the WinJS route. I'm glad I did, because I eventually ran into a problem I don't think I would have been able to resolve in a XAML approach.

The first incarnation of this app was ready a full year ago in January 2012, and I showed it at various venues including a Windows 8 developer event in downtown LA. When Windows 8 went to release and the Windows Store became active, it was time to revisit Task Board and bring it home. I ran into a few hurdles, let's look at them and how they were addressed.

Original Task Board App during Windows 8 Preview Period

Breaking Changes
First, my project would no longer build under the Windows 8 release. That's kind of the chance you take when you jump into pre-release development. My acquaintances at Microsoft did offer to take a look at my project, but I ultimately decided to start with a fresh code base, for a number of reasons beyond API changes: I was better equipped to structure the solution properly now, and I had a problem in that drag-and-drop of cards no longer worked.

Drag and Drop
Drag and drop is an essential aspect of this app: being able to drag cards around is the whole point of its existence. The method I used for drag-and-drop in the original pre-release app simply no longer responded to touch in the release version of Windows 8. I would have to figure something else out.

I started experimenting with other ways to handle drag and drop, also asking Microsoft for suggestions, and ultimately found two promising avenues: jQuery UI, or the IE10 API for touch events. I chose to try jQuery UI first, and that worked just fine. This is where I think you have an advantage in WinJS over the XAML approach: there are a lot of great JavaScript libraries you can leverage, and it's possible to "get under the hood" when you need to.

jQuery UI drag-and-drop is quite simple and does not require a lot of code once you come to understand it, and it's well-documented. Here's what my code looks like to set up and handle drag-and-drop of cards:

function wireupCardsForDragging() {
    $(".draggable").draggable({
        drag: function (event) {
            makeTopMost(this.id);
        }
    });

    $(".draggable").click(function (event) {
        editCard(this.id);
    });

    $(".droppable").droppable({
        drop: function (event, ui) {
            $(this);

            var tileId = ui.draggable[0].id;

            if (tileId.substr(0, 4) === "card") {
                var cardNumber = parseInt(tileId.substr(4), 10);
                cards[cardNumber].left = ui.draggable[0].style.left;
                cards[cardNumber].top = ui.draggable[0].style.top;
            }
        }
    });
}

A "card" is a simple entity. In HTML, this small markup renders a card:

<div class="card yellow draggable" id="card1" style="left: 50px; top: 140px;">
    <div class="heading">
        <span class="taskNumber">1</span>
     <span class="title">Ramp-up</span>
        <span class="priority">P1</span>
    </div>
    <div class="desc">Wire up user interface.</div>
</div>


Internally, cards are represented by card objects, indexed by task number:

card = {
    top: '120px',
    left: '50px',
    number: 1,
    color: 'yellow',
    title: 'Requirements Gathering',
    description: 'Analyze requirenents and capture user stories.',
    owner: 'dp',
    priority: 1,
    hours: 80,
    status: 'in progress'
};

Arranging, Tiling, and Stacking
In the final edition of the app, I wanted the user to be able to drag cards around, but I also wanted an "arrange" command that would nicely glide the cards into an orderly arrangement. I'd implemented this in the prototype as tiling, where each card was fully visible. In the final app, I also added a choice for stacking, where each card is closely overlaid and all you can see are the titles.

 
Cards Stacked

Tiling or stacking are App Bar commands. To provide the glide effect during arranging the cards, I used jQuery animation.

Preparing for Store Submission
Now to tackle Windows Store submission for the first time.

One area I felt I should address was content: I'd used a green blackboard image as a background in my prototyping, purchased from a stock photo side. It wasn't clear to me if the terms would allow me to use that in app submitted to an app store, so I removed it. This gave Task Board a rather dull look with just a plain green background. Mindful of the approaching end of year and my goal of getting an app in the store before that, I decided to worry about fancier background another time. That meant the app as I submitted it looked like this:

Project Task Board in Windows Store, Release 1

Cloud storage was another area I wanted to address. The original app could save and load a "project file" of tasks from the local file system, but I wanted people to be able to share projects collaboratively. It turns out I didn't need to do anything special, as the file open and save picker dialogs include SkyDrive support. The user can browse to their SkyDrive folders just as easily as to local folders when opening or saving a project.


Store Submission, Release 1
The store submission process for a company first requires you to establish an account and have your corporate identify verified. This takes a bit of time and you need to ensure someone in authority is available to be contacted by Microsoft.

With verification out of the way, you're ready to try submitting an app. The Windows Store dashboard takes you through a nice guided experience where you register a name for your app (I couldn't get Task Board, but Project Task Board was accepted), describe it, upload packages, provide notes to testers, and so on. Here's what some of the application detail looks like, summarized.






Store submission passed on the first try, and my app was in the store!

Release 2
A few weeks later, I decided to upgrade the app. I wanted a more sophisticated background, and I also wanted to give the user a choice of background colors and solid vs .patterned background.

I found a good CSS background to use for a background pattern at the CSS3 Patterns Gallery site. This gave the app the appearance you see at the top of this post.

To allow the user to change the background color and style,  I added a flyout to the settings pane. Now, the user can get to an options flyout pane by selecting Windows+C and Settings, then Options.

Options Settings Flyout

My second app submission was accepted, a few hours ago as of this writing, and you can see its Windows Store listing here
.
Summary
Windows 8 has come a long way in the last year, and it doesn't take more than a simple app or two to get your "sea legs" with it. Creating Project Task Board and bringing it to the point where it was accepted in the Windows Store was educational, a bit challenging, and fun. I'm now working on much more sophisticated apps, but this first app was a very necessary exercise in getting started.