A couple of days ago I talked about
polymorphism.
I can't even begin to tell you what all discussions I've had since
putting this up. Let me start by saying this: this post, as
all my posts on OOP principles, are not intended to cover the complete
aspect of the principle, and this applies most heavily to
polymorphism. Polymorphism can be a very complex concept and
difficult to understand in certain situations.
1)
"Polymorphism is coupled with inheritance." I made
this statement in my post. Looking back, I probably shouldn't have
because the statement is not true. More correctly, polymorphism
can be coupled with inheritance, but inheritance is not requierd to gain polymorphic behavior.
2) Please read
this post by Daniel Moth.
He counters on my statement discussed in #1 above, and he is
correct. This is a very good post, even if I did peeve him off
little :) Daniel's a very smart guy and I'm proud and
appreciative to have his input on my postings.
3) Now that you've read Daniel's post... and I've also had this
discussion via email with someone else who is very OOP knowledgable
like Daniel is, and that is method overloading. In my opinion,
and in the opinion of others, overloading
is a form of polymorphism,
also referred to as compile-time polymorphism and parametric
polymorphism. I'll leave it to you to form your own opinion.
4) My polymorphism post was incomplete, and I apologize for that.
The post was meant to only give a very basic understanding of
polymorphism in the .Net world to those who have never dealt with the
aspect of it before. Looking back, I should have discussed more
about it and in greater depth. To be honest, I left out other
aspects of polymorphism (interface is the biggie) as not to unload
too much at once and confuse anybody new to the idea.
Again, the post was not intended to give you the entire picture of
polymorphism. There are entire chapters of books dedicated to the
subject, and I certainly wasn't going to attempt to do that in one blog
post. I merely intended to give a broad picture in how it applies
most commonly to managed code (.Net). Please do your own
research, google the topics you read and form your own opinions.
This is true for all of my blog posts.