Monday, 13 June 2011

If you have an MSDN subscription then you'll also get some Azure benefits. These have even been increased recently. PhotoPivot is a BizSpark member so we get access to MSDN Ultimate which entitles us to 1500 hours of Small compute instances per month.

Be warned: THESE BENEFITS ARE NOT INTERCHANGEABLE!

What I mean is, if you're on Ultimate you can use 1 Small compute for 1500 hours or 2 Small computes for 750 hours each etc. What you cannot do is use an Extra Small compute for 1500 hours or 1 Medium compute for 750 hours. The benefit is SPECIFIC to the exact type of compute size.

Friday, 13 May 2011

Welcome to the first in a series of video blog posts where we'll be looking at what's new for PivotViewer v2 in Silverlight 5.

In this episode we'll take a deep-dive into PivotViewer v2 and look at what legacy support is available to all those that have created static, server-side cxml collections. We'll also see some great dynamic benefits that can be applied to these existing collections with v2.

Please leave comments, feedback and any suggestions for things you'd like to see in this series.

Friday, 15 April 2011

Every time you make a call "across the wire" you've got to provision for errors. Everything from gateway timeouts, server faults right down to your toddler pulling the lan cable out. If it can happen, at some point, it probably will.

This approach is fine if you only have a couple of calls in your application. In today's hyper-connected world, however, it's more likely that you'll be making lots of these requests with wildly differing signatures. Very quickly your code will become unreadable as you battle to trap all the possible exceptions and manage the retries. What we need is a pattern for easily applying this retry mechanism to any call whilst keeping our client code clean.

Real-world Example

There are a myriad of 3rd party libraries that allow you to target platform APIs e.g. Twitter, Facebook etc. At PhotoPivot.com we rely heavily on Sam and Tim's great FlickrNet library to perform an enormous number of calls to Flickr. Here's a greatly simplified bit of production code from our server-side application:

Potentially, any of the calls to the IFlickr interface can result in a sporadic network error. This is a serious pain if it happens inside the foreach loop when the routine is 90% through a list of 10,000 photos. If we implemented the ad-hoc solution at the start of this post the GetPhotoDataForUser method would become very untidy and a developer's ability to read it would lessen. So, let's look at some of the related classes. Below you can see the interface that the service uses to describe its requirements. We then used the Adapter Pattern to "bring in" the interface to the main FlickrNet class.

So, how do we encapsulate all the methods, or at least the methods we need, in the main Flickr class? We can't rely on just extending the class as it, or its methods, might be sealed. Let's start by creating a class that can keep track on failed attempts and whether a retry is possible.

You will, unfortunately, need to create a new class for each signature function call needed. For instance, the one's above will work for calls that match Func<TResult> or Func<T, TResult> only. Func<T1, T2, TResult> will need another class. Functions that don't return anything are Actions<>. You'll need separate classes for these also. Once done, though, the ROI will be huge.

We now have the capability to make calls robust but how do we 'invisibly' add this to someone else's class? We'll use the Decorator Pattern to create a new class that "is a" IFlickr but also "has a" IFlickr. By initially abstracting our service's needs to an interface we have enabled ourselves to do this very easily.

Now that we have all our pieces in place the ONLY change we need to make to our entire application is one line in the client. The service still gets the IFlickr it requires and simply doesn't care about the implementation:

var flickrBase = new FlickrEx();
// New line: Use the Decorator Pattern to extend functionality at runtime...
var flickr = new RetryableFlickrEx(flickrBase);
var service = new FlickrPhotoDataDownloadService(flickr);
service.GetPhotoDataForUser(userId);

Friday, 14 January 2011

When someone technical decides to step off the cliff and become a founder of a startup there are always going to be challenges. Most programmers and developers believe that these will come from areas outside of their comfort zone - sales, marketing, taxes, fund-raising, design and even just networking! This is why the standard co-founders model partners someone technical with someone more 'businessy'. The reality, however, is very different.

For me the biggest challenge I face as a technical founder is programming. To be more specific: stopping programming. For years I have measured my progress by ticking off features delivered, bugs fixed or user stories completed. It's a well understood system and it's easy to track, but that's not what I should be doing. My job as a founder is to find a repeatable business model that will make money, and the only route to achieving this is via validated learning.

Here's an example:

Earlier this week I was building some new server functionality for @photoPivot. I found myself working through the options of how and where to host a service and what type of communications medium was going to be the absolute best for this. Eventually I realised "Who cares? It doesn't matter!". All I needed to do was test my idea in the quickest way possible. Just stick it in a console app and off we go (sneakernet style!).

Now, this doesn't mean that you should write bad, unmanageable code. You can still test your ideas in a way that isn't going to back you into a nasty corner in the future. Just be a little pragmatic. Do enough to get it working, then step away. I know how difficult it is to know that you could make something better - it's very hard to resist being the perfect craftsman. Once you've proven your idea then you can make it elegant; but why waste your time polishing something that you don't know people want?

For technical founders, programming is chicken soup. On difficult days we find comfort there and, by the evening, we've convinced ourselves that, yes, we made good progress today. Don't be fooled by these false metrics. Test your ideas quickly and build your company.