Olive Software e-Editions on Surface RT


I decided to sign up for the newspaper this year, and I’ve really been enjoying it. I’ve said before that I’m a CNN junkie, but you really don’t get a lot of news from CNN. In the mornings, they tend to repeat the same 5-10 minutes worth of stories over and over again–presumably catering to the morning rushers that flip on the TV for a few minutes while they’re getting ready. The newspaper gives you SO MUCH MORE information. It’s really great. If you’re like me and haven’t (hadn’t?) picked up a paper in the last decade, maybe it’s time to give it another shot. But I digress…

Along with the physical paper that comes 3 times a week, I also have access to the paper daily via the e-Edition. But there’s a problem: it doesn’t work on my Surface.

The reason it doesn’t work is because it’s Flash-based. IE10 on Windows RT supports Flash, but sites must be whitelisted. So, my the e-Edition will work fine, but the e-Edition’s vendor, Olive Software, needs to provide code to Microsoft to get themselves on the whitelist. That seems like the easiest solution for Olive, but what I’d really like to see is a Detroit Free Press app in the Windows Store. I’d love to have something similar to the New York Times app with my local, Detroit news.

Surface RT Mutes Itself

While typing on my Surface yesterday, I noticed something unusual: the volume kept muting itself. I’d noticed this before, but I figured I just accidentally hit a button. Yesterday was different, though. The volume muted 3 times in a 15-minute span!

The first thing I did was hit the ‘net. Has anybody else experienced this? Yes, there are a lot of forum posts. People seemed to be pointing the finger at Touch Cover and suggesting that you contact Microsoft for a replacement.

I contacted Microsoft support and was told that replacing the cover was not found to fix the issue. I’m hoping it’s a software issue that can be resolved and pushed out in a hotfix, but I’m skeptical. It does seem to occur primarily when I interact with the keyboard.

It’s not a huge issue since the workaround is to simply unmute it, but it is annoying. If anybody hears about a solution, I’d love to hear!


Triage Android Battery Drain with BetterBatteryStats

I’ve really been digging JellyBean on my Galaxy S2, but the battery life has been a dagger. With my previous Gingerbread ROM, I was easily getting about 1.5-2 days of normal-use on a single charge. Since upgrading to CyanogenMod 10 (Beta 2), I’ve only been getting 8-10 hours, and most of that is standby! I’m never away from a convenient charging location for more than a few hours, so this is more of an annoyance than a deal-breaker, but I’d still like to get it fixed.

I thought that maybe the battery drain had to do with CM10, so I switched to AOKP over the weekend. The good news is that I like it just as much as CM10, but I didn’t really see any improvement in battery life. Using the standard battery details in Android settings, I was able to see that the vast majority of my battery—70 to 80%–was being used by Android OS, but that’s as much detail as you get. That’s not very helpful, and so I turned to BetterBatteryStats.


Looking at the screenshots, I wasn’t sure how useful the app was going to be. It was also $3, which is pricey fare for the app store. The app was recommended on many-a-forum, though, and I decided to take the plunge. I’m happy I did.

It’s easy to see what’s eating up your battery by looking at the Partial Wakelocks. Right away, I could see that NetworkLocationService was a major culprit. After just a few minutes of googling, I found that this service was linked to the Wi-Fi & Mobile network location setting in Settings > Location Access. I had originally linked this setting just to wi-fi. I knew I should keep wi-fi turned off when I wasn’t using it to conserve battery life, and I (incorrectly) assumed that the location service would be disabled-by-proxy when wi-fi was off. Upon re-reading the setting, it was using mobile data to update my location. Battery life is a much bigger priority to me than location-based services, so I turned off the setting and improved battery life significantly.

A few hours later, I decided to check the battery stats again. This time, it was the GPS. Like wi-fi, I knew that I was supposed to keep GPS turned off to conserve battery life. I got tricked by the fact that the GPS icon in the status bar was only visible for certain apps, though. I turned it off and boom–more battery life.

If you’re experiencing battery woes, I’d give BetterBatteryStats a look. It was well worth the $3 investment for me. In a day of monitoring and tweaking, I’ve gone from under 10 hours to over 20.

Renumber Enums with Regular Expressions

We had a widely-used assembly with an enumeration that did not have explicitly assigned values that was being released from multiple branches and causing problems. In an effort to keep the enumerations synchronized across projects, explicit values were added. The problem is that the values started at 1, whereas the implicit counter starts at 0. The solution is simple: renumber ’em to start at 0. Sounds like a job for regular expressions!

I was really hoping that I could do this using regular expressions in VS2012’s find & replace, but I just couldn’t find a way to implement the necessary arithmetic. After floundering for 15 minutes or so, I decided to just write a simple script in LINQPad. Here’s what I came up with, and it works fantastically.

var filename = @"C:\source\MehType.cs";

var contents = string.Empty;
using (var fs = new FileStream(filename, FileMode.Open))
    using (var sr = new StreamReader(fs))
        contents = sr.ReadToEnd();

var regex = new Regex(@"(.*?= )(\d+)");
foreach (Match match in regex.Matches(contents))
    var num = int.Parse(match.Groups[2].Value);
    contents = contents.Replace(
        match.Value, match.Result("${1}" + --num));

using (var fs = new FileStream(filename, FileMode.Create))
    using (var sw = new StreamWriter(fs))

The result is that this…

public enum MehType
    Erhmm = 1,
    Glurgh = 2,
    Mfhh = 3

…becomes this…

public enum MehType
    Erhmm = 0,
    Glurgh = 1,
    Mfhh = 2

SkyDrive Desktop App


Now that I’m all-in on the Surface-Office-SkyDrive solution, I need better access to SkyDrive from my PCs. No problem, there’s a SkyDrive desktop application. Get it here.

It’s everything you want and expect. Installation’s a breeze—just enter your credentials and pick a folder to sync to. Within seconds, the contents of my SkyDrive account was available locally. I can save to the folder, and it uploads automagically. (PS—I just learned that Word recognizes “automagically” as a correctly spelled word. Nice.)

There’s also an option to make any file on the computer available through SkyDrive. I didn’t enable it because I was surprised and got scared, but I might go back and check it out later.

Naming and Capitalization Conventions


A small group of us were doing a code review, and the topic of capitalization and naming conventions came up. I’m very rigid in my ways, and super anal about making sure everything is correct and consistent. Unfortunately, at work we don’t have any official standards documentation to define the style we use. There are some general patterns that are followed, but some of the more controversial topics–like use of var–are left to the preference of the developer. I knew that MSDN had published naming guidelines, so I dug them up to present to the group. Now when we review code, we can nitpick names and capitalization using the argument that “our standard is to follow Microsoft’s guidance.” That’s good with me!

The specific topic that got us started down this path was capitalization for acronyms, and Microsoft offers three rules for dealing with them:

  1. Do capitalize both characters of two-character acronyms, except the first word of a camel-cased identifier. (e.g., DBRate, ioChannel)
  2. Do capitalize only the first character of acronyms with three or more characters, except the first word of a camel-cased identifier. (e.g., XmlWriter, htmlReader)
  3. Do not capitalize any of the characters of any acronyms, whatever their length, at the beginning of a camel-cased identifier. (e.g., xmlStream, dbServerName)

Ahh, just how I like it.

An additional distinction is made for abbreviations. It advises that, generally, abbreviations should not be used in library names. Two exceptions are noted, though: ID and OK. These are acceptable to use in an identifier name and should follow the same casing rules as regular words. In other words, Id and Ok for Pascal-case and id and ok for camel-case.

While we’re on the topic of capitalization, here’s a list of conventions that I follow in terms of Pascal-case versus camel-case. Violating these rules is a good way to irritate me

  • Class: Pascal
  • Property: Pascal
  • Parameter: Camel
  • Private instance field: Camel, prefixed with “_” (no official guidance; I’m flexible on this one)
  • Public/internal/protected instance field: N/A (use Property instead; read more)
  • Event: Pascal
  • Local variable: Camel
  • Enum types and values: Pascal

What to read more? (I know; I love this stuff, too!) Check out the complete guidance here.

Performance Profiling for Unit Tests

When I first got my hands on Visual Studio 2012, I was trying out every feature I could, new and old alike. I love the new Test Explorer. Code coverage is SO much better than it was before. Code analysis for code clones is a terrific, too. The only thing I wasn’t happy about was performance analysis.

The reason I wasn’t happy with performance analysis is that I couldn’t use it on unit tests. Luckily, Microsoft fixed that with the release of Visual Studio 2012 Update 1. Now you can right-click a test and choose Profile Test to run performance analysis on a single unit test, and it is awesome!


When you choose to profile a test, the test runs as usual followed by the analysis. When analysis completes, you’re presented with a summary view that shows you CPU usage over time, the “hot path” call tree—a tree of the most active function calls where most of the work was performed—and a list of functions responsible for doing the most individual work.


You can find out more and investigate resource spikes by selecting a time range on the graph and filtering. That’s all good and well, but what really blew me away was that you can click on the functions with the most individual work to drill into them. Drill into them? Yea—you’re taken to a view that shows you the selected function, its callers, and the methods it calls. There are percentages that show how much time was taken in each of the three areas (callers, current method, and callees), and you can click into any of the methods displayed to navigate up or down the call stack. The actual code for the current method is also displayed. The only thing that seemed sub-optimal is that I couldn’t edit the code directly; there’s a link to the actual file, though, so you’re only a click away from the editable code file.


There are other, sortable views you can look at, too. You can view a call tree or breakdown by module, and you can get to the same function details view described above from each of those views. It’s a really useful, powerful experience.

Here’s where it gets really nuts, though: add SpecFlow to the mix. SpecFlow lets you write feature-based scenarios that are capable of serving as automated integration tests. The scenarios run like normal unit tests. You can right-click them in the Test Explorer to run performance analysis on them. This means that you can do targeted performance analysis on specific features of your application! To test this out, I sorted my unit tests by execution duration and analyzed the slowest. I was able to find a bottleneck with a caching algorithm used by nearly all of the other modules in the application. Execution time of the 350 unit tests in the project went from 50 seconds to 20. That’s a HUGE improvement from fixing one flaw found from running analysis on one function picked only because it was the most time-consuming in the slowest test.

Good tests are supposed to run quickly, and performance analysis is an invaluable tool to help you triage valuable-but-poor-performing tests. Also, since you’ve got automated tests, you can refactor and optimize the performance of your application with high confidence. If you haven’t used performance analysis before—more specifically, performance analysis for unit tests—give it a shot; I’d be blown away if you didn’t find incredible value.