Blog enhanced with WPTouch

Since I am one of the guys playing around with an iPhone now I thought it might be a good idea to make my blog a little bit more readable on the iPhone and other PDAs. After a small research I decided to install the WPTouch plugin and have to state: great work, thanks!

Posted in Misc | Tagged | Leave a comment

Buying an iPhone in China

Lately it was the time that I had to replace my old PDA with something new because I dropped it one time too much on the floor. Because we had business in Shanghai and found a shop with “original” iPhones we decided to switch to iPhones.

The first question when you buy something like an iPhone in China is: How can you be sure it really is an Apple iPhone and not a chinese clone? First I would suggest to search for some detailled pictures of original iPhones, they are very slim and have a characteristic position and border of the embedded camera. But I think the easiest way to identify an iPhone is the software on the phone. If you make a photo with the phone and scale it with the multi-touch ability of the iPhone the image scales and corrects the image resolution at the same time so that you can hardly see pixels while zooming.

So we went into this shop and in total bought 3 iPhones. The iPhones were neatly packed, seemingly in original, brand new boxes and my test showed that they were real Apple iPhones.

Before I bought the iPhones I didn’t now anything about jailbreaking and unlocking. I just tried my chinese and my german SIM card in the phone and both worked.

Back in the hotel the problems started. I reconfigured my phone and it didn’t work with any SIM card any more. So we went back to the shop and they made it run within 5 min and gave it back to me. While leaving they told me better not to update the software on the phone myself which finally made me really curious and back in the hotel I started an internet research to find out if the iPhones where original ones.

Especially the Apple Service and Repair webpage was very helpful. One of the iPhones was a replacement part without any guarantee, the other two were already several month old. Conclusion we bought refurbished iPhones sold as new ones. When the battery life of the replacement part showed that the battery was already quite old we decided to go back to the shop another time and ask the sellers directly about the fact that they hid that they sold refurbished iPhones.

The result was not really satisfactory. They changed the replacement iPhone with the damaged battery to another one but that was all.

Because one of us was really pissed off, she called the police later to ask them what to do. The police forwarded us to a special unit which deals with these matters and they told us that only China Unicom is allowed to sell iPhones in China and therefore they will do nothing about our case.

After we got this information I finally understood what happend to my iPhone which suddenly didn’t work any more and had a closer look on the installed software. The iPhones were original China Unicom phones which have been jailbreaked and unlocked!

As final resultI can only warn you to be aware that most phones, even in official China Mobile Reseller Shops like the one where we bought our phones, are fakes or refurbished. This puts the price we payed into a complete new perspective!

Posted in Around the World, China | Tagged , | Leave a comment

The Nonsense of Software Patents

I am Software Developer and my opinion is that Software Patents are not only Nonsense but also counterproductive!

There are not infinitely many ways to program something. Computer Science Theory already shows that for many problems there are only few methods to solve the problem with programming in a reasonable way if they are solvable at all. And then there are best practices in programming which simply evolved from many programmers coding a huge amount of code and trying to make everything more manageable.

On the other hand there are the software companies who try to claim every idea as theirs to gain control over their competitors or even a part of the software development universe. This turns programming more and more into a run through a minefield and I am already sure that one day when I finally think that I get a big success with one of my programs there comes one of these big patent hoarders and wants its part of my cake because I violated some sort of broad spread patent.

As I can read on Heise Online today this time someone tries to get his piece of cake from our dear competitor Microsoft. It seems that the Canadian company i4i holds a US Patent No. 5,787,449 which describes the separate manipulation of architecture information and data of a document within the same file.

Not that I am not a little bit mischievous that it hit Microsoft, one of the biggest supporters of software patents and rigorous enforcer of his own “rights”, but I have to state that I am a little bit astonished that such a patent is possible after all! I mean, the patent was filed in 1994 but at this time we had already the Java Programming language since 1992. And together with this language came the famous JAR-file which is an zip-archive enhanced with a metadata file. This metadata file describes the “architecture” of the jar-archive and can be manipulated independently from the class files which normally constitute the data. It becomes even more obvious that this method is common sense when you examine the usage of ear- or war-archives because with the appearance of J2EE the usage of XML-Files within the archive for configuration and architecture description of the data within the archive went a huge step further.

Since 2006 the Open Document Standard is specified, which actually does what every smart programmer would do without any guidance. It packs together the formatting information and the data of a document into one archive, the exact same path which was already prepared by the jar-archives.

So, especially in direction of Microsoft, I would like to ask: Does anybody else have the same impression as I that software patents are really counterproductive an therefore should be forbidden?

I for myself have never in this business seen a striking innovation where I would have agreed that this should be protected by a patent. But I am only about 20 years in this business. Perhaps this point is still to come.

Posted in All, Patents | Tagged , , | Leave a comment

Back after a Break

