Object Oriented Programming, or just OOP or OO, is a programming language paradigm that builds upon structured programming in procedural programming languages with the insight that procedures and the data on which they operate can be considered to be two parts of the same thing: an object.

This insight allows better encapsulation. By the year 2000, Object-oriented programming has largely supplanted procedural programming as the dominant programming paradigm, as it is widely recognised as a good thing. Object-orientation evolved as a way to better structure large programs. It has largely succeeded in this, but software is always a victim of its own success: the better the tools we have, the larger the tasks that we attempt.

An object-oriented programming language generally has three distinguishing features that other languages lack:

  • encapsulation: code and data together in one object type. Part of that object is public, part is not. Code that uses that object can only know about the public part. The private part can change without the client code knowing or caring.
  • Inheritance: The ability to extend the type system by defining new object types that subclass existing ones in an is-a relationship, and thus defining common interfaces and sharing code in a base class.
  • polymorphism: The ability to perform the same operation on different types of objects, each one implementing that operation in a way appropriate to them.

Languages that lack all of these three features are not generally considered to be Object-Oriented. For instance, the first three or four versions of Microsoft's Visual basic allowed you to manipulate the system-supplied objects in a Polymorphic manner using the Object.procedure notation, but not to inherit from these objects. Such systems are said to be Object based.

Of the three, inheritance schemes differ the most from language to language. Some languages specify that each class type must have one and only one parent class type, except course for the built-in ancestor of all classes. Delphi's Object Pascal fits this pattern - all classes are descended directly or indirectly from TObject.

C++, true to it's C roots, takes the most flexible possible approach: There is no single root of the class hierarchy, and a class can inherit interface and implementation from many ancestors. Each class has zero or more parents, and there is more than one way to inherit.

Java tries to be more structured: a java class must inherit implementation from only one ancestor, but can inherit any number of interfaces. Other designs, such as delegation have also been tried, but have not become mainstream.

For a programmer well versed in procedural methods to understand OO may take a few days, but for them to master the art of writing OO programs will likely take a few years. Yes, it took me that long. It will take you a long time too. The Design patterns book and tools like the Law of Demeter may help speed you.

Once you know one OO language, the most time-intensive part of learning another is not understanding the syntax and learning how to read the code; it is gaining a knowledge of how to use the class library that that language has.

Though it is technically right that OO code can be written in almost any language as they are all really just assembler, programming languages do differ a lot in the extent to which the language encourages or discourages OO. A language such as smalltalk or java for instance makes it very hard to write code that is not at least superficially object-oriented, and thus is said to be a highly OO language.

A language such as 1980's era BASIC, where if ... goto is the main flow-of-control construct would make it far more pain than it is worth to write OO code, and thus cannot be considered as an OO language.

Plain C, to give a better example near this end of the spectrum, has a tool chest of primitive operations for building whatever you like, OO being just one option that can be accomplished with much manual labour, and thus is generally viewed as being not object-oriented at all, in spite of the fact that C++ can be translated into C.

As C++ is a superset of C, it makes an OO style easier to do than in C, but also allows you to code in other ways, mix programming metaphors, or just skip the OO entirely.

Hence Kay's objection: I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. Since that write-up has been nuked, I shall explain. Alan C. Kay was the brains behind smalltalk, an pioneering strongly Object-Oriented language.


quamaretto adds: I think you are taking the Kay quote a bit out of context - I would say that the quote is mostly about the lack of garbage collection, metaclassing, the pointer fandango, Furthermore, since Smalltalk was largely inspired by Lisp, it is unlikely that Alan Kay is fanatical about OO features.

Object orientation is a Good Thing (tm) because it enforces information hiding. You only should care about the interface an object presents to your client code, not the internal object implementation. Hiding the guts through encapsulation and access control has the added benefit of not letting you shoot yourself in the foot. Even if you'd like to, you can't reach in and wreak havoc.

At least in languages like Java. Sure, you can ultimately write any code in assembly, but the benefit of catching oft-recurring errors at compile time is gone.

Log in or register to write something here or to contact authors.