MVP Award Time Again
January first - most people celebrate the ability of gravity working for another year and other physics related awesomeness at midnight however for 943 people they get a special celebration at about 5pm (SAST) when they are told they are MVPs.
For the forth time I have been honoured to be placed into that special group by being award a MVP for ALM.
Thank you to everyone who has been a part of helping me gain this award for the work I did in 2012!
NDepend + Windows Store apps = WINNING
I <3 NDepend, it is an amazingly powerful tool that is brutally honest & unforgiving, and the rewards it brings are massive. Building Windows Store apps without it has always worried me – how do I know if this is going right? Thankfully yesterday the NDepend team released 4.1 which includes support for Windows Store apps, which includes the ability to analyse the .winmd files too!
This not only means I have personal benefits, but it is a sign of something too. NDepend really is cutting edge, and so the sign that they professional tools are arriving for Windows Store apps really shows commitment from the community to the platform! This means it will get easier and better to develop Windows Store apps in the future!
You can download a trial of NDepend at http://www.ndepend.com/NDependDownload.aspx
Twitter Pro-trick: Refer to companies by stock codes
Twitter is filled with awesome little tricks, and I recently found a very cool one for referring to companies on Twitter. First though, lets see the existing two ways to refer to a company. First you can use the companies Twitter name for example:
I work for @bbdsoftware :)
— Robert MacLean (@rmaclean) November 29, 2012
Or your other option is to use a hashtag
So what is the new awesome trick? If the company has a stock ticker code, for example Microsoft has MSFT & Nokia has NOK then you can prefix that with $ on Twitter, i.e. $MSFT & $NOK.My mother is a happy #Bing user
— Robert MacLean (@rmaclean) November 29, 2012
I am hoping for a $NOK Lumia 920 phone :)
— Robert MacLean (@rmaclean) November 29, 2012
On the Twitter site you will note that $NOK is now a link to a search for all $NOK related items (it doesn't work on the embedded Tweet), which in many cases (like Nokia) can save you a little bit of text. For people monitoring companies social network this is also important as it is an another thing they need to monitor!
This feature is called a CTAG (maybe it isn’t - but that is the the source on the search).
Presenting on Windows 8 - Pro tip
This tip is aimed at presenting, but is just as useful to those who want to focus in Windows 8 without distractions!
Windows 8 is a great operating system to use, especially the background tasks system that ensures other applications are not destroying your CPU & memory. However, there is a downside to background tasks!
Previously, if I wanted to ensure no annoying Skype popups (during my talks for example) I just shutdown Skype and no popups could occur, but in Windows 8, since the application isn’t running, how do we stop the popups?
It is a simple solution, bring up the settings charm (see image on left) and in the bottom right hand corner is an option called Notifications. If you tap that, you will get options to block notifications for 1, 3 or 8 hours.
I am tending towards 3 hours for my 1 hour talks to allow for setup, clean-up etc.
Once you have disabled it, the icon will change to show you it is disabled! If you want them back, for example when you are finished, then you can tap the icon again to enable them!
What is great is that live tiles & the background tasks still occur, just no popups anymore.
Windows Store app Development Snack: File Type Association Icons
For more posts in this series, see the series index.
One of the declarations you can have with a Windows Store app is the file type association, which lets file types become associated with your application. This means you can customise the icon for the file type & if the user double clicks an associated file, it will launch the application.
One of the properties of declaration is the logo property which is the icon to use for the file type. Logo is optional and if you do not specify it, or you specify it incorrectly, it uses the applications small icon (i.e. the 30x30) one – which doesn’t look great.
The solution to this is to correctly specify the logo, but that isn’t as straight forward as it seems. Firstly you don’t just have a single image you need FOUR icons with different resolutions
- 16x16
- 32x32
- 48x48
- 256x256
Next you need to name them correctly, the format is <name>.targetsize-<resolution>.<extension>, so for example if we wanted to use MyLogo.png as the file name we would have:
- MyLogo.targetsize-16.png
- MyLogo.targetsize-32.png
- MyLogo.targetsize-48.png
- MyLogo.targetsize-256.png
Lastly is putting in the correct logo name in the manifest, since you have four icons what do you use? You use the name + extension components. Using the example about we would have MyLogo.png as the name & Windows 8 is smart enough to figure out the resolution, insert the target bit and get the right image for the right resolution!
Windows Store app Development Snack: Background Colour
For more posts in this series, see the series index.
When you are configuring the appxmanifest for your Windows Store app, one of the options is the background colour for the tile – YOU SHOULD ALWAYS SET THIS!
It is used for two things, firstly if your image is transparent this is the colour that will show through for example for Notepad Classic that is what I do – the actual image is just plain white & transparent.
The second one, which is not always the most obvious is when a small icon is needed, for example you do a pinch gesture on the start screen (semantic zoom is the technical term for it), the background colour is what is used as a border around the image. Below you can see a screen shot from my machine, and note two of them have this ugly black border – that is because they do not have a matching background colour set!
It is not always possible, especially for games with rich tile icons (note Angry Birds in the screen shot below) but I would suggest trying to find a similar colour anyway for example the top two below have a similar colour & Jetpack Joyride (the last one) chose white (which is at least better than ugly grey).
Another location for the small icon is the search charm
How rich are you?
How rich are you? Did you ever wonder that? I did, so I built this little tool to tell me exactly how rich I am! The tool uses data from the South Africa 2011 Census1 and nothing is sent or stored when you use this tool.
The tool
Enter your current MONTHLY income:
My thoughts
What really hit home to me is just how much better off I am than many people in South Africa. It is very sobering.
Footnotes
The numbers may seem off from the 51 million people that StatsSA reported, that is because I have removed people who answered "not applicable" or "not specified" which lowered the amount of the population to 46 867 063 - still enough of a data set to play with.
If you want to understand how this works, you can see the code (in a very messy state) at BitBucket.
English to Afrikaans to English
South Africa, the amazing country I live in, has 11 official languages including the language of Afrikaans which I can muddle my way through speaking. However often I struggle and that inspired me to create an app to help with a phrase book that helps you translate English to Afrikaans & back again!
I see some real value in this on a tablet, when people come to South Africa on holiday as they will be able to quickly find out what “jou ma se…” means and take the required action (ducking is generally the required action at that point).
While I did some planning for this app before hand (finding content, prototyping UI’s etc…) the app was mostly built at the recent WowzApp event, which is an event aimed at students (although we had professionals & even a 13 year old).
This app is also in the Apptivate competition so please go there and vote for it by clicking the image below:
Video
Screen shots
Windows Store app Development Snack: The vastness of CPU time
For more posts in this series, see the series index.
I have written in a previous post (What do you get from being a lock screen app?) about how your background processing has a limited amount of time to do it’s processing in, what the odd unit of measurement used (the CPU second) and the overflow bucket. Even with the thinking it is hard to understand what you can accomplish in the time available, so help let’s look at what an app I built (Bing my lockscreen) does in it’s time.
In short what I hope you take away from this, is that you do get a decent amount of time and that with careful planning you can do a lot!
The Process
First off, Bing my lockscreen since it uses a timer requires lock screen permissions which means it gets at least 2 CPU seconds every fifteen minutes, plus overflow from the bucket.
First thing that happens is we get a deferral object (similar to what was explained in Async & Sharing) since we need to use async in the background task. Now we go to the RoamingSettings values to get a boolean (which needs to be cast, since RoamingSettings is a Dictionary of string & object) to see if the user has disabled automatic updates. Now assuming the user hasn’t disabled automatic updates, we connect to a web site using the HttpClient & HttpClientHandler classes and pull down some JSON as a string and convert it to an object using Windows.Data.Json.JsonObject.
Aside: if I felt too tight on CPU, I may swop to the AWESOME Json.NET, which has a better parsing performance.
If all that worked (and there is minimal logging and status checks happening in here too), I use a touch of Linq to get the first image from the IEnumerable collection that it is stored in internally. I then check the URL of the image against a value stored in LocalSettings, as I do not wish to update the lock screen with the same image multiple times. If the image is different, I download the image from Bing to the TemporaryFolder, check the file size is greater than 0. If it is, then I call the SetImageFileAsync method to change the lock screen, else I delete the damage file. Downloading is far more complex than it first appears as I need to handle proxies, handle scenarios where I can’t get the 1920x1200 resolution and need to fall back to the 1366x766 resolution image, ensure everything is written to disk BEFORE the lockscreen is set (I had some issues with I/O buffers in earlier versions that caused a minor corruption on images because they were not flushed to disk!).
Aside: Important to remember that CPU seconds, is time the CPU works – when the CPU is idle say because you are doing something I/O bound like a download, it doesn’t count!
Next I store the result of this to the log, which is just a container in LocalSettings (so that means the first time this is run we create the container too!) and store the URL of the newly changed image too. Now the process continues in a similar way for the live tile! We check if the last live tile update is the same based on the URL for the image (again comparing to a value stored in LocalSettings). I then use the TileNotification and the TileUpdateManager to send the tile update. I do not need to download the tile image in this case, as tiles do support remote URL’s for the images. Lastly I update the LocalSettings for the updated tile!
Line count
If you count the lines of code executed for this, and I am excluding blank lines, namespace declarations, comments – really just the code that actually runs it is approx. 190 lines of C# code! Far more than you may think.
More stats!
I used the always amazing NDepend to generate some more stats on the assembly which does all the background processing:
- IL instructions: 2 092
- lines of code (LOC): 80
- lines of comment: 9
- Percentage Comment: 10%
- Methods: 99
- Fields: 75
- Types: 18
- Namespaces: 2
- Assembly Level: 1
- Abstractness: 0.11111
- Instability: 1
- Dist from main seq: 0.078567
- Normalized dist from main seq: 0.11111
- Relational cohesion: 2.3333
- Afferent coupling (AsmCa): 0
- Efferent coupling (AsmCe): 17
LOC is different here since NDepend uses the compiled assembly and works back, while I counted lines in Visual Studio. Same is true for methods, which NDepend works out from the compiled assembly and thus includes all anonymous methods - where if I counted that in VS, it would be 8 or 9 methods.