So you've got an idea for a truely
wicked class library. It
encapsulates everything from an earthworm to the kitchen sink with generic
behaviors defined at all levels. But Lord, the code sure does get
repetitive after a while... How many
stream insertor / extractors are you going to have to write? If you change your
base class, how many of them are you going to have to rewrite? Soon, you're bogged down with no end of work in sight and
you're considering giving up.
What would Linus do?
Well, I don't know about Linus but I do have the answer: Open C++. Imagine being able to write
C++ code that knows itself
inside and out. You could have a class rewrite itself, inserting code into the stream
operators to handle each member variable. If you make a change to a class in such a program, it will update itself at
compile time.
Best of all, there's a
deb package for it.
I tried it and it changed my life.
Not being a
Java junkie, I had no idea that they've been doing this for a long time. They call it
introspection and
reflection. That's OK though, I still
refuse to learn Java.