Timeline for Why are inheritance and polymorphism so widely used?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 11, 2014 at 21:36 | comment | added | user22815 | Animals and shapes are really bad applications of polymorphism for several reasons which have been discussed ad nauseum on this site. Basically, saying a cat "is an" animal is meaningless, since there is no concrete "animal." What you really mean to model is behavior, not identity. Defining an interface "CanSpeak" that could be implemented as a meow or a bark makes sense. Defining an interface "HasArea" that a square and circle can implement makes sense, but not a generic Shape. | |
| Aug 11, 2014 at 20:52 | comment | added | Cristian Garcia | @gnat While the "substance" is already out there, a person new to the subject might find an example easier to grasp. | |
| Aug 11, 2014 at 20:37 | comment | added | gnat | this doesn't seem to add anything substantial over prior 10 answers | |
| Aug 11, 2014 at 20:08 | comment | added | Cristian Garcia | @Telastyn I learned the example from Derek Banas on Youtube. Great teacher. In my opinion it is very easy to visualize and reason about. You are free to edit the post with a better example. | |
| Aug 11, 2014 at 20:04 | review | First posts | |||
| Aug 12, 2014 at 6:54 | |||||
| Aug 11, 2014 at 20:01 | comment | added | Telastyn | I swear, Animal is the anti-tutorial of OOP. | |
| Aug 11, 2014 at 20:00 | history | answered | Cristian Garcia | CC BY-SA 3.0 |