Flickr.Net API Library 3.0 Release

I’ve just released a brand spanking new version of the Flickr.Net API library.

The big things to note are that this version has over 150 unit tests to make sure it is working correctly. It also covers 100% of the Flickr API methods (there is a unit test that ensures this).

I’ve also sent some considerable time running Microsoft Code Analysis against the library to try to ensure that it meets most of the Microsoft guidelines on library design. This has resulted in some quite wide ranging changes, most noticeably to many of the class names in the Library. Most of these changes could have been avoided but I felt that it was better to get the library in a consistent and easy to understand position going forward than try to maintain a large segment of code just for backward compatibility reasons.

The main reason for the change was actually to do with a little Flickr method called flickr.photos.getFavorites. Previously the library had used XML serialization and the serialization attributes to handle converting the returned XML from Flickr into .Net object. However there was a huge clash between the flickr.photos.getInfo method, which returned a root element of <photo> and sub elements containing different bits of information about that photo and the flickr.photos.getFavourites method which also returned a root element of <photo> and sub elements of <person> which were the people who had favourited that photo.

One solution to this was to add a PersonCollection property to the PhotoInfo class, but this I felt would just add to the already growing confusion in other areas, such as when returning a list of Photosets the Photoset.PhotoCollection property would always be null – this is because PhotosetsGetList does not return any photos, but the Photoset class is used in more than one place so had to handle all scenarios.

So instead I had to develop a method of overriding the XML deserialization. I chose to do this by a combination of a custom Interface (IFlickrParsable) and the use of generics to handle the processing of the responses.

Changes

So, now instead of PhotosetsGetList returning a Photosets class, it returns a PhotosetCollection class. This class is a generic collection which can be iterated over using foreach etc. It no longer has a PhotoCollection property. Instead the PhotosetsGetPhoto method now returns a PhotosetPhotoCollection which is a collection of Photo class instances as you would expect.

string ApiKey = "ABCDEFG";

string UserId = "";

Flickr f = new Flickr(ApiKey);

PhotosetCollection photosets = f.PhotosetsGetList(UserId);

foreach(Photoset photoset in photosets)

{

    PhotosetPhotoCollection photos = f.PhotosetsGetPhotos(photoset.PhotosetId);

    // Do something with all the photos here.

}

Likewise there are a large number of other changes – most noticeably that the Photos class is now called the PhotoCollection class.

Beta

Due to the large number of breaking changes I’ve labelled this version a beta until such time as I have had chance to actually use it myself. I’m already underway moving my Flickr screensaver over to this library, and its improved support for the Flickr methods has saved a huge number of method calls in that already, so I’m hopeful this is only a good move.

Download the latest version of the Flickr.Net API Library from here: http://flickrnet.codeplex.com/

You can also report bugs and ask questions over there too.

Peaceful Night

Last monday our Virgin Media connection went down. We lost our TV and
the internet (but phone was still working, somehow).

Now you might think – bloody disgusting, but I’m actually thankful.
Instead of sitting, face glued to a screen (TV or monitor) I put some
music on (Sign No More by Mumford and Sons for those interested) and
sat and read a book. Then I went to bed early and had a great nights
sleep in my brand new foam mattress, that also helped me sleep well, and I got it at a mattress sale blackfriday. And so far, so good.

I think I needed that.

Posted via email from Sam’s Random Junk!

Regex Split bug in JScript?

I’ve been messing around with JavaScript quite a bit recently and I came across a ‘bug’ in the Microsoft implementation of the split() method.

Take the following example string (note the two tabs at the end):

var s = “HellotHowtaretyoutt”;

and then run the following to write it out to the screen:

document.writeln(s.split(“t”));

Well that works as expected, and outputs “Hello,How,are,you,,”;

But if you replace the string in the split method with an inline Regex object it fails if run under a Microsoft implementation

document.writeln(s.split(/t/));

This outputs the same as above in Firefox etc, but if run in JScript (i.e. Internet Explorer) you lose all empty elements and get the following: “Hello,How,are,you”. This is really weird, because if you use the string delimiter above it works just fine.

I have managed to find another blog post that tries to fix this problem, but doesn’t say why it happens.

http://blog.stevenlevithan.com/archives/cross-browser-split

To test this online, try going to W3Schools.com.

What makes StackOverflow different…

I was asked the question recently, what makes StackOverflow different from other developer forums. (Thanks http://twitter.com/redgum)

http://www.stackoverflow.com

I’ve only been using it for a few days now, and its still in private beta, although it is claimed to be (mostly) feature complete.

There are a few obvious things that mark it as different from your usual developer forum.

1. No forums

It doesn’t have the concept of forums, instead uses tags to provide order to the chaos. This is good, in that everything gets at least some attention when it is posted, as well as the eventual problem of things being posted to the incorrect forum never appearing.

2. No login

Eventually you will be able to ask questions and answer them without logging in. This does sound very strange, and as the web site is still in private beta it really isn’t being tested much yet, but it certainly could make life interesting.

3. Voting

Questions, as well as answers can be voted up and down – you require a log in and the required reputation to do either of these things. Reputation is gained from answering questions, having questions and answers voted up, and by having answers marked as ‘correct’ by the question asker. The exact formula isn’t really known.

4. Badges and Reputation

As you answer questions and generally interact you gain reputation, and various ‘badges’. This is in common with many game web sites (such as Kongregate) where completing certain objectives gives you a particular badge. Badges are given for things like ‘First Answer marked as Correct’.

So far this is producing a very fluid and engaging experience, but I don’t think it will truly get tested till it is open to a) Spam and b) Crap questions. Hopefully the reputation/voting system will encourage the better questions, while discouraging the worst.

Will StackOverflow end up any different from all the other developer forums? They have certainly set out on the right path. Whether this path enables them to end up better than the rest is something I think is still to be seen.

Reasons Twitter is a better IM client…

I'm starting to like twitter. As with most (damn the phrase) web 2.0 major sites I have an account (I'm there on all the social networks, flickr, pownce, last.fm, friendfeed etc) but I found it quite hard work to get used to the format.

Then I started trying out http://www.posterous.com which takes anything I email them (like this), throws it on a blog and then updates twitter. That and a couple of people who've sent me actual tweets (ok, that still sounds silly) and the service just comes alive.

And the reasons I prefer it over normal IM – well mainly because of the whole "who's online" thing – I hate being pinged in IM by people at random times – if maybe I just logged on to check one thing in google, or I'm trying to write some code or play a game. So what do I do, well I shut down the IM client – or even worse make sure it doesn't start at startup. And from there on in it becomes pointless.

With Twitter there is no concept of being online – you just post anytime you want – and read others posts anytime you want. You can keep track of those sent to your ears, as well as what the world is saying (I think Search was the big thing missing, but now they've got that sorted too).

And if you close your twitter client (or heaven forbid twitter is down) then that's just a while for you to get more work done :)

Posted by email from Sam’s posterous

Big Bug in Flickr Screensaver

Hi

I’ve just been informed of a fairly large bug in the uninstaller for the latest Flickr Screensaver.

Basically if you uninstall it it will try and delete your WindowsSystem32 directory.

Obviously that is VERY BAD. I apologise. I’ve deleted the installer from the web site, but anyone who has the latest version of the screensaver should not uninstall it.

Sam