Object Orientation – Required Features for Object Orientation

data structureslanguage-designobject-orientedobject-oriented-design

I am just wondering, what exactly are the features a language or a library must provide in order for it to be defined as 'Object Oriented'. Is Object Orientation something that can, more or less, be achieved in any general-purpose programming language with decent features? Or is it something that can only be achieved in languages that specifically advertise that they support Object Oriented Programming?

For example, look at the following C code:

SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_HWSURFACE);
SDL_FreeSurface( screen );

or the code discussed here.

Now the above code does not use inheritance , runtime-polymorphism ( ? ) , virtual functions etc. But it seems pretty much OOP to me.

Is Object-Orientation simply writing code which is based on creatable and destructable data structures such as objects, classes, structs etc. which does not require on any special pattern or features provided by the Programming Language or a library ?

Best Answer

According to Alan Kay, who invented the term "object oriented",

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.

Messaging (as implemented in Smalltalk) is a comparable concept to polymorphism, but rather more powerful (at least than the kind of polymorphism supported by C++ or Java). It can be done in all languages, but is rather painful if not supported directly by the language. Basically it means objects can send each other messages containing anything, amd can react however they want to messages they receive. To fully support messaging, there must be a way for objects to react flexibly to messages without enumerating them in the source code (which is basically what method/function definitions do).

local retention and protection and hiding of state-process - AKA encapsulation - can be done by convention in all languages, but that's cheating somewhat. Local retention on the language level actually seems to be the one feature all languages that claim to be OO (and many that don't) share - there's generally a way to create compound datatypes with multiple instances. The protection and hiding, on the other hand, is often only done by convention.

late-binding of all things - a sliding scale on which C is really far away from Kay's vision (As is C++, while Java is much closer). Can be faked (see COM), but that will be a pain to use.

Note how Kay does not mention inheritance. In the same email he wrote

I didn't like the way Simula I or Simula 67 did inheritance (though I thought Nygaard and Dahl were just tremendous thinkers and designers). So I decided to leave out inheritance as a built-in feature until I understood it better

Related Topic