This is the blog of Gerd Riesselmann, a freelance software developer from Cologne, Germany. This site contains articles about software development and user interface design in general and object oriented programming in special, covering a set of programming languages from C++ and C# to PHP and Javascript. Additionally, you'll find code snippets and modules for Drupal, the open source content management system powering this site.


XMLRPC value types and C++

A while ago, I was looking for a C/C++ XMLRPC client implementation. However, for some reason or another, I was unsatisfied with the recent implementations, which mostly seem utterly complex for my purposes. That's why I decided to roll out my own. While the XML building and parsing is more or less straight forward (although there's too much redundancy and unneccessary tags in the spec for my taste), implementing the possible value types made me scratch my head. The XMLRPC protocol supports a set of data types: integer, string, double etc., but also an array or a struct. Integer and double are native types, string is either a char pointer or a class. How this should be put within one class? My first sketch introduced a quite complex model with an impressing inheritence chain, but then boost::variant came to the rescue:

Using scriptaculous slider with two handles

Since version 1.6 the slider widget coming with the script.actulo.us javascript library can have more than one handle. This for example allows something similar to the Amazon diamond search. I did it here. However, the script.aculo.us documentation isn't up to date currently, so here's how you do it.

I'm a freelancer now

Well, the headline says it all: Since April 1st I'm a full time freelancer now. And to be honest, I'm still surprised about that fact.

I decided to become a freelancer about half a year ago, and my original schedule looked like that:

  1. Register yourself as a freelancer with the officials, get firm with taxes etc.: immediately
  2. Reduce working hours, so there's actually some time for freelancing: as soon as possible
  3. Quit company and live happily ever after: about one year later

Well, things developed faster than expected. I started my business in October 2005, reduced working hours in January 2006, and left my former job behind on April 1st, the first date possible. I already told my boss I will leave the company at the beginning of February.

Roots of the net

Roots of the net - How the internet came to Germany: A full day conference about the history of the internet taking place in Bonn. Looks promising - plus it's free!

A triangle with rounded corners in C#

For one of my projects I needed to draw triangles with rounded egdes, and since I didn't found anything about this topic elsewhere, I had to figure it out by myself. Luckily no mathematics is needed, except the Pythagorean theorem. So here'S how I did it, complete with a sample implementation using C#.

To make things easier, I started with a right-angled triangle where the two sides forming the right angle are vertical and horizontal. This makes applying a rounded corner for the right angle easy, since it is a common problem known from drawing rounded rectangles. You'll find examples for this all over the net. I instead will discuss, how to round the two other edges, which both form an angle of 45 degrees.

A 64 bit integer for PHP

thegeek misses a 64 bit integer for PHP (German), since he uses a bitmask with more then 32 options. Here's a proposal, how to deal with this problem by splitting a float into two integers:

<?php
define
("BIGINT_DIVIDER", 0x7fffffff + 1);

function
split2Int(&$upper, &$lower, $value) {
 
$lower = intval($value % BIGINT_DIVIDER);
 
$upper = intval(($value - $lower) / BIGINT_DIVIDER);
}

function
bigInt2float($upper, $lower) {
  return
$upper * BIGINT_DIVIDER + $lower;
}
?>

split2Int puts the upper 32 bits into $upper and the lower 32 bits into $lower. Binary operations can now be performed on both the ints. Afterwards, the result in converted to a float using bigInt2float(). I also wrapped up this stuff into a little class. You can download it here.

Drupal as MVC Framework?

Peter Van Garderen talks about Drupal as a MVC framework. His essay is well worth a reading and so are the comments. Peter writes that

I had considered Drupal as an option earlier but I had been swayed by all the buzz in the tech press and blogosphere about the new generation of open source MVC frameworks that are promising to improve the speed and quality of web application development.

Since Drupal has been around a bit longer than the more recent MVC frameworks, it never thought to sell itself to new developers like myself as a MVC framework. It started out as website content management system and has grown over the past five years into a swiss army knife type toolkit for building websites that is host to an active community of contributors.

Swiss army knife: That's to the point, couldn't agree more :-). However, he concludes that Drupal is not a true MVC framework, but that developing is promising.

Microformats: Prefering machines over people

Anybody ever took a look at the Datetime Design Pattern at Microformats.org (via Georg Bauer (German))? It goes like this:

<abbr class="foo" title="YYYY-MM-DDTHH:MM:SS+ZZ:ZZ">Date Time</abbr>

I think this is a misuse of the abbrevation tag - and worse: it's completly ignoring user experience. Most of nowadays browsers display the text of the title attribut when you hover over the abbrevation. Now imaging a user browsing your microformatted page. When he hovers over a date like - say - May 4th 1970, which is my birthday, he'll see a tooltip stating "1970-05-04T18:10:52+01:00". Doh!

Don't trust PHP_SELF

Sean Coates points out why $_SERVER["PHP_SELF"] must be considered unsafe. You should never use it without at least converting it to entities:

<?php
print htmlentities($_SERVER['PHP_SELF']);
?>

This offers me the chance to again repeat one of my mantras: Create a function for everything, at least when reading values from somewhere, even for something simple like retrieving the value of PHP_SELF. The reason is maintenance: If you haven't previously validated the value of PHP_SELF there will be only one place to change, instead of checking all your code.

Did Nokia get mangafied?

Seems the designers of Nokia's PC Suite setup flash introduction are reading to much Japanese comic books. At least they are associating left with forward and right with backwards:

Screenshot