Object-Oriented Programming

Procedual-oriented programming focuses on subprograms and subprogram libraries, data are sent to subprograms for computation. Data-oriented programming focuses on abstract data types, computation on a data object is specified by calling subprograms associated with the data object. Languages that support data- oriented programming are often called object-oriented languages.

A computing in a pure OO language is done by the same technique: sending a message to an object to invoke one of its methods. An executing program in an OO language can be described as a simulation of a collection of objects that communicate with each other through messages.

There are three key language features of OO languages: abstract data types, inheritance and a particular kind of dynamic binding.

Abstract Data Types(ADT):

The abstract data type, which is often called class, is an encapsulation that includes only the data representation of one specific data type and the subprograms that provides the operations for that type, the details of the type can be hidden from units outside the class. An instance of a class is called an object. There are two kinds of methods and variables in a class:

Inheritance:

Once you have a basic class, you can derive a new class from that basic class, the basic class is called super class, and the derived class is called subclass, The subclass can inherit the data and functionality of the superclass.

In addition to inheriting entities from its parent class, a derived class can add new entities and modify inherited methods. A modified method has the same name, and often the same protocol, as the one of which it is a modification. The new method is said to override the inherited version, which is then called an overriden method.

There are two kinds of inheritance:

One disadvantage of inheritance is that it creates a dependency among the classes in an inheritance hierarchy. This works against one of the advantage of ADT, which is that they are independent of each other.

Polymorphism and dynamic binding

The third characteristic of OO programming languages is a kind of polymorphism provided by the dynamic binding of messages to method definitions. This is supported by allowing one to define polymorphic variables of the type of the parent class that are also able to reference objects of any of the subclasses of that class. The parent class can define a method that is overriden by its subclasses. When such a method is called through the polymorphic variable, that call is bound to the method in the proper class dynamically. One purpose of this dynamic binding is to allow software systems to be more easily extended during both development and maintenance.

Advantages: