Trying out Windows Phone 7

Recently I’ve been working with a friend of mine on writing some password management clients for various platforms. After developing clients for Mac OS X and iOS, I’ve started working on a Windows Phone 7 version. I have to say, so far I’m very impressed by how simple and straight forward things are, especially compared to targeting iOS. Granted I have more experience with .NET than Objective-C and Cocoa, but aside from that Windows Phone 7 has some pretty big advantages over Cocoa Touch when it comes to ease of authoring applications.

The first is data binding. To me, data binding in .NET has always been tops. Coming from Delphi where data binding only works for a specific set of database-oriented classes, the data binding in .NET is ubiquitous and straight forward.

Cocoa also has binding, and it works well enough once you learn how to set things up in Interface Builder. However, Cocoa Touch is missing binding altogether. I guess it didn’t make the cut when it comes to performance and size constraints. This means all data display under iOS is manual. This is a pretty big productivity hit, depending on the type of application.

Another area where I think Windows Phone 7 is far ahead in terms of usability is the application navigation. Navigating from page to page is simple and straight forward, following a model similar to navigating web pages. You don’t have to worry about views and controllers and view controllers and navigation controllers and tab controllers.

In general, developing an application is just simpler and far more forgiving. Adding an application bar is simply a matter of copying in some XAML. Trying to make your iOS application use a UITabController is not trivial. Trying to make your iOS application use a UITableController and a UINavigationController, simply to get an application with tabs that allows you to navigate forward and back, is mind numbing. I’m sure you get used to it, but you shouldn’t have to.

Lists in Windows Phone 7 are simply a ListBox with templating that can be data bound. Makes sense to me. And while UITableView is something you can wrap your head around, I wouldn’t say it’s easy to use. It reminds me of TVirtualStringTree for Delphi. Powerful to be sure, but it takes you half an hour just to get something showing.

Another example: if a keyboard is shown in a Windows Phone 7 application, automatically (and obviously, to me), the contents will scroll if they are obscured by the keyboard. This doesn’t come for free, or easily, when developing for iOS.

To illustrate how simple things came together for me, I sat down a few nights ago to do a bit of work on Password Tote for Windows Phone 7. I already had an application that let me log in and display a list of passwords in a ListBox. You could select a password to see its details. I wanted to add an application bar, a screen for recent passwords, one for favorites, one for categories, and add the ability to show passwords given a category.

Using Google and LINQ, I was able to get all of that done in a little over an hour.

Adding the application bar was easy. There are several tutorials online. It’s basically a matter of pasting in some XAML, adding some images to your project, and handling event calls for button presses. Once I had my application bar and the various new screens, I was able to add a ListBox to each screen, and then wire up each screen using the already present password list and some LINQ.

Categories:

List<ServerPassword> passwords = (List<ServerPassword>)PhoneApplicationService.Current.State["passwords"];

var categories = (from p in passwords
                    where p.CategoryName != null
                    select p.CategoryName).Distinct();

categoryListBox.ItemsSource = categories;

Favorites:

List<ServerPassword> passwords = (List<ServerPassword>)PhoneApplicationService.Current.State["passwords"];

var favorites = from p in passwords
                where p.Favorite
                select p;

favoriteListBox.ItemsSource = favorites;

Recents:

List<ServerPassword> passwords = (List<ServerPassword>)PhoneApplicationService.Current.State["passwords"];

var recents = (from p in passwords
                orderby p.LastAccessed descending
                select p).Take(30);

recentListBox.ItemsSource = recents;

Passwords for a Category:

List<ServerPassword> passwords = (List<ServerPassword>)PhoneApplicationService.Current.State["passwords"];
var categoryPasswords = from p in passwords
                        where p.CategoryName == categoryName
                        select p;
passwordListBox.ItemsSource = categoryPasswords;

So far I’m very excited with how productive I am developing for Windows Phone 7. While Cocoa has predicates, without data binding and given the non-obvious controller setups required just to get things functioning under iOS, Windows Phone 7 is a breath of fresh air. Every time I return to .NET development, either from Delphi or now Cocoa, I am always greeted with a feeling of “damn, this is easy”.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s