Christian Heilmann

You are currently browsing the Christian Heilmann blog archives for November, 2007.

Archive for November, 2007

Sending objects as parameters – good or bad?

Wednesday, November 7th, 2007

One of the differences I keep seeing in functions and methods lately is that people seem to go away from the strict pattern of expecting parameters in a certain form. If you look back some years you might remember functions like the following:


function doLayerFloat(id,start,end,direction,speed,fade,whatelse,Iforgot){
...
}

This, at least to me is rather annoying as I am terrible at remembering the order the parameters need to be sent in (conditioning in PHP confusion probably). The other issue I kept seeing with this was that if you didn’t want to provide some of the parameters but one of the last ones you had to send empty strings or even null values:


doLayerFloat(‘myDIV’,0,30,null,null,true,null,null){
...
}

// or
doLayerFloat(‘myDIV’,0,30,’‘,’‘,’‘,’‘,’‘){
...
}

This is both confusing and convoluted. Other scripts I have seen work around the issue by using the arguments array, which at least allows a flexible amount of arguments to be sent.


function doLayerFloat(id){
var args = arguments;
for(var i = 1; i < args.length; i++) {
...
}

}

However, my favourite these days is functions that actually take a few defined parameters (or a single one), allow for it to be several things and allow you to send an object as the properties:


function doLayerFloat(id, props){
var elm = typeof id !== ‘string’ ? id : document.getElementById(id);
for (var i in props){
...
}

}

This allows the id to be either an element reference or a string and takes an object as the second parameter in which I can define the order and amount any which way I like (provided the method then tests for each of them and their correct values):


doLayerFloat(‘x’,{start:20,end:30,fade:true});
// or
doLayerFloat(myElm,{fade:true,direction:’right’});

This also allows you to define default values should the properties not be set, something you can do in PHP but not in JavaScript. In PHP, this works:


function foo($bar=2,$baz=’foo’){
}

In JavaScript that can’t be done, but if you use an object you can predefine if the properties are not set:


function doLayerFloat(id, props){
var elm = typeof id !== ‘string’ ? id : document.getElementById(id);
props = props || {};
props.start = props.start || 100;
props.fade = props.fade || false;
}

Do you agree? Or is the object literal syntax still too tricky?

Sky is dishing out £10k for widgets using their RSS feeds

Tuesday, November 6th, 2007

Well, in a competition, not just directly. I like the idea of Sky News’ Developer Competition where they offer all in all £10k in prize money for widget and badge implementations of the content of their RSS feeds.

Talented developers can use the feeds to create their own applications. The brains with the best ideas will be invited to a Dragons’ Den-style judgment day at the Sky News studios.

A bit of a shame is that they haven’t got an API yet, but I pointed them to Yahoo! Pipes to offer developers as a workaround to use the RSS feeds in an easier manner.

The deadline is 30th of November and the Dragon’s Den shootout is on the 20th of December in the Sky offices. So if you want to have a go, get coding :) Make also sure you check the Terms and Conditions of the competition.

So what is the deal with the new gmail crashing my Firefox (or stalling it)

Tuesday, November 6th, 2007

I am a big fan of gmail (and a lot of colleagues scowl at me for it). With the massive amount of emails I get daily and me working on 3 computers there is just no other way to get around them.

Until the latest update of gmail though. Now my two laptops (both Windows) get stuck and I have to shoot down Firefox 5 times a day to be able to work. Sorry Google, but what happened? I turned off Firebug as you asked me to and yet it messes up. I also tried switching to the “older interface” but my setting does not get stored (yes, cookies are enabled).

I also tried to turn off sounds of the chat inside gmail but yet it keeps crashing. Don’t make me change because of superfluous bells and whistles, I have too many good contacts in your system.

PlugLondon – let there be talk, let there be beers and let there be London developers shape the event

Monday, November 5th, 2007

Once in a while you realize that a lot of people are like you. When I joined a big internet corporation a lot of people asked me if I will shut up about bad things on my blog or if I will become a company drone now. The joke never gets old and I told some other people in the same situation about it. Well, we drank some beers, chatted and now it is time to take action:

PlugLondon is a meetup for developers in London in December sponsored by ebay, Yahoo, Skype and Paypal.

The catch? All of the people involved agreed on leaving both HR and PR out the door and do the thing ourselves. So on the 8th of December we want all the London people who drive software innovation to show up, chat with us about their products, how they use our APIs, get info from our experts and of course have several beers and food.

We are planning on repeating the exercise every half year and basically want to show that London can be as cool as the Valley but not as annoying to get to for UK folks.

The event has no branding yet and we invite people to give us logo ideas. The audience at the first meetup will choose which is the best and we go from there.

So come around, check out the different parts:

See you there,

Chris

It’s all about APIs these days.

Friday, November 2nd, 2007

It is quite cool to see the increase of coverage of the topic of web APIs. It is also very exciting to APIs finally evolving to work across several systems, aggregate and move from a one way stream of retrieving data to an alternative entry point for applications. How cool will it be for example to write reviews for amazon on movie or book sites? Having write APIs would allow us to leverage the knowledge of people on the web at the places they hang out rather than having to lure them into using a web app.

Anyways with this new API interest I had a triple release today: There is a podcast about APIs for .net magazine together with Jeremy Keith, Paul Hammond, Drew McLellan and hosted by Paul Boag, Ajaxian is featuring my ‘hack’ of the Slideshare RSS feed and I uploaded the presentations I gave at the University Hack Day introduction at Dundee, Scotland yesterday.

Enjoy!