Internal Polymorphism

Internal polymorphism is the kind of polymorphism that you see in most OO computer languages. When you call a method on an object the actual function called is based on the dynamic type of the object. In CeePlusPlus this is implemented using a virtual function table or vtable. Only methods declared as "virtual" are polymorphic in C++. One key attribute of InternalPolymorphism is that the function bindings are part of the class definition of the object -- about as tight a coupling as you can get. Contrast this with ExternalPolymorphism where the functions and their bindings are defined independently of the class.

Usually InternalPolymorphism is preferable to ExternalPolymorphism because it bundles type-specific information into one cohesive unit. However, there are times where the cohesion of domain specific information is more valuable than type-specific information. This is especially true when the objects in question will be playing a passive role in the methods in question. In these cases it is desirable to bundle the variances in type behavior into domain specific units using ExternalPolymorphism. -- PhilGoodwin
Also see OnUnderstandingTypes.


CategoryPolymorphism CategoryCpp CategoryObjectOrientation

EditText of this page (last edited January 22, 2007) or FindPage with title or text search