Montag, 4. Juli 2005

The next shot

Today is a nice day. I finished the first version of a tiny piece of software which is to become one of the more important building blocks in my upcoming work.

For a long time I carried the idea of expanding C++ objects whenever I want to with me. And since it's my character to stick to a goal until I am at least a bit satisfied I am now able to say that the expansion framework has become reality. It is to become one very important characteristic in the object system I am currently fixing my thoughts on.

To explain the idea very briefly. I want to take a C++ object, put it into a blackbox that has a "Expand-Object-with-X"-button. And when I pressed that button I want another object to come out on the other side that contains the original one and the expanded part.

Now one might ask what this is necessary for. Well, having such a mechanism allows me to combine arbitrary data in one object. I can use different "stages" of an expansion to select behaviors just by overloading. More precise: If I decide to take an int. And I decide to expand it with a float. And the result is then an IntFloat. Then I can write a function which takes an IntFloat as parameter and furthermore I can overload this function with lots of other "stages", for instance IntFloatBool and so on. This is a very big advantage since I am using the type system of C++ as a state value. In addition the object that is finally created might "know" how to do  certain tasks, e.g. encode itself into another representation. Since the outcome of the expansion is a structured type, i.e. a class hierarchy I can address certain "subobjects" and do whatever I like with it.

Another thing I can do with the object expansion framework is that I can combine behaviors together, e.g. I can create an object that contains the methods of two distinct classes that do know nothing about each other.

If this isn't a reason for today to be a good day.....