Quiz for Geeks is now available on Windows Phone!

I’m pleased to announce Quiz for Geeks is now available on¬†Windows Phone.

You can now get the same set of questions and the same challenging gameplay at your fingertips!

Give it a try and let me know what your think!

Download link: http://www.windowsphone.com/en-us/store/app/quiz-for-geeks/2a79d5ca-c1a0-4f19-b044-6073c41953b7

Constructive feedback and good ratings are encouraged ūüôā

Quiz for Geeks for Windows Phone

Quiz for Geeks for Windows Phone

Quiz for Geeks in now available in Windows Store!

Quiz for Geeks passed certification and is now available in Windows Store.

Before you try it, here is the game trailer:

Download it from here: http://apps.microsoft.com/windows/en-us/app/quiz-for-geeks/4b3becb8-97c6-40ef-b922-019e6a55c18d

Don’t forget to¬†follow our Facebook page: https://www.facebook.com/QuizForGeeks

Let me know what you think. Good¬†ratings are encouraged ūüôā

 

 

Coming soon to Windows Store: Quiz for Geeks

  • Who played ‘Rachel Green’ in the TV Show Friends?
  • 19+16=…
  • What is the decimal value of the roman numeral¬†LXIII?
  • What is the local currency in Laos called?
  • What is the¬†name of the element “Cl”?

Can you answer any of these questions in 10 seconds or less? If the answers is YES then Quiz for Geeks is the game for you!

Quiz for Geeks is a fast paced game that tests your knowledge on a variety of topics from geography and history to mathematics and literature as well as entertainment and current events.

Thousands of dynamic questions structured in 5 levels of difficulty will challenge you as you progress in the game.

Quiz for Geeks

The game is days away from being launched,¬†stick around and like our Facebook page, we’ll let you know when it reaches¬†Windows Store.

How much code can you really place in your Portable Library?

Recently, Jevgeni asked me how much code I was able to share between my projects by using a Portable Library. He is contemplating building a Windows Phone and a Windows Store app and wants to create a Portable Library for sharing common code.

So I decided to get some numbers based on my new app code which is going to (hopefully) reach Windows Store soon.

Code Sharing between a Portable Library and a Windows Store app

Code sharing between a Portable Library and a Windows Store app

The app is not 100% ready yet, so I might add few lines of code but at the moment it turns out I placed more than 70% of my code in a Portable Library.

However, I invested quite a lot into having such a structure as I plan to release a Windows Phone app around the same core.

While you are waiting for my new app to be released :), go ahead and try my other apps already in the Windows Store: Puzzle Frenzy (download link) and Puzzle Frenzy Kids (download link).

Ask for User Rating: The Story of How I Doubled My Daily App Downloads

I currently have two apps in the Windows Store: Puzzle Frenzy and Puzzle Frenzy Kids. I’ve been closely monitoring user rating, feedback and request from day one and tried at the same time to tweak and improve the apps.

However, one thing I noticed quite fast was that my app was not getting too many ratings. Even if rating an app is possible in Windows 8 for all apps without extra work (bring up right side bar -> Settings -> Rate and review), my users were simply not doing that. On top of that, I noticed that my competitors’ apps and all the top apps in the same category had hundreds, thousands, even tens of thousands of ratings.

I also realized that the more ratings an app has, the higher it is placed in the Windows Store. It goes without saying that user ratings have a significant contribution to the ranking of the app.

Therefore, I decided to ask for user rating inside the apps, to see if the users will respond and rate my apps more frequently.

However, I found what I think is the sweet spot for getting users to rate the app:

  • I will ask users to rate the app only after they have engaged in (and hopefully enjoyed) the app, that is after they already played 3 puzzle games. By doing so, the users will most likely give it a good rating because they appear to have enjoyed the app enough to stay in the app and play all the 3 games.
  • I offer the user the choice not to rate it and ask again later. I tried not to be too annoying with these requests so I only display it after 3, 7, 15 or 30 games. If even after the fifth prompt the user hasn’t rated the app, I won’t bother him again because he most likely isn’t going to rate the app anyway.
  • I don’t bother the user again once he rated the app, but I still display a “Rate app” button on the home page, in case he changes his mind or wants to update his rating.
Puzzle Frenzy User Rating Prompt

Puzzle Frenzy User Rating Prompt

After introducing these changes, the number of ratings I was getting increased quite a lot.  In around one week I started to get the same number of ratings which before I was getting in one month.

As a consequence, (there were other factors for sure, but the user rating prompt was most likely the most important) the apps got ranked higher and higher, and they started getting more downloads.

On average, now I get around twice as many downloads as I did before.

I highly recommend adding such prompt to anyone developing apps on any platform.

Be ready however, with more ratings and feedback comes more responsibility.

Take user feedback into account and react to it as it will help you improve your app.

Good luck!

Ensuring Data Integrity Using Digital Signatures in WinRT

