Justin a.k.a. The Code Monkey

posts - 10 , comments - 27 , trackbacks - 0





The results to this question are always fascinating.











Print | posted on Friday, January 23, 2009 12:05 AM | Filed Under [ Computer Science Coding as an art ]



# re: Can you tell me the meaning of the word "Polymorphism"?

Yeah, I think that if you have a four year degree in Computer Science obtained in the last several decades, you should know what polymorphism is, plain and simple. Not just the idea, but the term as well. It is not a buzzward - "Ruby on Rails" is a buzzword. I can't imagine a CS curriculum that didn't highly emphasize this central concept of OO programming. If you don't understand it, you are going to run into problems down the line; same with things like vtables, struct alignment, and garbage collection.
1/25/2009 10:33 AM | Luke Sandell


um.. well.. there just one thing... er ...um... Your definition of "Polymorphism" is ...well.. wrong....

OK, not so much wrong as merely describing how Polymorphism is implemented in a C++-esque system. But the guiding principle of C++ (and OO and, for the most part, programming) is "Implementation is irrelevant"

A proper (if a bit high level) definition of Polymorphism would be:

"Polymorphism is the ability of different object to behave differently to the same message."

non-"virtual" method are just a C++ optimization. In a true OO system, all methods are "virtual". And in a true OO system, all objects have a common ancestor (namely "Object"). In strict OO, File.Open() and Window.Open() is an example of polymorphism, which would be a bit of a strain seeing in your description.
1/26/2009 9:27 AM | James Curran


I agree with James Curran's comment...

In fact your definition seemed to be to much influenced by a specifical implementation...
1/31/2009 10:44 AM | opensas


@Luke Sandell

Ruby on Rails is not a buzzword. Ruby is the language, Rails is the framework. Ruby on Rails is the buzzwords.

Oh wait... ;-)
1/31/2009 12:48 PM | Fadzlan


First rule of interviewing: know the answers to the questions you are asking. </troll>

@James Curran, @opensas: I agree with your definition and see it like this:

C++ supports both "static" and "dynamic" polymorphism. Static polymorphism is inherent to OO and doesn't even require inheritance to work. That is, two classes can implement a member function (method) having the same signature. This may not seem like much, but Employee.save(), Customer.save() is a big improvement over employeeSave(), saveCustomer(), IMO. To be fair, this can be achieved even in C somewhat via struct scope and function pointer members.

"Dynamic" polymorphism (vtbl) is even more useful, of course, as it enables "late binding." You might say it's what inheritance was invented for. The OP seems to understand this, but neglects to mention the significant design features that DP affords, like interfaces and ABCs; frameworks and the "hollywood principle"; design patterns and IoC, ... (just a buzzword, meh)

I agree also with the other comments w.r.t. implementation. "virtual" is assumed in many OO langauges. Some others permit late binding via alternate constructs: C# and Delphi have delegates/events/method pointers. Still others support closures. Last but not least, dynamic languages give us "duck-typing."

And finally, why all the hatin' on COBOL? Lots of people still use it, and it continues to evolve. When M$ introduced .NET at a PDC many years ago, it profiled two non-M$ langauge implementations: Eiffel and Fujitsu COBOL. The ASP.NET page written in COBOL was awesome, offering a bridge back to all that legacy code -- what better trick can your language do?

I should get my own blog ;)
2/1/2009 10:12 AM | stevej


Hey guys, thanks for the comments. Just a couple of replies:

@James Curran:

I do believe you're right. Thank you for the clarification.

@ the rest

TROLLS! j/k. It wasn't right, but it wasn't wrong either :D Honestly, knowing gets in the way of learning. I learned something here.

@ stevej

I don't hate COBOL, i just like picking on it. My COBOL teacher in college liked to beat the fact into us that programming was a clerical job. All you would do in the real world is translate somebody else's specs into code and there's no creativity involved. Having worked in the industry for a while, I can definitively say that's not true. I don't think I've seen comprehensive specs once. Hence, I pick on COBOL. I don't hate it, but I wouldn't voluntarily work in it either.

I'm also still convinced that "Object Oriented COBOL is an Oxymoron". Just an opinion :D

And yes, you should get your own blog. You're a good writer.
5/17/2009 3:18 PM | Justin
Post A Comment

Powered by: