Tech Blog

Jay's Technical blog

The WP7/Windows Metro/RT Opportunity!

25 January 2012
Jay Kimble

[WARNING! This is an archived post and as such there may be things broken/missing here.. you have been warned.]

I think we’ve all seen the commercial where the kids are playing with their dad who is grocery shopping. The kids update the grocery list with all kinds of sweets. Eventually the dad realizes what is happening and he changes the list to “Do your homework!!” Microsoft is famous for showing stuff like this, and about 2 to 3 versions of VS later it gets available to the masses. In other words, it’s a feature they keep to themselves for a bit and then they give it to the developers. Oftentimes we have already moved on or have built our own solutions to the problem that we are now stuck with (until we refactor our code).

This is why I am amazed at what has been announced surrounding SkyDrive, Windows Phone (aka WP7, WP7.5, etc), and the next version of Windows. We are actually getting the ability to make apps like this! Very, very cool!

Theme Park Pro – A Scenario
I was recently at an Amusement Park and used my buddy’s NeurelNet’s Theme Park Pro App. If you are not familiar with the app, it let’s you scope out a bunch of Amusement parks (like Walt Disney World, Busch Gardens in Tampa, and Universal Studios Parks in Florida – just to name a couple). They actually offer badges as you walk around the park letting you check in at the Roller Coasters and other rides. As I was using the app that day I started thinking about a few changes I was going to suggest to the guys.

As the went on I realized that there were a couple things bugging me. I’m getting older (but still in my early 40s), so there are few roller coasters I ‘m not really interested in riding (mainly because I am not the daredevil I once was). I started realizing that what I wish I could have done was customized my trip to show those things that I wanted to do on my trip. Of course I really didn’t want to do this on my phone.. I wanted to do this on something like my tablet or my laptop.. I wanted to be able to customize my experience in Theme Park Pro and have it reflected when I grabbed my phone.

The Opportunity!
As I was thinking how to send this idea to my NeurelNet buddies I realized what an opportunity we all have (those of us who develop for Windows Phone –or other Mobile Platforms, really). We can make Phone Apps that absolutely rock and that combine the experiences of the PC and the Phone. I watched the demos at BUILD, but the reality is hitting me now.. I think there is a huge financial opportunity for us all again!


WinRT Quick Tip #1: Get the Constructor for a Type

19 January 2012
Jay Kimble

[WARNING! This is an archived post and as such there may be things broken/missing here.. you have been warned.]

I ran into this on the Win8 Developer’s Preview. I am porting over some Windows Phone Code. This code has a MEF/IOC-Like mechanism that let’s me do discovery on the project. The project itself is a simple App Framework; it has a bunch of content controls, but with the way it is configured you may decide that you don’t want to deploy all these controls, SO I needed to be able to discover controls and create them dynamically (the latter is what this tip is all about).

My original code looked like this:

public UserControl GetAndInitControlFor(string targetType, SectionInfo data) 
        {
            UserControl result = null;
            var typ = (from item in Catalog 
                              where item.Key.Equals(targetType, 
                                                  StringComparison.InvariantCultureIgnoreCase) 
                              select item).FirstOrDefault();

            if (!typ.Equals(null))
            {
                var ctor = typ.Value.GetConstructor(new Type[0]);
                result = ctor.Invoke(newobject[0]) as UserControl;
                if (result != null )
                {
                    ((ISUAFContentControl)result).SetData(data);
                }
            }
            return result;
        }

 

This particular function looks up a control by it’s content type (a string) in the Dictionary that I have already built. If it finds a match then it takes the type instantiates it via the type’s constructor (essentially doing a “new” on the class). The only problem is that WinRT’s type doesn’t have a way to get the constructor. Instead there is a different mechanism you have to use.

Enter TypeInfo

I did some BINGing and I found the answer. There is a mechanism called TypeInfo. It’s apart of System.Reflection, so you will have to add a “Using System.Reflectiomn;” to the top of your file. Now you can get TypeInfo for you class. Here’s the rewritten function for WinRT:

public UserControl GetAndInitControlFor(string targetType, SectionInfo data) 
        {
            UserControl result = null;
            var typ = (from item in Catalog 
                             where item.Key.Equals(targetType, 
                                           StringComparison.OrdinalIgnoreCase)
                             select item).FirstOrDefault();

            if (!typ.Equals(null))
            {
                TypeInfo typeInfo = typ.Value.GetTypeInfo();
                var ctor = typeInfo.DeclaredConstructors
                                    .Where(c=>c.GetParameters().Count() == 0)
                                    .Select(c=>c).FirstOrDefault();
                result = ctor.Invoke(newobject[0]) as UserControl;
                if (result != null )
                {
                    ((ISUAFContentControl)result).SetData(data);
                }
            }
            return result;
        }

It’s very similar, but about midway down you can see where I create a TypeInfo for the type, and then using that type I have to write a Linq query to pull out the paramerless constructor that I am going to use to new up an instance.

I didn’t like having to change things, but I do like the new mechanism a lot better. These things should have been properties all along.


Mobile Apps and Legal issues

13 January 2012
Jay Kimble

[WARNING! This is an archived post and as such there may be things broken/missing here.. you have been warned.]

One of the guys on the local Florida Windows Phone List asked a question about his app which is a medical app. He was becoming worried that he might have legal issues with his app. This resulted into a really nice thread on legal issues and your app (and your business).

I decided to go ahead and make a quick write up (for me as well as for anyone else).

Rule # 1 cover yourself at all times!
Think about the lady who got burnt by McDonald’s coffee who sued because they didn’t say it was hot! You might think the lawsuit was frivolous, but it illustrates the problem. Someone using your app ends up setting their device (and house) on fire, you could get blamed (Ok, that’s extreme, but you get the idea). You can never be too careful!

This advice sounds scary, but there are solutions here.. Don’t give up just yet! Lawyers exist for this very reason.

[Keith Kabza had the best bit of info on this -- I have to credit the source as the info is good, and much of the post from here comes from Keith’s knowledge] To the specifics of medical related apps, you need to make sure you aren’t violating any laws related HIPAA (In my personal experience you need to find someone that knows those laws and walk them through what you are doing – if you don’t know someone, come to a local user group and ask if anyone there knows anything about HIPAA). You also need to avoid exposing data their data without using encryption and basic security principals. The good news is there is limited risk in selling mobile apps.

Next operate as an LLC! This protects you to a point. Form there get at least limited liability insurance. It will cost you about $800 a year, but it will cover you for $1 million. [these next 3 nuggets from from Henry Lee] Additionally you may want to get Errors and Omission insurance which really covers the scenario where someone burns down their house while using their app (that’s extreme, but has happened). Also, getting umbrella insurance to cover anything not covered by the previous two insurances. The short is that you want to cover yourself on all legal aspects because you don’t want your spare time building an app to cause you to lose your house.

You want an attorney when you are crafting your licensing agreements. You want it to be written to protect you from frivolous lawsuits.This is something that gets overlooked by many of us! The lawyer Keith recommended (who specializes in this stuff) charges about $3000.

Resources

A few additional resources came up in the thread, and here they are:

www.techinsurance.com – they are an insurance company who simply finds the best rate for you. (via Henry Lee)
legalzoom.com – offers a whole suite of legal solutions and you can get liability coverage for about $450 a year. (via Greg Leonardo)