Polymorphism: Object Oriented Programming (OOP)

Object Oriented Programming

Class inheritance is not just about reusing the classes at many locations, it also adds enormous flexibility to the way in which one can program his application.

The object-oriented programming approach focuses on objects as the basis for application building. Objects are instances of classes, which contain a description of related data and procedures. The Visual FoxPro language has been extended to use object-oriented programming (OOP). One of the concepts used in OOP is polymorphism.

In OOP terms, polymorphism represents the ability to resolve a reference to an object’s method at run time. Specifically, different objects could make a call to a Draw or Print method, and these methods would act differently with each object; the process can take different forms behind a common interface. One of the benefits of polymorphism is that because the interface is common to objects, any object is able to respond differently to some common set of tasks, and objects are independent of each other.

In programming terms polymorphism generally means the ability to assume several different forms and or shapes. In programming terms it means the ability of a single variable of a given type to be used to reference objects of different types and to automatically calls the method that is specific to the type of the object the variable reference. This enables a single method call to behave differently, depending on the type of the object to which the call applies.

There are certain requirements to be fulfilled to get the polymorphic behavior.

  1. Polymorphism works with derived classes
  2. To get polymorphic operation when calling the method the method must be a member of base class
  3. You can not call the method of a derived class object from the variable of the base class if the method is not a member of a base class
  4. Method must have the same signature and return type as in the base class and derived class

Polymorphism only applies to the methods not the data members.

Polymorphism

The object-oriented programming approach focuses on objects as the basis for application building. Objects are instances of classes, which contain a description of related data and procedures. The Visual FoxPro language has been extended to use object-oriented programming (OOP). One of the concepts used in OOP is polymorphism.

In OOP terms, polymorphism represents the ability to resolve a reference to an object’s method at run time. Specifically, different objects could make a call to a Draw or Print method, and these methods would act differently with each object; the process can take different forms behind a common interface. One of the benefits of polymorphism is that because the interface is common to objects, any object is able to respond differently to some common set of tasks, and objects are independent of each other.

M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post