Tag Archives: Windows Phone 7

Now, 2011, is a great time to move into Windows Phone development

Earlier this week, over at The Guardian, Matthew Baxter-Reynolds essentially asked the question: Where do the Windows Mobile developers go now?

Except that the article was actually called Why Android is the natural alternative to Windows Mobile for developers. The strapline for Matthew’s article added a little more meat to that statement: “When Microsoft killed off Windows Mobile, it left would-be developers with experience in its tools who wanted to build ‘line-of-business’ apps with a problem: what could they target?”

Matthew’s article covered many topics. It touched on:

  • fabrication of Windows Mobile and Android devices
  • line of business application development using the iPhone, Android and Windows Phone
  • patents
  • BlackBerry and RIM

It’s a well-written piece and I would urge you read it and Matthew’s other material.

I’d like to focus on one small piece of Matthew’s article. Specifically the piece about Windows Phone:

Windows Phone is also a pain because no one has them and no one (yet) wants to buy them. I believe this will improve when Windows 8 hits the market next year, but until then it’s difficult to pitch to customers. Plus you would think migrating software and apps from Windows Mobile to Windows Phone would be easy. It’s not, because of the radically different Silverlight-based user interface model. Windows Mobile is .NET-based and Java-esque.

It is fair to say that much has been written [during 2011] about the uptake of Windows Phone devices. The phone manufacturers [HTC, Samsung, LG, etc.] must be furious with the way the phone carriers [the likes of O2, Vodafone, T-Mobile, Orange, Three] have failed to market their Windows Phone products. It wasn’t until I was at DDD North on the 8th of October 2011 that I saw more than one Windows Phone device in the same place. In fact, as @scottisafool noted, by virtue of there being a handful of Windows Phone devices in the same place, it put many High Street stores and supposedly phone-savvy supermarkets to shame.

Every market has to start somewhere. Windows Phone is the new kid on the block and it has moved into a block that’s already very well established; current residents include Android, iOS and to some extent BlackBerry. Given that major pundits are referring to Windows Phone as the third member of the mobile ecosystem, I believe it’s fair to follow Matthew’s recommendation to ignore BlackBerry. Unless RIM have an ace up their sleeve, I have to agree with Matthew.

Despite this apparent low uptake, it hasn’t thwarted the application developers. As of today there are some 35,000 applications in the Windows Phone Marketplace. Many of the reputable news sources for Windows Phone report that about 90% of the core apps and games that “the others” have on their iPads, iPhones and Android tablets are available for Windows Phone devices. Whilst that suggests the market is pretty much sewn up, there are still gaps that need filled. Contrast this with the fact there are over 500,000 applications available for iPhone and Android devices and it’s fair to say Windows Phone has some catching up to do. Assuming, of course, that you believe catch up is required. One has to ask how many of the 500,000 or so applications are unique or are so trivial that calling them an application is an overstatement.

Nokia’s presence in the Windows Phone ecosystem should not be under-estimated. Rumours about their device line up have been rife. Leaked photographs of their proposed Windows Phone device(s) have been published, analysed and analysed again. This weekend, October 21st and 22nd 2011, TV viewers in the UK started to see subtle hints from Nokia, the Sea Ray made very short but pointed appearances between adverts in major shows on Saturday evening. This advertising, albeit very short, is very welcome. Windows Phone marketing has been beyond disappointing, a fact that cannot be denied and a fact that isn’t UK-specific. I would hope that advertising picks up as we get closer to Nokia World, October 26th 2011, when Nokia’s devices will be revealed to the public for the first time. Nokia have the ability to produce, market and sell millions of devices. In Europe, they are virtually independent of any particular demographic: kids, teenagers, housewifes, workers / business users, pensioners, the military…they all use Nokia devices.

Whilst Matthew believes no one has them [Windows Phone devices], he does believe that people will want to buy them in the future. And that’s the key: the future. The future for Windows Phone isn’t 12-18 months away, or further. It’s between now and Q1 2012. It’s now. Microsoft’s careful approach, whereby they built Windows Phone version 7.0, used customer feedback to refine it with NoDo and subsequently with Mango, mean they have an operating system that is a first class citizen in the mobile space. It can compete, and win, against the likes of iOS and Android.

