Ease of maintenance the modular design and code

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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. Dynamic Binding 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. Code Reusability 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 reused. Thi...
View Full Document

Ask a homework question - tutors are online