The data stored in Windows Storage  for Win8 Apps (equivalent of IsolatedStorage for WP8) can be accessed by users directly, even by using Windows Explorer.

The files are stored under C:\Users\<User>\AppData\Local\Packages\<AppName>\LocalState and even if <AppName> is actually a combination of publisher name, app name and another sequence of letters, it is pretty easy to tell which app is which.

If you are going to store data and you want to keep your users from modifying it, you have to make sure you have the right mechanisms in place for doing so.

Luckily, WinRT has some useful libraries for helping you accomplish file signing in Windows.Security.Cryptography namespace.

The classes in this namespace can help you ensure the integrity of a file by creating a digital signature whenever you save it, and by verifying the signature whenever you read the file.

Wikipedia is a good starting point for finding out more about Digital Signatures and RSA.

Here is how you initialize the all the variables needed for signing and signature verification:

var hashAlgorithmName = HashAlgorithmNames.Sha1;
var asymmetricKeyAlgorithmName = AsymmetricAlgorithmNames.RsaPkcs1;

hashAlgorithm = HashAlgorithmProvider.OpenAlgorithm(hashAlgorithmName);
asymmetricKeyAlgorithm = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(asymmetricKeyAlgorithmName);

var privateKeyBuffer = Convert.FromBase64String(privateKeyString).AsBuffer();
privateKey = asymmetricKeyAlgorithm.ImportKeyPair(privateKeyBuffer, CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey);

Here is how you create a signature:

public IBuffer Sign(IBuffer byteArrayBuffer)
{
var hashBuffer = hashAlgorithm.HashData(byteArrayBuffer);
var encryptedBuffer = CryptographicEngine.Encrypt(privateKey, hashBuffer, null);

var hashString = CryptographicBuffer.EncodeToBase64String(hashBuffer);
Debug.WriteLine("This is the hash:" + hashString);

var encryptedHashString = CryptographicBuffer.EncodeToBase64String(encryptedBuffer);
Debug.WriteLine("This is the encrypted hash:" + encryptedHashString);

return encryptedBuffer;
}

Here is how you verify a signature:

public bool VerifySign(IBuffer originalBuffer, IBuffer encodedHashBuffer)
{
var originalHashBuffer = hashAlgorithm.HashData(originalBuffer);
var decriptedHashBuffer = CryptographicEngine.Decrypt(privateKey, encodedHashBuffer, null);

byte[] originalHashArray;
byte[] decriptedHashArray;

CryptographicBuffer.CopyToByteArray(originalHashBuffer, out originalHashArray);
var originalHashString = Convert.ToBase64String(originalHashArray);
Debug.WriteLine("Original hash:" + originalHashString);

CryptographicBuffer.CopyToByteArray(decriptedHashBuffer, out decriptedHashArray);
var decryptedHashString = Convert.ToBase64String(decriptedHashArray);
Debug.WriteLine("Decrypted hash:" + decryptedHashString);

return originalHashString == decryptedHashString;
}

Notes:

  • In order to make it work, you need a private key which you can generate using:
var key = asym.CreateKeyPair(512);
  • For the sake of simplicity, I keep the private file as a resource inside the app, which is not¬†necessarily¬†a good idea. The only reason I do it in this way is because I want to prevent anyone from easily changing the content of the saved files. However, this approach can easily be improved by storing the private key into a secure location and retrieving it over a secure channel.

Remember! Signing a file won’t keep your users from seeing its content, it will only prevent them from modifying it, or let you know if they they did.

Good luck!

How Many Unit Tests Should I Write for Each Method?

5 (Five) unit tests. That’s how much unit tests each method deserves!

Here are your options:

  • 0 unit tests: obviously not the best choice. How do you know your code even works?
  • 1 unit test: you are probably looking to increase your code coverage and don’t care that much about testing. Either your team or your manager made you write that unit test. Or maybe you just want to feel good about what your are doing and brag about how you are unit testing.
  • 2 unit tests: they ensure basic coverage as any method should have at least a positive and a negative test.
  • 3 – 4 unit tests: you are taking your code seriously and you may feel both proud and confident, but you shouldn’t stop here…
  • 5 unit tests: always think about edge cases, null variables, exceptions thrown by APIs you consider solid and unbreakable. Have a healthy dose of paranoia and spend time refining your code, and testing those cases your users are sure to find.

Perhaps these numbers are a bit too precise. Of course each method is different, and each developer/team has his/its own goals and know how much they must/should test.

However, always ask yourself “Are there any other tests I can write?” And if there are, go ahead and write them!

The most important thing is to feel confident about your test. They are the ones allowing you to write code faster, eliminate bugs before the code reaches production and in the end build better apps.

PS: If you find yourself writing more than 5 unit tests you should consider refactoring the method you are testing and splitting it in two or more methods. The tests will become simpler, easier to read, and will cover less functionality, making them easier to maintain.

Happy coding!