Windows Mobile developers will continue to have their market in line-of-business applications for as long as there is demand and device availability. Where should they turn to next? Matthew believes that Windows Mobile developers should be focusing their future development efforts in the Android space. I have to disagree with that thought! The Android market is saturated. Android is an operating system that suffers from considerable fragmentation; there are many versions of Android, spanning major version numbers, still in use today. Examining the various platform versions, I see there are only a few flavours of Android that are “accepted” as primary development targets, which is a step in the right direction. Even if you target the three major versions of Android, the open source nature of Android means that developers might find themselves having to work around issues that are very device-specific.

Windows Mobile developers will find themselves moving from Microsoft’s .NET platform over to Java, which is means moving away from Visual C++ and the Visual Studio IDE. Thankfully, the existence of third-party tools such as MonoDroid, allow us to write C#/.NET code that can be deployed to the Android platform. However getting started with MonoDroid will cost you at least $399, which is very much worth it if you wish to avoid entering the Java camp. On the plus side, once you’ve written your application, it can be submitted to the Android Store and available for sale within hours. Ultimately, moving from Windows Mobile to Android should be considered a complete platform change: all of the tools, software development kits (SDKs), frameworks and deployment targets have changed. You could be buying into a whole new set of problems.

Windows Mobile developers who are considering a move to iOS are in for a similar surprise. Apple’s iOS relies on the Objective-C programming language. I won’t go into Objective-C in this post, but if you need to read more, there’s good content in this article over at The Guardian. Whilst iOS developers don’t suffer from Android’s OS fragementation, they do suffer from Apple’s lengthy application submission process. I’ve heard some developers say the application submission process can take weeks. I’ve also heard that Apple can reject applications without providing any reasons as to why the rejection occured – I believe Apple have gone as far as to ignore some Google application submissions! Not surprisingly, tools such as MonoTouch exist, whereby we can write C#/.NET code that runs on iOS. If I was developing for iOS, I’d be seriously considering the $399 cost for MonoTouch. Again, moving from Windows Mobile to iOS should be considered a complete platform change and one that may have a significant cost attached to it.

Contrast Android and iOs with the Windows Phone modus operandi. Windows Phone applications can be developed using a tool that Windows Mobile developers should be reasonably familiar with: Visual Studio. Windows Mobile developers have been used to working in a managed code environment for some time now and they are particularly comfortable with the Visual C++ language. Windows Phone development will mean developers use their choice of C# or Visual Basic – this shouldn’t be a major undertaking as it’s not a complete platform change. Windows Mobile developers should have a good grasp on the .NET framework. The move from Visual C++ to C# is, in my opinion, fairly painless. Yes, they will have to contend with a new deployment target, however it’s not a case of “all change” as it would be for Android and iOS, developers get to stay in the overall Microsoft ecosystem. And or course, the Windows Phone development tools are free, which is always good.

Many businesses are already allowing Windows Phones to form part of their device portfolio, whether the device is on the corporate asset register or simply owned by an individual. Once the consumer market opens its mind to the fact there are alternatives to Android devices, iOS devices, BlackBerry devices, the business space will see similar such uptake. Consumers have day-jobs, they don’t want to find themselves using a state-of-the-art Windows Phone device to manage their personal life and then to have to use a candy bar to make phone calls in their corporate life. Nokia used to be in the candy bar market, especially for corporate customers…I still have a Nokia 6021 gathering dust! Ironically, I carry a Palm Treo 750 (Windows Mobile 6) instead of the Nokia 6021. I also carry an HTC HD7 Windows Phone – it’s my personal phone. The HD7 gets more use than the Palm does – putting Windows Phone aside, the screen size makes it so much more useable.

Whether Windows Mobile developers choose Android, iOS or Windows Phone, they will still find themselves building their line-of-business applications using a new user interface metaphor – gone are the small buttons and stylus-inspired Windows Mobile user interfaces. Windows Phone, like the iPhone and Android is all about touch, sliding, pinching and tapping. Despite the ease at which I believe a Windows Mobile developer could pick up the Windows Phone development environment, it’s not the main reason I believe that they should move into Windows Phone application development. The ease at which a Windows Phone application can be developed is certainly a very important reason, however it’s not why I’ve written this article.

