Thursday, February 25, 2010

Original Sin

Either make the abstraction good and its variations good, or make the abstraction bad and its variations bad; for the abstraction is known by its variations.
 We do not inherit to specialize, we inherit to add variation behind abstraction.  Yet both of the major platforms today - Java and .NET - force every object to specialize a base class.  For Java, you have to inherit java.Object, and for .NET it is System.Object.


...but it really doesn't matter; the damage is done either way.

This is the "original sin" of software development.  Every object must be able to determine if it is equivalent to another.  Every object must be able to bucket itself with equivalent and similar objects.  Every object must be able to convert itself to a string.

Whether you need these features or not, you must, at the very least, inherit them.  The true nature of abstraction is, therefore, tarnished.  You can never have a pure interface for every object is tarnished by the sins of its base class's designers.  Consequently, programmers will, forever, be weighed down by the mental model of objects as "data with behavior" that is so apparent in their platform's design.

I hope that, when he next real platform (ruby and python don't count, guys... I hope you all figure that out, soon), its architects will be more enlightened.  In the mean time, I hope you can bring yourself to flat-out ignore those garbage behaviors that every object inherits.

P.S.: Isn't it interesting that we, the gods of software, are the ones truly responsible for a sin of design committed by a single ancestor and that said sin burdens its every inheritor?