Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming

> ## Polymorphism

> Polymorphism is tightly coupled to inheritance and is one of the most powerful advantages of object-oriented programming. When a message is sent to an object of a class, the class must have a method defined to respond to that message. In an inheritance hierarchy, all subclasses inherit the same methods from a common super class. However, because each subclass is a separate entity, each might require a separate response to the same message. Polymorphism allows the message sent to the super class to be dispatched to an overridden method in a given subclass at run time. In other words, polymorphism allows the objects in a class hierarchy to respond to the same message in different ways—hence poly- (many) morphism (forms).

> For example, you might have a system with many different shapes, where `Shape` is a super class. However, a circle, a square, and a star are each drawn differently. By using polymorphism, you can define a `Draw( )` method in the `Shape` super class, then send the super class a message to invoke this `Draw( )` method, and each subclass of `Shape` (`Circle`, `Square`, or `Star`) is responsible for drawing itself using its own implementation of the `Draw( )` method.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095