I didn’t write anything for quite a while. But now I am back 🙂

My break had two reasons. The really good one is that I became father of a little daughter named Thalea in the mid of July. Naturally I hope for the next talent in computer science but who knows. If she is only a little bit like her mother she will absolutely have her own head and push her own ideas!

If you hope that I will publish family pictures regularly now I have to disappoint you. Family business stays private. The next public pictures of Thalea you can see perhaps in her own blog one day. 😉

The second reason for not publishing articles was the deceasing of my beloved IBM Thinkpad Tablet. I think the heat and moisture of Hainan have been too much for it and when the fan finally gave up …

As a more suitable solution for the Hainan weather conditions I bought a desktop computer with many fans 😉 and installed Linux in form of the Fedora 11 distro on it. Perhaps installed is said too much. After over a week of installation I am still struggling to get all components supported and fully up and running. Hope that one day I manage to have installed this cool machine as it should be, including accelerated graphics and dolby surround sound.

Nevertheless I will try to revive the laptop. The tablet functionality is simply cool to manipulate images.

Posted in Misc | Tagged | 1 Comment

Ruby Objects, Class-Objects and MetaClass-Objects

After a while of evaluation I started over programming mainly in Ruby about two month ago.

Long time ago I learned for a short while object orientation programming in Smalltalk-80 but soon started to use C++, first with the AT&T preprocessor and later with the gcc. Since 1998 I am programming Java. All these years have left me with a certain idea of practical object orientation which was not really what I learned from Smalltalk-80.

But Ruby changed things a lot as I have to admit. In Ruby everything is an object and Ruby is interpreted like Smalltalk! What are the consequences. This is what my post will try to figure out.

From Ruby Core – Class documentation:

Classes in Ruby are first-class objects—each is an instance of class Class.

A big help for understanding Ruby Objects has been the Pickaxe Book.

In Ruby everything is an object. This includes as well Integers as Classes. So what happens if you write something like:

  a = "test1"
  b = "test2"

You get references a and b to your Objects a and b of class String which is an object too and has the class object Object as superclass. So far the only difference is that the Classes are realized as objects themselves.

But you can do things in Ruby which you cannot do in C++ or Java. For example you can add a method only to one object like:

  c = 'test'
  class < < c
    def double
      self + self
    end
  end
 
  c.double
  =>"testtest"

This piece of code generates a virtual class exclusively for the object c.

What happens if you try the same for integers? If you try the same for integers it should look like object b in this graph:

The code for this would be:

  b = 7
  class < < b
    def double
      self + self
    end
  end
 
  TypeError: no virtual class for Fixnum

So what is this? I thought that all objects can have virtual (or singleton) classes which hold the methods specially attached to this object?

The solution is quite simple. There are special classes like Fixnum which are called eigenclasses. Instead of a reference to an object these classes return the class object itself (for example as parameter for a method call). Eigenclass objects only have one single Object for example for each Fixnum value. This is why it is not possible to create singleton classes for eigenclass objects.

But what you can do is to extend an eigenclass with your own attributes like:

  class Fixnum
    attr_accessor :name
  end
 
  b = 5
  b.class
  => Fixnum
  b.name 'five'
  => "five"

The next thing I want to do is to define a class variable. I found a nice article about class variables in Ruby on John Nunemakers blog. At first I was really astonished about this:

  class Polygon
    @@sides = 10
    def self.sides
      @@sides
    end
  end
 
  puts Polygon.sides # => 10

This is a Polygon class with a class variable which holds the number of sides of the Polygon and a getter class method. Now we create a subclass which inherits from Polygon and holds its own number of sides:

  class Triangle < Polygon
    @@sides = 3
  end
 
  puts Triangle.sides # => 3
  puts Polygon.sides # => 3

What happens here? The Polygon sides have been set to 10 originally.

To understand this behavior you must have an understanding about the Ruby Meta-class and look-up mechanism for methods and variables. When you create a class variable or method Ruby actually creates the following Meta-Class for you:

The Meta-Class hold the Class level extensions of your class. If you subclass Polygon now you have the following image:

In Ruby everything, including class definitions, are executable code. The assignment to the class variable @@sides in the class Triangle leads the Ruby interpreter to search for an existing class variable @@sides which he finds in the Meta-Class of the superclass Polygon first and makes an assignment to this variable instead of creating a new meta-Class with the same variable for Triangle.

So what can we do if we want to have a variable for the sides of our class which is unique to the according class? As the class itself is an object you can assign a variable to the class object

You can do this with the following code:

  class Polygon
    @sides
    class < < self
      attr_accessor :sides
    end
  end

for the Class Polygon and the same for class Triangle. Be aware that you have to assign the accessors to the class object and not to the object itself.

I hope that my explanations are correct and can help other newbies in Ruby to understand the Class handling a little bit.

Posted in All, Ruby | Tagged , | Leave a comment