The primary reason is the exponential growth that we are about to see in Windows Phone uptake, particularly in the consumer space. As noted earlier in this article, during the week leading up to Nokia World, the commercial UK TV channels carried a number of subtle adverts. Even today, Monday 24th October, the free Metro commuter newspaper carried an advert for the HTC Radar – granted it could have done with having more than a “cake” on the screen, it could have showed off the OS! Assuming Nokia World proves to be the catalyst that Windows Phone needs and deserves, Q4 2011 and Q1 2012 are going to see massive uptake in the Windows Phone space. Demand for Windows Phone applications is going to go through the roof early next year, 2012. We need to be developing applications to meet that demand and we need to be doing it now. Rarely do we get a moment like this, we have six months notice that good times are coming: action, now! The Windows Phone market needs you!

So, you see, now, 2011 is a great time to move into Windows Phone development.

Protecting your #windowsphone intellectual property using Dotfuscator

Justin Angel‘s Windows Phone Marketplace Statistics post makes very interesting reading. Justin has done a stellar job downloading all of the Marketplace applications and performing a lot of statistical analysis.

I was particularly interested in one of the statistics: 97% of Marketplace apps aren’t obfuscated. On the off chance that you haven’t come across obfuscation yet, here’s something from wikipedia to get you started:

Obfuscation is the concealment of intended meaning in communication, making communication confusing, intentionally ambiguous, and more difficult to interpret.
http://en.wikipedia.org/wiki/Obfuscation

Obviously this means that a mere 3% of the apps in the Marketplace have some form of obfuscation. Justin was looking for PreEmptive Solutions Dotfuscator signatures, which is currently the only Windows Phone obfuscater available. Regardless of the obfuscation monopoly, 3% for what is currently the de facto tool is surprisingly low and worrying. I think back to my days in academia and how source code was something to be protected. Getting your hands on somebody else’s code was (for some students) a real boon – if you were struggling, picking up a top student’s discarded source code could provide you with something from which gave you a start. I witnessed this a few times, it happened “back in the day”, and I’m sure it still happens today.

Traditionally, we’ve used reflection to provide us with some insight as to the contents of .net assemblies. We used, almost exclusively, .NET Reflector, although recently we’ve seen similar offerings from JetBrains (dotPeek) and Telerik (JustDecompile) to name but two other reverse engineering or decompilation tools. Typically, these tools looks for .dll or .exe files. Windows Phone apps are deployed via a .xap file, we need to crack open the .xap and extract the .dlls that we are interested in looking at. Given that .xap files are actually no more than .zip files, we can simply rename the .xap to .zip and pull out the .dlls from there.

An Example
About 20 years ago (ahem!), my Pascal tutor set us a programming exercise. The full details are documented in this post. In a nutshell, we had to create a [Pascal] program that accepted a letter A thru Z and plotted a text-based triangle, where the chosen letter was the “middle” of the triangle. Once you see the screenshot (and the code), all will become clear.

Needless to say, the problem wasn’t as simple as it sounded. As soon as students demonstrated a solution, others were keen to look at the algorithms and tricks used to arrive at the solution. The code below presents a re-hashed version of my original submission, updated slightly such that it runs as a Windows Phone app.

     private void button1_Click(object sender, RoutedEventArgs e)
        {
            char widest_char;
            int next_char, finish_char, wide, range, direction, position, spacelength, loop;

            widest_char = 'F';

            wide = (int)widest_char;
            direction = 1;
            spacelength = 1;
            position = 1;

            next_char = 66;
            finish_char = 65;

            range = 2 * (wide - finish_char);

            // Calculate initial left indent
            int mid = wide - 65 + 1;

            String firstLetter = Char.ToString((char)finish_char);
            firstLetter = firstLetter.PadLeft(mid + 1);

            textBlock1.Text = firstLetter + "\n";

            for (loop = 1; loop < range; loop++)
            {
                textBlock1.Text += (" ".PadLeft(mid - position));
                textBlock1.Text += ((char)next_char);

                textBlock1.Text += (" ".PadLeft(spacelength));
                textBlock1.Text += ((char)next_char);
                textBlock1.Text += "\n";

                next_char = next_char + (1 * direction);
                position = position + (1 * direction);
                spacelength = spacelength + (2 * direction);

                // Flip direction when the middle of the diamond is reached
                if (next_char == wide) direction = -1;
            }

            textBlock1.Text += firstLetter;
            textBlock1.Text += "\n";            
        }

