Tuesday, August 31, 2010

The antipattern of hate

Code changed to protect the guilty, but the approach is the same. Also, this pseudo-code below is actually more streamlined, more sensible and slightly saner than the original.

static char* array[10];
static int other_array[10];

void get_values(int n)
for (i = 0; i < n; i++)
other_array[i] = get_val(array[i]);

int main (void) {
array[0] = "somestring";
array[1] = "some other string"
array[2] = "lalala"
array[3] = "bananas"


for (i = 0; i < 4; i++)

return 0;

If you think of writing code like that, don't. Google for function parameters and try to understand how they work. Some poor sod will eventually have to figure out wtf you're trying to do [1]. I've encountered this bit of code a few weeks back and I am still flabbergasted.

/me hopes this venting makes the anger go away.

[1] as I stated in an early post, any software project is a collaborative project. It has at least two developers [...]. The person you may end up hating for the above may be you.

Friday, August 6, 2010

First draft of multitouch protocol spec published

In case you're not subscribed to xorg-devel, I've sent off the first draft for the multitouch X protocol specification (as part of the X Input Extension 2.1) today. If you have interest in multitouch, please read through it and see if you can poke holes into the current approach.


Note that this is very low-level stuff. The data described by the protocol is what's sent on the wire to the client. Most applications are separated from this data by toolkits (GTK, Qt, etc.) and only few people are unlucky enough to have to care about the protocol itself.