My Visual Studio Solution for Project Euler

Saturday, January 23 2010

I’ve recently been getting back into completing problems found at Project Euler. There are a lot of good problems on there that help me hone my programming skills (especially when it comes to test driven development). When starting into these problems again, I decided to create a solution where I could easily start up the TDD process without having to concern myself with other tasks that I found myself doing over and over again. I presently have this solution hosted in a Google Code repository. Feel free to check it out.

I created a solution with a simple architecture: The Core project houses things such as IEulerProblem, a simple interface that I can define Euler problems under, and all of the problems themselves (along with the other classes needed to solve those particular problems). I have a DependencyResolution project for my Inversion of Control needs. Currently, I’m using Unity, but as this is the only project that depends on it, I can easily switch. The UI project houses a simple console application which outputs both the problem and the solution. Now that this part is written, I don’t have to touch it: All I do to show a different problem is change which Problem class IEulerProblem resolves to in the DependencyResolution project. I have a UnitTests project as well. This is where all the TDD magic happens, naturally. I also have an IntegrationTests project. This project basically houses the Acceptance Tests for the solutions I’ve written, just to make sure that the implementations of the solutions are actually correct. I write these tests after I have submitted my answer.

I have a ClickToBuild file set up for this solution, which builds the project and runs all of the tests within a command prompt window. This allows me to easily verify that my solution is in good working order before checking in any more changes. Another goal I have for this project is to set up some sort of Continuous Integration for it (most likely through TeamCity). I have a somewhat-old machine that I’m planning to turn into a little server so I can tinker around with this concept.

Definitions of classes common to all problems, such as IEulerProblem, are subject to change. In fact, I changed the interface simply because moving from the first problem I attempted (#8) to the next one exposed something that didn’t belong there. I believe that this solution will continue to evolve as I complete more problems with it. This is probably a bit overzealous for such a simple project, but I wanted to tinker around with designing a solution architecture that I’m satisfied with.