Why the Peggle mobile experience beats GTA

Peggle iconGTA icon

Pegs vs Triads

I’ve had two very different iPhone gaming experiences over the last few weeks: Peggle and Grand Theft Auto: Chinatown Wars. It’s safe to say I got completely addicted to Peggle, but when it arrived I couldn’t resist the temptation of having the GTA universe in my pocket too. After shelling out the almighty sum of £5.99 on the sandbox triad-’em-up, I discovered that there were many aspects of playing/using Peggle that make it a better fit on the iPhone than GTA. Let’s break down how these very different experiences manage the transition to a hand-held, “casual” gaming platform. What exactly does “usability” mean in this context?
Read More »

Posted in Gaming, Usability, iPhone | Tagged , | 1 Comment

Beware of using stack-based COM objects from .NET

There are all sorts of nasty things to be aware of if you’re mixing reference-counted COM objects with garbage-collected .NET. For instance, if you’re implementing COM objects in C++ then you’re free to allocate them anywhere you like; on the heap or perhaps on the stack if you know they’re only used in some specific scope.

But what happens if during the lifetime of that stack based COM object, it gets used from .NET? A runtime callable wrapper (RCW) will be created around the object. And this RCW expects to be able to keep the underlying object alive by incrementing its reference count. Of course, the stack-based object will soon go out of scope, and regardless of its reference count the object will be destroyed and the pointer that the RCW contains will no longer be valid. It points into the stack, so when the RCW gets cleaned-up, the CLR will call via this pointer into memory that contains garbage and you’ll get something nasty like an access violation or illegal instruction exception.

Read More »

Posted in .NET, COM, Debugging, Software Development, WinDbg | Tagged , , , , , , | Leave a comment

A WPF custom control in F#

In the world of WPF with its powerful templating support, you’re much less likely to need to build a custom control from scratch than you are with legacy Windows GUI frameworks. For the vast majority of scenarios it’s possible to take an existing control and modify its appearance and behaviour to get what you need. However it is still possible and sometimes necessary to build something in code. The other day I was looking at creating one – using F# of course – and realised that a skeleton control serves as a good example of the kind of cross-paradigm features the language offers. They’re the kind of things that make it possible to use functional F# with inherently imperative .NET languages and frameworks like WPF.
Read More »

Posted in .NET, F#, Software Development, WPF, Windows | Tagged , , , | 2 Comments

Don’t do anything in DllMain… Please

Novice Windows programmers can often think that DllMain is a good place to get that one-time set-up and tear-down work done. It seems to offer an ideal opportunity to know when your DLL has just been loaded, and when it’s about to be unloaded. What better place to add all that expensive, complicated initialisation…? STOP! WAIT! Before you add anything in DllMain, make sure you understand what state the process will be in when it gets called. Once you know that, you may well change your mind…
Read More »

Posted in Debugging, Software Development, Uncategorized, Windows | Tagged , , , , | Leave a comment

Generating and plotting random numbers

For a while now I’ve been planning to write a blog post about pricing financial instruments using Monte Carlo techniques in F#. As part of this I needed to generate normally distributed random numbers, and while putting together the code to do it I realised it was interesting enough to warrant its own post.

I’m making use of a few F#/.NET idioms to make the process easier. For instance, sequences (.NET’s IEnumerable) are used as the source of uniformly distributed random numbers. Also, to verify that the resulting numbers are actually normally distributed, we can easily use existing WPF/silverlight controls to visualise the values direct from within Visual Studio, in a manner similar to this previous post – but without having to write the plotting code ourselves.
Read More »

Posted in .NET, F#, Finance, Visual Studio, WPF | Tagged , , , | Leave a comment

Programming is like a bad analogy

The joy of programming is hard for anyone to precisely define. At least, it’s hard for programmers to define, and seeing as nobody else understands what the hell it is anyway, that’s pretty much the same thing. However a few people on the interweb have tried quite hard to describe just what the feeling of developing software is by comparing it to things in “the real world”.

A quick google reveals some of the funny, interesting and downright weird things that people have compared programming to. Let’s take a closer look at some of them…
Read More »

Posted in Rant, Software Development | Tagged | 4 Comments

Pinned DataTips in Visual Studio 2010 Beta 2

vs2010_pinned_datatipsI’ve just noticed a nice little feature in Visual Studio 2010 Beta 2: pinned DataTips. Values displayed in the debugger as you hover over a variable can now be pinned in place and remain aligned with the source. They can even have annotations added… Tasty!

Posted in Debugging, Usability, Visual Studio | Tagged , | Leave a comment

Comparing lambdas in C++ and F#

The other day someone pointed me to the new MSDN article on C++ lambdas in Visual Studio 2010. Interesting. C++0x has been a long time coming, but in my opinion anything that makes C++ usable at a higher level of abstraction is a good thing. There’s nothing wrong with a little abstraction, as long as you can get to the fundamentals if you need to. Otherwise you wouldn’t be using C++, would you?

But one of the things I couldn’t get over from that article is the verbosity. I’ve just got too used to the succintness of F#. I know this is only example code, so it’s intended to demonstrate usage, but the whole point of lambdas is to reduce boilerplate and make the intent of your code more obvious. So, let’s compare the C++0x implementation with the F# version.
Read More »

Posted in F#, Software Development, Visual Studio | Tagged , | 1 Comment

FormatException in WPF DataBinding

While working on some F#/C# WPF code the other day, I kept hitting a fatal FormatException when running under the debugger. Annoyingly, the app would quit with:

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.

But it worked fine when started from Expression Blend, or when run using Start Without Debugging in Visual Studio. Let’s take a closer look…
Read More »

Posted in .NET, Uncategorized, Visual Studio, Windows | Tagged , , , , | Leave a comment

TwitterVision: How Twitter transformed TV

TwitterTVFor a long time now, TV executives have bemoaned the lack of “event TV”. Modern broadcast television is a fractured ghost of its previous self. People’s attention is no longer focused in a tight beam on 3 channels; we have millions of videos at a click on YouTube, full-length TV shows and films on iTunes, hundreds of channels on satellite and cable. That means there’s no longer a significant section of society sharing the experience of a television show and discussing it the next day at school/the office water-cooler.

But what they seem to have missed is that something very different, but equally significant, has replaced it: the instantaneously-shared TV experience, enabled by Twitter. With the omnipresence of laptops, broadband and Twitter, the sofa’s now connected. It’s possible to sit at home on your own and discuss, berate and dissect whatever’s on RIGHT NOW.
Read More »

Posted in Rant | Tagged , | Leave a comment