The big fault in OO

NOTE HXA7241 2010-10-26T20:52Z

Harrison Ainsworth

OO's central abstraction – the class – is too weakly, loosely defined

A class hardly defines anything, it hardly restricts anything. It can have any number of methods, any number of fields, they can have various relations with external things, they can have various relations with each other. A class can be anything, with anything, with any amount of complexity, and any kind of complexity.

Such a very wide abstraction is bad. The growth of OO seems to have been accompanied by a similar growth in guidelines, idioms, patterns, opinions, experience, etc. on what is a good class or OO code. But none of this is definite knowledge. It takes knowledge away from the code, and obscures it in human judgement – which is the exact opposite of what is needed. Software is supposed to externalise and capture – to represent – knowledge in something manipulable.

An abstraction fixes something and lets something else vary. But it is the fixed part that matters most, not the flexibility or detail of the varying part. It is the way the fixed parts of abstractions fit together that makes them interesting and useful. Because the fixed parts are what the logical structure of knowledge can get a grip on.

Classes have too much varying and not enough fixed. They do have some meaning, some structure, but it is overbalanced by too much freedom.

(Probably the best thing about classes is the simple, strong concept of the constructor.)