Monday, September 30, 2013

Tuesday, September 24, 2013

Top ten Windows Phone app firms? - I don't think so!

The windowsphone-news site today pointed out a report by Best Web Design Agencies for what it reports are the "Top 10 Windows Phone apps companies in United Kingdom".



Hmmm. Let's take a look.

Actually, I'll save you the effort. Here's what I've found:
  • Of the ten best UK companies, one is in the USA and one is in India. How's that work then?
  • Two of those companies don't claim to do Windows Phone development on their website. One does Windows Embedded Compact and one does Windows Mobile, which it still claims "now accounts for a considerable share in the smart phones OS market".
  • Four of the companies specifically refer to "Windows Phone 7".
  • Only one lists any Windows Phone development on the site in their portfolio or case study sections.
  • The one that does show some portfolio work leaves me underwhelmed. Especially when they're supposed to be among the best.
Apparently, the agencies have "been put through a rigorous examination to uncover how well they perform compared to industry standards and competitors." And the results are the work of "A specialized team of researchers examine thousands of applicants each month who are seeking to be ranked as a top mobile development product or service."

I call BS.

There are some great companies building some incredible apps. They're just not included in the above report.
To be fair, I don't know any of the companies in the report and am not aware of seeing any of the apps they've built. They may be good. We've just no way of confirming it for ourselves. We just have to rely on the opaque, anonymous reviews performed by a company who asks agencies to apply for a ranking.

This report doesn't reflect the state of those agencies who are doing Windows Phone development. If I was to look at the companies in the report to get an idea of the Windows Phone platform I'd consider it to be in much worse shape than it really is.




Wednesday, September 18, 2013

Confirming that the user wants to leave the app

I was recently asked if there's a way to show a message box when exiting the app by the home (windows) button.

The thoroughness of my response was remarked upon so I thought I'd share it here to let everyone know my thoughts.



AFAIK the only guaranteed way of forcing a (confirmation?) message box when leaving an app, via the public SDK, is by overriding the back button. (There may of course be undocumented or private APIs that exist for this though)
Obviously overridding the back button behaviour will only take effect when leaving the app by pressing the back button.
Leaving the app in any other way will cause the application level events to be triggered and these cannot block indefinitely (and actually only have a few seconds to run) as to do so would risk compromising the OS. Imagine for instance if you could throw up a message box when someone left an app for any reason (and cancel the navigation dependent upon the result) this would enable the creation of an app that could prevent the user EVER leaving the app. This would be the equivalent of being able to override the other hardware buttons or stop someone launching another app from system UI (E.g. Toasts, notifications or answering incoming calls)
There may be a few cases such as LOB apps where this may be desirable but it doesn't make sense in terms of a general purpose, consumer focused, mobile operating system.

Typically apps try and force a confirmation on exit to avoid accidentally closing the app. There are a few motivations behind this.

  1. The company behind the app isn't familiar with the OS and closing apps via the back button and so they assume the users won't be either. - Coding for this just reinforces uncertainty in the system and an inconsistent experience across apps.
  2.  The navigation model within the app is confusing and users aren't always clear where they are in the app and so don't realize they're exiting by pressing back. - This is an IA issue and should be solved with better UX design.
  3. Users often close accidentally and have to relaunch the app, which is very slow. Confirming closing is faster than restarting the app and so seen as beneficial. - The better solution here would be to improve startup/launch time. This would also help all users of the app and not just those who close the app accidentally.

The other reason I've seen for wanting to confirm application exit is if there is entered but unsaved data. In this scenario it is normally better to automatically save it (login credentials being the usual exception) and then restore it, or ask the user if they want it restored when the user  returns to the app. The nature of the data, the app and how they return to it can also have an impact on what is most appropriate here.

Sorry I can't be more explicit but I hope this helps.
If I can help further or you want to discuss specific scenarios, please get in touch.



When needing to bind to a platform specific class but the ViewModel is a PCL

This is a less than ideal scenario. I've made by ViewModel a PCL as an aid to making it easier to write "proper unit tests" (i.e. run within Visual Studio) but now I discover I need to add a map to the app and show a dynamic collection of locations (pins) on the map.

<disclaimer>I'm working on a proof of concept app and the requirements are very "flexible" at the moment. Of course I'd plan things better than this in advance under normal scenarios.</disclaimer>

Starting simply, I want to add an ObservableCollection<MyPin> to my VM. But there's a problem.

    public class MyPin
    {
        public GeoCoordinate Coordinate { getset; }
        public string Name { getset; }
    }

The problem is that The GeoCoordinate lives in System.Device.Location and so can't be referenced in the PCL. This means I won't be able to bind to it directly. Frustrating!

frustration