Here's a screenshot of the output:

Visual Studio 2010 created a .xap file that was deployed to the emulator or physical device. In order to extract the .dll that makes up the diamond application, we rename the .xap file as a .zip file, from there it's just copy and paste.

It's a different story for dotPeek now. It can still inspect the .dll with ease, however the meaningful variable names have been largely lost. The crux of this particular code example revolves around the algorithm that is used to create the diamond shape - some students were very keen to get a glimpse of an algorithm! The algorithm is still very obvious from the code fragment below:

private void button1_Click(object sender, RoutedEventArgs e)
    {
      char ch = 'F';
      int num1 = (int) ch;
      int num2 = 1;
      int totalWidth = 1;
      int num3 = 1;
      int num4 = 66;
      int num5 = 65;
      int num6 = 2 * (num1 - num5);
      int num7 = num1 - 65 + 1;
      string str1 = char.ToString((char) num5).PadLeft(num7 + 1);
      this.textBlock1.Text = str1 + "\n";
      for (int index = 1; index < num6; ++index)
      {
        TextBlock textBlock1 = this.textBlock1;
        string str2 = textBlock1.Text + " ".PadLeft(num7 - num3);
        textBlock1.Text = str2;
        TextBlock textBlock2 = this.textBlock1;
        string str3 = textBlock2.Text + (object) (char) num4;
        textBlock2.Text = str3;
        TextBlock textBlock3 = this.textBlock1;
        string str4 = textBlock3.Text + " ".PadLeft(totalWidth);
        textBlock3.Text = str4;
        TextBlock textBlock4 = this.textBlock1;
        string str5 = textBlock4.Text + (object) (char) num4;
        textBlock4.Text = str5;
        TextBlock textBlock5 = this.textBlock1;
        string str6 = textBlock5.Text + "\n";
        textBlock5.Text = str6;
        num4 += num2;
        num3 += num2;
        totalWidth += 2 * num2;
        if (num4 == num1)
          num2 = -1;
      }
      TextBlock textBlock6 = this.textBlock1;
      string str7 = textBlock6.Text + str1;
      textBlock6.Text = str7;
      TextBlock textBlock7 = this.textBlock1;
      string str8 = textBlock7.Text + "\n";
      textBlock7.Text = str8;
    }

Obfuscating the .xap using PreEmptive Solutions' Dotfuscator, changes the playing field quite significantly. Whilst Dotfuscator can obfuscate a Windows Phone .xap file, we still have to rename it to a .zip before we can inspect the assemblies found inside it. Extracting the assembly that draws the diamond, then firing it through dotPeek results in the following, rather lengthy, code fragement:

 private void ᜀ(object A_0, RoutedEventArgs A_1)
    {
      int A_1_1 = 6;
      switch (0)
      {
        default:
label_2:
          char ch = 'F';
          int num1 = (int) ch;
          int num2 = 1;
          int totalWidth = 1;
          int num3 = 1;
          int num4 = 66;
          int num5 = 65;
          int num6 = 2 * (num1 - num5);
          int num7 = num1 - 65 + 1;
          string str1 = char.ToString((char) num5).PadLeft(num7 + 1);
          this.textBlock1.Text = str1 + MainPage.b("ሗ", A_1_1);
          int num8 = 1;
          int num9 = 1;
          while (true)
          {
            switch (num9)
            {
              case 0:
label_8:
                num2 = -1;
                num9 = 5;
                continue;
              case 1:
              case 4:
                num9 = 3;
                continue;
              case 2:
                if (num4 == num1)
                {
                  num9 = 0;
                  continue;
                }
                else
                  goto case 5;
              case 3:
                if (num8 < num6)
                {
                  TextBlock textBlock1 = this.textBlock1;
                  string str2 = textBlock1.Text + MainPage.b("㠗", A_1_1).PadLeft(num7 - num3);
                  textBlock1.Text = str2;
                  TextBlock textBlock2 = this.textBlock1;
                  string str3 = textBlock2.Text + (object) (char) num4;
                  textBlock2.Text = str3;
                  TextBlock textBlock3 = this.textBlock1;
                  string str4 = textBlock3.Text + MainPage.b("㠗", A_1_1).PadLeft(totalWidth);
                  textBlock3.Text = str4;
                  TextBlock textBlock4 = this.textBlock1;
                  string str5 = textBlock4.Text + (object) (char) num4;
                  textBlock4.Text = str5;
                  TextBlock textBlock5 = this.textBlock1;
                  string str6 = textBlock5.Text + MainPage.b("ሗ", A_1_1);
                  textBlock5.Text = str6;
                  num4 += num2;
                  num3 += num2;
                  totalWidth += 2 * num2;
                  num9 = 2;
                  continue;
                }
                else
                {
                  num9 = 6;
                  continue;
                }
              case 5:
                if (1 == 0)
                  ;
                switch (1 == 1 ? 1 : 0)
                {
                  case 0:
                  case 2:
                    goto label_8;
                  case 1:
                    if (0 == 0)
                      ;
                    ++num8;
                    num9 = 4;
                    continue;
                  default:
                    goto case 1;
                }
              case 6:
                goto label_15;
              default:
                goto label_2;
            }
          }
label_15:
          TextBlock textBlock6 = this.textBlock1;
          string str7 = textBlock6.Text + str1;
          textBlock6.Text = str7;
          TextBlock textBlock7 = this.textBlock1;
          string str8 = textBlock7.Text + MainPage.b("ሗ", A_1_1);
          textBlock7.Text = str8;
          break;
      }
    }

