mark: Photo of Mark's face, taken in standard office fluorescent. (me)Mark Smith ([staff profile] mark) wrote in [site community profile] dw_dev_training,
It means many things, but commonly, polymorphism is just a fancy way of saying that an object satisfies several classes. This is most useful in the situation where you have, say,

class MyBase;
implements Foo, Bar;

class MyRealClass inherits from MyBase;
implements Foo;

class MyOtherClass inherits from MyBase;
implements Bar;

Elsewhere, you can say that something takes a MyBase and in reality, someone can pass it a MyRealClass. For the purpose of that function, you treat MyRealClass as MyBase... it is polymorphic. I.e., has several forms. But when you call Foo on it, it's actually calling MyRealClass::Foo, not MyBase::Foo. Even though the function in question doesn't know what a MyRealClass is.

(This is an example of late/dynamic binding, an implementation of polymorphism, -- read more at http://en.wikipedia.org/wiki/Dynamic_binding_(computer_science) if you're curious. But in reality, it can mean other things, too. The word itself is polymorphic! Augh!)



(Read 8 comments)

Post a comment in response:

From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.