One of the things that seems to baffle many people when they start learning about Object Oriented Programming (OOP) is the jargon – and the arcane concepts that the jargon attempts to describe: classes, instances, inheritance, polymorphism, message-passing and so on. It could have been all so much simpler…
OOP could, for example, have been described as nothing more than data records (or structs) that can be extended. That, in fact, is precisely how Niklaus Wirth – creator of the Pascal, Modula-2 and Oberon – thought of Object Orientation. I happened to be browsing through an old copy of Wirth and Reiser’s book ‘Programming In Oberon’ the other day and I came across this very sane explanation:
“The ultimate innovation [of OOP] was data type extensibility, which, unfortunately remained obscured behind the much less expressive term ‘object orientated.’ Rather unfortunately, this term was accompanied by a whole new nomenclature for many already familiar concepts with the aim of perpetrating a new view or metaphor of programming at large. Thus types became classes, variables instances, procedures methods and procedure activations messages.”
I have to say that I pretty much agree with Wirth. The trouble is that what seemed to make sense in Smalltalk doesn’t make a whole lot of sense in a C-like or Pascal-like language. One other gripe I have about OOP is that many programmers define ‘encapsulation’ as ‘putting data and methods together’ (i.e. inside an object) but they pay no attention to modularity – data and implementation hiding. Modularity is something about which Wirth is obsessional. It’s just a pity that his obsession hasn’t been as influential as OOP!