Upon reflection this makes sense. That I'm using a GeoCoordinate is an implementation detail of the UI. It could be displayed as anything. It just makes my life a little bit more complicated.
In reality my class should be more generic:
    public class MyPin
    {
        public double Longitude { getset; }
        public double Latitude { getset; }
        public string Name { getset; }
    }

But this doesn't help with my binding.
So, I need to be able to convert a Latitude and Longitude value into a GeoCoordinate. Sounds like a job for an IValueConverter.

I'm not a big fan of using ValueConverters. They have 2 issues in my mind.
1. They are a performance overhead.
2. They are hard to write coded tests for.

These aren't really issues any more though.

1. This was true in the early days of WP7, where having lots of converters could noticeably impact page loading, but this isn't really a problem any more. You'd have to use loads for this to be an issue on WP8 and I'm only using it where I have to.
2. In this instance I'm only using them for a presentation details though so a lack of automated tests for how locations are displayed on the map isn't a big deal.

So let's add a converter:

public class PinToGeoCoordinateConverter : IValueConverter
{
  public object Convert(object value, Type targetType, object para, CultureInfo culture)
  {
    var pin = value as MyPin;
 
    return pin != null ? new GeoCoordinate(pin.Latitude, pin.Longitude)
                       : new GeoCoordinate();
  }
 
  public object ConvertBack(object valu, Type targetType, object para, CultureInfo culture)
  {
    throw new NotImplementedException();
  }
}
Then I just define my resource:
    <phone:PhoneApplicationPage.Resources>
        <converters:PinToGeoCoordinateConverter x:Key="PinToGeo" />
    </phone:PhoneApplicationPage.Resources>

and then I can use it
    <map:Map x:Name="TheMap">
     <toolkit:MapExtensions.Children>
      <toolkit:MapItemsControl>
       <toolkit:MapItemsControl.ItemTemplate>
        <DataTemplate>
         <toolkit:Pushpin GeoCoordinate="{Binding Converter={StaticResource PinToGeo}}"
                          Content="{Binding Name}" />
        </DataTemplate>
       </toolkit:MapItemsControl.ItemTemplate>
      </toolkit:MapItemsControl>
     </toolkit:MapExtensions.Children>
    </map:Map>

Simples.

All in all this feels like a bit of a kludge. At first it felt like a very bad approach but as time goes on I'm feeling more comfortable with it. I don't know if this is just be getting used to the idea or if it's really not that bad after all.

If you have any better approaches to dealing with this scenario or there are some issues you see with the above I'd love to hear from you.



Tuesday, September 17, 2013

Why my Win8 tiles weren't updating


I spend the vast amount of my development effort focusing on Windows Phone but also do some Windows 8 work.

Just recently I noticed that the live tile for an app wasn't updating to show the latest content.

The tile was updated with a TileUpdater instance and by watching the network traffic I could see that the requests for content were being sent and the server was returning a 200 response with what looked, at a quick glance, like valid content. After all the same code had been running for a year without issue.

Unfortunately, AFAIK, there is no error raised or recorded anywhere when invalid content is returned by the server. Despite this, as the only thing that had changed was the pay load of the notification so I started my investigation there.

Taking a proper look at what was happening and what might be going on, I quickly spotted a probable cause in the returned XML.

There was an unencoded ampersand in the text. 

Oh I feel foolish. Especially after I make such a fuss about developers who use but don't understand XML properly. :(

Anyway,  the lesson here is that you should ALWAYS make sure that your XML is encoded properly. Especially with regards tile information. If your tiles stop updating this is probably a good place to start looking. ;)


Friday, September 13, 2013

My #Azure subscription migration saga continues

Following on from my previous post about migrating Azure services between subscriptions.

After I moved (deleted and then recreated on the new subscription) my web sites, I was told that they would be able to move my mobile services.

But then:


"Due to system issue, our backend team was unable to migrate the Mobile Services from source to destination subscription and they are working to fix it but we do not have any ETA for it.
You would need to back up the Mobile Services from Source subscription and re-deploy it to the destination subscription. I sincerely apologies for any inconvenience caused due to this."
 :(

Yep, I need to delete the existing services and then recreate them on the other subscription. Even though they previously, after 2 weeks back and forth, was told they could do it. And all this time I'm paying for something that would be free on the other subscription.

Okay, it's a good test of my backups and ability to recreate these services if something went wrong but I can't help feel that I'm working round what should really just be a setting on their end. After all, it is a setting for some of the other services.

The lesson in all this: Moving services between subscriptions is a lot harder than it should be. If you have to do this in the future, be aware of possibly having to delete and recreate services yourself. In fact it will probably be quicker (and cheaper?) if you just do this yourself and don't ask them to do it for you.

Lesson 2: This was handled by the billing support department of Azure. This is the free support that everyone gets. This is not from the, paid, technical support. - I guess I'm gettting what I'm paying for.