Clearly the Dotfuscator version is much harder to understand. This is about as far as most obfuscation methods can go, they won't make it impossible to reverse engineer your application, but they will make it very time-consuming for those trying to read and understand the code.

If you are planning to obfuscate your Windows Phone apps, be sure to test them after they have been obfuscated. Like any tool that alters code post-compile, there is a chance that something may cause your app to fail. As part of the Windows Phone SDK, the Application Deployment tool is your friend. It will let you deploy .xap files to the emulator or a physical device outside of Visual Studio 2010. In other words, once you've built and tested your app, after you've obfuscated the .xap, use the Application Deployment tool to re-test the deployment.

Of course, if you are targeting Windows Phone Mango, all of this becomes rather academic. As Justin points out, from Mango onwards, .xap files will be DRM protected. Whilst your .xap will be downloadable from the Marketplace, the file itself can't be cracked open in the same way I mentioned earlier in this post. However, if you are planning to target Windows Phone 7.0 "NoDo" 7392/7390 builds, obfuscation might be something for you to consider.

40 days and 40 nights with #WindowsPhone 7

In July, I finally gave in and won a bid on eBay. I rarely win bids on eBay, apart from the ‘buy it now’ variety, but that just equates to online shopping. I had been bidding on Windows Phone 7 devices, not thinking my bid would actually be considered good enough to actually win the goods. Of course I won the goods and had to pay up. I became the proud owner of an HTC HD7, two batteries, a desktop dock, car cradle, a carry case and a clean install of Windows Phone 7 (build 7392).

Moving to Windows Phone 7 has been an excellent move. I feel more organised, at least when I’m on the move (I can’t say that my primary e-mail inbox is anything to gauge that statement on!) The device integrates itself with Facebook. Some folks say that’s a bad thing, it certainly hasn’t proven to be a problem for me. Being able to “link” contact records between the Facebook and any number of e-mail accounts is a real boon. Couple that with the de-duplication feature in Windows Live, no longer do I have to see multiple contact records for the same person.

Windows Phone 7 also lends itself to getting your contacts sorted out, once and for all. I had contacts in Outlook (both at home and at work) and on a Nokia handset. After “some” effort, I was able to get all of my contacts into my Windows Live account. Most of the hassle that I had during this process was down to the Nokia PC Suite software – a product I will never need to see again, ever. After a little bit of tweaking, I was able to get my personal Outlook calendar and contacts synchronising with the phone. Importantly, I was also able to get my corporate Outlook calendar synchronising too.

