• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compile time polymorphism  RSS feed

 
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from the discussion with Campbell Ritchiehere.i thought to create a new topic to dicuss about the polymorphism in regard of the overloading.
As per me the polymorphism is the different behaviour of entities sharing a common root.
In java the polymorphism is more specifically a run-time polymorphism where we have a different behaviour of objects.as per my definition here:
the entity is  : the object.
common root: the super class.
cause for this polymorphism is the override of the instance method(part of the super class) in sub class.

now if we see a overloading,in my opinion they are also polymorphic:
the entity is: the method(having the same name)
common root is the class in which this method is contained in
cause for this polymorphism is the type of the argument or different signature.

is there something it is contradicting for holding polymorphism(as per the general definition of polymorphism in computer science).

Kind regards,
Praveen.
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell you what: why don't you have a look at the Wikipedia article Polymorphism (computer science) which talks about that term? Be aware that the article isn't bound to any particular programming language, in particular the terms that it uses might not be the terms used by the designers of the Java language. But you should be able to map the concepts described in that article to concepts which are present in Java, I think.
 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,Actaually i have already gone through that link.my conclusion: these things are actually "terms" war defined in specific languages.like in java we have a name method overloading(for ad hoc polymorphism).so it should not be messed with polymorphism because in java we have only one type(and one definition) of polymorphism which is the subtyping(run-time polymorphism).
however,as per computer science i can call the overloading as polymorphic

Kind regards,
Praveen.
 
Paul Clapham
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, people who write different languages sometimes have different names for the same concepts. Some people think that these name choices should be the subject of exams which can be passed or failed, or the subject of flame wars. Me, I think it helps if we (as Java programmers, say) all use the same name for the same concept, just to reduce confusion. So if the Java designers wanted to call something "method overloading" then it helps if we all call it that. Just like if I moved to Britain it would be helpful if I referred to a wrench as a "spanner", which is what they call it there.
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately ad‑hoc polymorphism is a term which has largely fallen out of use; I had never heard it before.
 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Unfortunately ad‑hoc polymorphism is a term which has largely fallen out of use; I had never heard it before.

That is not an issue.i just want to know if the overloading is really contradicting the general(not specifically from java's point of view) definition of polymorphism.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, overloading is consistent with polymorphism. Even if you don't call it polymorphism.
 
Paul Clapham
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Unfortunately ad‑hoc polymorphism is a term which has largely fallen out of use; I had never heard it before.


I have never heard it before either. If I knew a better term I would edit the Wikipedia article to use that term instead, but I think I would have to have a better Computer Science background (so that I could defend my choice) before I did that.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!