7 tips for extending browser functionality to Silverlight apps

Silverlight 2 is an awesome platform for development of rich web applications. One issue to be aware of, though, is that some browser features do not extend into Silverlight apps. For example, the Back and Forward browser buttons do not always work as the user may expect with Silverlight apps. The set of browser features you’ll miss in Silverlight apps is pretty much identical to what you’d miss in Flash or AJAX, and some of them are about to be addressed in the Silverlight 3 release.

Let’s go over the affected browser features one by one, and discuss ways of getting them working in Silverlight apps.

Feature 1: Bookmarking and deep linking

Continue reading »

My YouTube debut: a RoboZZle demo video

It took significantly longer than I expected, but the RoboZZle demo video is finally on YouTube.

The video made the reddit front page, so you can read the usual mixture of insightful, funny, and outright insane comments on the reddit page and the YouTube page.

My favorite funny comment is this one:
silverlight_tinfoilhat1

And finally, this is the video:

Precomputed view: A cool and useful SQL pattern

In database terminology, a view is a named query that typically aggregates data from multiple tables. When using views, it is important to remember that querying a view will evaluate the query that defines the view. Repeated evaluation of the view - say from within a nested query - may seriously impact or even kill the performance of your application.

One solution to this performance problem is to use a “precomputed view”. Unlike an ordinary view, a precomputed view is stored in a table rather than computed on demand. When data in one of the aggregated tables changes, the update operation also updates the precomputed view table.

Continue reading »

Choose expression: proposal for a revolutionary C# construct

Notice that this post was published on April 1, 2009.

For decades, computer science students have been taught that so-called NP-hard problems do not have known efficient solutions. These problems include the infamous Travelling salesman problem, subset sum, 3SAT, and many more.

But - as is often the case - where theoretical Computer Science failed, sound software engineering practices will succeed. By using loosely-coupled OOP, agile methodologies and the model-view-controller architectural pattern, I developed a solution that someone trapped in the world of formulas and big Ohs would never dream of.

Enough with the background, and let’s take a deep dive into the intriguing design.
Continue reading »

The first month of my online game

It’s now been a month since I launched RoboZZle, so it is a good time to reflect on how things went so far. It has been a great experience, and the project took up all of my free time and then some.

For fun, I’ll discuss different aspects of RoboZZle and assign each a letter grade.

Game Addictiveness: A
Continue reading »

My hobby project: a social puzzle game developed in Silverlight

After about 3 months of evening coding, the game that I’ve been working on is now live.

RoboZZle is an online puzzle game that challenges you to program a robot to pick up all stars on a game board. The game mechanics are simple, yet allow for a wide variety of challenges that call for very different solution approaches.

Here is an example of a solved RoboZZle puzzle, with the arrow edited-in to show the path of the robot:

Continue reading »

Puzzling over arrays and enumerators in C#

Here is a little puzzle for C# developers reading my blog. What is the error in the program below?

   using System.Collections.Generic;
   class Program
   {
       public static void Main()
       {
           int[] arr = new int[10];
           IEnumerator<int> e = arr.GetEnumerator();
       }
   }

If you don’t see it, don’t worry.  I was surprised by this C# behavior as well. Just come back in a couple days to see the solution. Or try to compile the program in Visual Studio. :-)

PS.: The cause for the low cadency of posts on my blog is a side project (an online game written in Silverlight) that has been draining away my extra time over the last few months. Expect an announcement in two to three weeks, once it’s ready for launch.

How to recover a lost post in Windows Live Writer

Windows Live Writer is an awesome tool that I use to write all of my blog posts. I am so used to it that I can’t imagine blogging without it, but I have also found ways to shoot myself in the foot with it. Here are two ways in which I managed to lose a nearly finished blog post:

  1. Live Writer clears its undo history when you switch between views. So, if you mess up your article in the HTML view, you won’t be able to revert the change when you notice the disaster after switching back into the Normal view.
  2. In the Preview view, Live Writer looks a lot like Internet Explorer. If you are not careful, it is not too hard to close Live Writer by accident. And, the confirmation dialog looks somewhat like IE’s closing dialog.

Thankfully, I found a way to recover Live Writer posts, and saved myself some wasted work.

Continue reading »

How to write a self-printing program

As promised at the end of my recent post, I am going to explain how to implement a program that prints itself, in addition to doing other things (like playing Game of Life).

A self-printing program - also called a quine - is a program that prints out its own source code. I will describe one simple way to implement a quine that can be adapted to just about any programming language. The technique does not depend on any unusual language features, but also does not necessarily yield the shortest possible quine in a particular language.

The main idea behind this quine implementation is simple. The quine will consist of two parts: a definition of a string and the program core. The string will contain the source code of the program core. And, what will the program core do? It will print the string twice: once to print the string definition, and again to print the program core.

Continue reading »

Self-printing Game of Life in C#

Conway’s Game of Life has fascinated computer scientists for decades. Even though its rules are ridiculously simple, Conway’s universe gives rise to a variety of gliders, spaceships, oscillators, glider guns, and other forms of “life”. Self-printing programs are similarly curious, and - rather surprisingly - have an important place in the theory of computation.

What happens when you combine the two? You are about to find out, but one thing is for sure: the geekiness factor should be pretty high.

I wrote a little C# program that contains a Game-of-Life grid. The program advances the game grid to the next generation and prints out a copy of itself, with the grid updated. You can take the output, compile it with a C# compiler, run it, and you’ll get the next generation of the game. You can iterate the process, or change the initial grid state manually.

Continue reading »

Next »