Prior to the HTC HD7, for corporate use, I had been using a couple of Nokia devices, a 6021 and a 7230. Both were “candy bar” style devices, one was a traditional black’n’white device, the other had a colour screen with a slide out numeric keypad. For personal use, I was using a Palm Treo running Windows Mobile 6.1. Now that I am running the HTC device as my personal phone, the Nokia devices have been retired…the corporate SIM card is in the Palm Treo. The Palm Treo is used as a phone and for managing my corporate inbox, although I do use the HTC device for this purpose too.

I am very impressed with the operating system and the device itself; here are my seven favourite Windows Phone 7 features, so far:

  1. I never need to see a duplicate contact card again
  2. The Metro styled user interface is very clean
  3. Live Tiles – active content, such as “number of unread e-mail items” or “number of unread text messages”
  4. Next appointment, date, time, unread e-mails, voicemails and missed calls “on top of the curtain” (when the phone is turned on, the curtain is down – the screenshot on the right demonstrates the curtain)
  5. There is a camera button on the phone. This is great for getting the camera application running without having to power on then tap on a couple of icons to get to the camera.
  6. It’s fast. Very fast. What with all the animations that are going on, you might expect some drag. I find the whole phone experience very snappy.
  7. Its simplicity and its wealth of configuration options. Each of the tiles that you see in the screenshot above (the curtain is up) can be turned on or off. Applications and ‘people’ can be pinned to the home screen as a tile. Pinning family members to the home screen is particularly useful, two taps and I can be sending a text or returning my wife’s calls.

So I am a convert, I’ve joined the smartphone fraternity. I am pleased that I resisted the temptation to jump on the “i” or the “‘droid” or the “‘berry” bandwagon. If you’re in the market for a new device, I would urge you to go to your local store, push past the array of “other smartphones” and hunt out a Windows Phone 7 device. I’m so enthused by the device that I’ve signed up for the developer programme – I’ll be taking my .net development experience from the desktop and the web over to Windows Phone, apps coming soon!

All of this Windows Phone 7 “goodness”, gets even better with the Mango update that should be shipping during “the fall” of 2011.

Event – UK – 16/07/2010 – Bournemouth Pier! #nxtgenug

NxtGenUG are pleased to announce their annual conference Fest10 will be taking place on Bournemouth Pier this year on Friday the 16th July 2010. It’s a great opportunity to take the family to the Seaside for the weekend, and catch up on technology. The best thing is attendance to the conference is free to members and just £59.95 for non-members.

Speakers
We have a great speaker line up this year, Google’s Jon Skeet will be talking about C#, Microsoft’s Glenn Block is coming over from Redmond to talk about MEF, Ryan Simpson will be giving us the lowdown on F#. We’ll also be having NxtGenUG veterans Mike Taulty, on OData and Chris Hay on Azure, Plus Marcus Perryman will be talking about one of the hottest technologies this year Windows Phone 7.

You can find a list of speakers and their sessions here:
http://www.nxtgenug.net/fest10/Sessions.aspx

To register simply click here and follow the instructions on screen.

Parking, Hotels and Timings
Full details about parking, hotel accommodation and timings for the day can be found on the Fest10 site. The nearest parking for Bournemouth Pier is either in the Bournemouth International Centre (BIC – 20) car park, the Bournemouth Pavilion car parks (19/24) or the car park next to the Royal Bath hotel (18). However, there is also further car parking available at Eden Glen car park (21), Winter Gardens car park (22) and Beacon Road car park (25).

For Hotels, the RusselCourt is where the evening entertainment will be. Quote: NxtGenUG when booking, otherwise Bournemouth has a large amount of hotels, including the Best Western Hotel Royale.

Geek Dinner
It’s the Fest10 geek dinner – normal rules apply – pay for your own food/drink, and engage in great conversation, and eat fish and chips at Harry Ramsden’s. To register for the geek dinner, click here.

Post Fest Party
We’ll also be having a post Fest Party at the RusselCourt Hotel – If you’ve brought your family down for the weekend feel free to bring them along. Just register on the site and drop us an email on how many people you’ll be bringing with you to enquiries@nxtgenug.net

Sponsorship
NxtGenUG would like to thank DevExpress, our gold sponsor, along with Microsoft, RedGate, PluralSight and Apress for their support in making this event possible.