Kami 2 Solver

I love the game Kami on my iPhone, by State Of Play games. When they brought out the sequel, Kami 2, I was very excited! But it proved to be a lot harder than the original, and before no time I was stuck and had run out of hints. So I wondered if it was possible to solve this puzzle with a program. I’d written myself a solver for Soduku in C# using the algorithms I used in my head to solve the problems. I figured I could do something similar with Kami. The first solver I found was by…
Read more →

Dependency Injection via Constructor Injection

The most common way of implementing Dependency Injection (DI) is to use Constructor Injection with classes. Let’s suppose we have a Customer class defined as follows:

We can create a service to fetch customer records and define an interface for this service:

An actual implementation of the DataService class could look like this:

Obviously the real thing would fetch the real records from somewhere, e.g. a database. When we fetch these records we’d like to put them in a Customer repository. Whenever we create an instance of the CustomerRepository class we’ll pass in the dependency to the…
Read more →

Kinect Point Cloud Normals Rendering – Part 4

In this post I’ll create a WPF front-end to the C++ template code I’ve been using so far. I’ll use a CLR wrapper to achieve this. The first step is to create a WPF project. I like to use MVVM Light Toolkit for my WPF projects. I’ve installed the Visual Studio plugin so it comes up as on option when I’m creating a new project. I started by created a project called DepthViewer2D: Once I created this project I added a new project to the solution called DepthImageRenderer. This is a C++/CLR class library project. You’ll find it under “Other…
Read more →

Polymorphism and Abstract in C#

Let’s say you want to define a base class that other classes will inherit from:

We want to make sure that everything that inherits from this class will implement its own version of the CreateBrushes() method. If this method isn’t implemented then we will get a runtime exception every time our inherited class is instantiated. This is one way of ensuring that inherited classes provide an implementation of a method. However, we only find out the problem at runtime. A better solution would be to get an error at compile time. This is where the abstract keyword comes in….
Read more →