Lessons learnt from my first Node.js project

Over the last couple of months my wife and I have been working on a little web game called findthatrobot.com. It’s a small, building it for the fun of it project, and gave me a chance to stretch my newly acquired Node.js muscle. I’ve played around with some small Node.js projects over the last year or so, mostly following tutorials and the such, and this was my first complete project. I’m going to share with you what worked for me and what didn’t, in hopes that anyone else out there might learn something to make their lives easier, or perhaps be inspired to try Node.js for...
read more

Red-Black Tree in F#

Here’s some F# just for fun, it’s some code translated from the Qi code here.
read more

Alternating Row Styles in Silverlight

Update: There was an issue when using ItemsControl because of the way I was determining if one control was in another (I was using the DataContext.) This example code and attached ZIP have been updated. Because the ItemsControl in Silverlight 4 doesn’t support alternating styles on the child items, I’ve made this set of attached properties to allow you to switch the style on any item contained within an ItemsControl or anything that inherits from it (e.g. ListBox.) I’ve uploaded a sample project, but here’s the entirety of the code for those who don’t want to download...
read more

Dealing with infinite recursion redux

In a previous post about infinite recursion I proposed the use of the ThreadStaticAttribute to deal with infinite recursion. This approach is fine so long as your recursion doesn’t cross threads, if it does the static variable will be reset for each new thread and offer not benefit. Here’s an example, in .NET 4.0, to show you what I mean. In this example I have a simple logging setup, with a list of IListeners which handle messages that a logged with the LogMessage function. It’ll get into a infinite recursive loop becuase the LogToDiskListener attempts to log a message, and the...
read more

Phil’s 10 Rules for the treatment of Exceptions

You know what I love, Exceptions. Exceptions are awesome. They’re an awesome tool that simplify post-mortem debugging, help developers code against and understand the internal workings of an API and they help prevent applications getting into a corrupt state. Even though exceptions are so invaluable, a lot of the time they’re poorly understood, abused, ignored and forgotten. I hope that I can earn some respect for the venerable exception, by setting down some rules on how they should be treated. Phil’s 10 rules for the treatment of Exceptions: Throw early, throw often[1] This is key...
read more

« Previous Entries Next Entries »