I made an app for Windows Phone 8

It’s winter and I’m on a holiday so I have lots of free time at my hands. I thought that maybe I could spend it in a productive fashion, so I wrote an app for Windows Phone 8.

The app itself is a GitHub client, which lets you check out your repositories, view files and diffs and do other stuff. It’s open source, of course, and hosted on GitHub. Check out the source code!

Connecting to the API

I knew it won’t be a walk in the park, but there’s a very nice project on GitHub which lets you use the whole API, called OctoKit.NET. ┬áIt even has a portable library for Windows Store. But not for Windows Phone, so you have to take portable as in portable to another Windows 8 PC. Something is seriously messed up here, and we’re heading towards a new kind of DLL hell.

But it’s not the fault of the guys behind OctoKit, this is the current ecosystem. I thought that I’d fork their project and do some changes to make it a portable library for Windows Phone 8. Nope, that’s not going to happen. Networking code is not part of the portable stuff, you have to do that in your Windows Phone project.

So I did that there. Wrote a client for the API parts I actually needed, and used that. It wasn’t a huge work, and JSON.NET made it very easy as well.

MVVM

There’s decent MVVM support in the WP8 controls, but I ran into some horrible stuff which seriously messes up properly architectured code. One being the ApplicationBar control, which doesn’t support bindings. Even the sample project has that horrible commented out stub like BuildLocalizedAppBar. Also it doesn’t support commands, so you’ve to have event handlers in your XAML code behind, instead using the ViewModel for this stuff. That’s a shame. I hope that Microsoft fleshes this out in some upcoming release.

Some limitations

I wanted to build a page for viewing your source code files and diffs. I’m a fan of short files with one class in them, but there’s a perfectly fine chance that files grow bigger. The idea was to grab a TextBlock and bind it to the file text. Later when I feel like syntax highlighting, I’d ditch the TextBlock and try something else.

However I noticed that a TextBlock (or any other control, by the way) tends to cut off its content after some height. It turned out that the maximal control height in WP8 is about 2040 pixels. So I wrote an abomination to split the stuff into small chunks and add it dynamically to a StackPanel. Ugly and broke MVVM brutally. I know about a control written for WP7 that doesn’t cut off stuff, but there were some changes between the versions, and it wasn’t worth the effort to adapt it for a fun project like this.

Lack of unit testing support

Now this almost made me gave up the project. I wondered what can be the Windows Phone 8 Unit Tests template in Visual Studio, but I never thought that they want me to run my tests on my actual phone (or buy Windows 8 Pro and use an emulator). Am I supposed to connect a phone to a build server and run the tests there if I’m serious about WP8 development?

The excuse was laughable at best: WP8 code relies so much on WP8 libraries that the unit tests will surely touch libraries depending on the platform. I did a fairly big amount of SharePoint unit testing, which enforces that too, but never needed to run my tests in a SharePoint server. The whole point of unit tests would be to test a unit of code, and if you really need it, provide some mocks or stubs for the dependencies. I think that Microsoft got this one really bad.

So what’s the point?

Windows Phone 8 as a development platform doesn’t seem that mature for me. There are lots of quirks and you have to do lots of workarounds for simple stuff. A template project requiring workarounds is something I haven’t seen yet anywhere else.

The development tools on the other hand are fairly robust, it’s a pleasure to write mobile apps with Visual Studio at last. However Microsoft doesn’t seem to be in a position to ship incomplete libraries for developers, as this clearly won’t help overcome their chicken and egg problem of nobody develops on the platform because there are not enough users because nobody develops apps.

I think I’d consider iOS as my primary mobile development platform, and write some fun side projects if I have the time and resources for WP8.

Advertisements