This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ation or
service. The 'how' part, that is, the implementation details are internal to the
object, the supplier. Thus OOP provides a high degree of abstraction, which gives
an opportunity to the programmers to concentrate more o problem specification
rather than be taken away by the implementation details.
In conventional programming languages, the operators, functions, etc. are bound
to their respective operations at the time of compilation. This is called static
binding. However, in OOP, the binding of operator to an operation takes place at
run time. This is called dynamic binding. To have an understanding of this
concept, let us consider the following situation. A class named 'shape' has been
defined along with a collection of sub-classes for different kinds of shapes, such as
circles, triangles, rectangles, etc. If objects of these sub-classes need to be
displayed, the display method must be defined within the class of the particular
kind of shape, for each kind o shape will require different display code. Suppose
that a linked list of objects of various shapes is constructed and code is written to
display each object on the list. Then the message to 'display shape' is the same for
each object on the list, but it must be dynamically bound to the 'display_shape'
method in the proper object. Naturally the same message 'display_shape' sent to
different objects has got different responses, which is term& polymorphism.
Languages that provide this sort of dynamic binding are called polymorphic
languages. Dynamic binding allows abstract data types to be truly generic because
it enables a single operator to have more than one operation.
In OOP, inheritance provides an effective method of code reuse because the
common operations defined and implemented in a class can be accessed by all the
classes and instances down the whole class hierarchy. That is, as and when new
classes inherit from existing classes, the code developed in super-classes gets
View Full Document
- Spring '14