Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you define polymorphism to a CS 101 student? [duplicate]

Possible Duplicate:
Try to describe polymorphism as easy as you can

How would you define polymorphism to a CS 101 student? Be as concise as possible (maybe an answer of a couple of lines and not too technical). Thanks

like image 672
nabster Avatar asked Jan 01 '26 00:01

nabster


2 Answers

Something that has the ability to change itself much like actors in films they can be either the good guy or the bad guy or even both or none. As non technical as I could get.

To extend my first example: the movie company doesnt need an actor to do a specific role as long as its a role.

In A somewhat more technical manner you tell three people to do a job but don't leave any instructions. Those three people will solve the job three different ways(if the job is unique lol) basically you dont care how it gets done as long as it gets done thats what polymorphism is.

like image 162
Aquertu Avatar answered Jan 05 '26 04:01

Aquertu


I will dump down some one-liners from the top of my head. I think that various answers are necessarily due since polymorphism serves different purposes, depending on the consumer of the service. From formal to informal:

  1. Allow a multiplicity of automata to provide different semantics based on a common syntax.
  2. Allow a multiplicity of agents to provide specific behavior respecting a contract.
  3. You give a task to some students in a class, each one completes it correctly in its own personal way.
  4. You don't care who gets the job done or exactly how, as long as it satisfies some general criteria.
like image 42
Luca Geretti Avatar answered Jan 05 '26 04:01

Luca Geretti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!