Developing for Windows Mobile – Guru Meditation

I’ve been working away for a few nights now trying to put together a simple framework for building user interfaces on a Windows Mobile device. It’s only taken a few nights to build something that I’m pretty happy with… and I was thinking of maybe even posting some source code.

It was at this moment of course that I had a visit from my Inner Guru. You know the one… that little voice in your head that sniggers impolitely whenever you struggle to convert a loop into a LINQ expression. Or when you’re hacking out some prototype code and you need to new up an instance. You know that really its going to need an IOC container, you look around, no-ones watching… in goes the explicit “new Foo()”. Immediately your Inner Guru can be heard muttering to themselves, “tut… tut.. will he never learn…”.

Anyhow, my Inner Guru popped in for a visit just the other day and we had a quick chat about the work I’d been doing on my mobile framework. The conversation went something like this:

Me: Hey – check out this framework I’ve been building for Windows Mobile – pretty cool huh?

Guru: Hmm… yes it appears you’ve made quite some progress.

Me: Yeah – look it can do animations.

Guru: Very impressive. Did you have trouble using the DirectX libraries?

Me: Ah well, err no it’s just using GDI.

Guru: Ah, I see. Does that give you full hardware acceleration on the device?

Me: Um… no I don’t think so.

Guru: Ah, I see. Commendable that you have support for an opacity on each element.

Me: Yeah, well I mean no. It seemed like a good idea at the time but I haven’t done that yet.

Guru: Ah, I see. It appears all objects support using a RotateTransform?

Me: Yeah, well I mean no. I couldn’t figure out how to rotate images an arbitrary amount with decent performance.

Guru: Ah, I see. I notice that your transforms all inherit from a base class which of course must perform the Matrix calculations.

Me: Yeah, well actually no. I mean there is a base class but I haven’t bothered implementing the transforms using Matrix math – they’re just, you-know, hard coded.

Guru: Ah, I see. It seems you’ve done some work building the framework for a layout engine that can be plugged into any container control. Seems a bit WinForms’ish to me, not very WPF like.

Me: Well I didn’t think it was so bad, although I haven’t actually written that bit yet.

Guru: Ah, I see. So no actual layout panels yet, not even the most simple stack panel?

Me: Err, well no – but it wouldn’t be hard to add.

Guru: But you haven’t done it – even though it wouldn’t be hard.

Me: Well no.

Guru: Hmm.

Me: I was thinking of posting the source code.

Guru: I see. So despite the obvious architectural flaws, the missing classes, the lacklustre performance, the questionable code formatting you feel it adequate for public viewing, or perhaps that may be ridicule? I see you’re still using foreach loops – can’t quite seem to wrap your head around LINQ can you dear boy?

Me: Umm…

Fortunately it was at this point that my Inner Guru hit an untrapped exception deep in his runtime. The following image began blinking away in my head.

I suppressed an evil chuckle and posted the code: