Introduction / Object Orientation 3: Polymorphism
Subtitles of the Movie
Polymorphism, another object orientated concept we'll look at is polymorphism and all that means is the ability to take on many different forms. Now polymorphism can apply to objects and it can also apply to operations. Let's look at some examples to see how. A polymorphic object is one whose true type hides within a super class as an example think of the class, basketball player. Now this class has different subtypes, center, forward and guard and each of those subtypes has its own idiosyncrasies, position, rules, strategies for play. However when we are talking about the operation dribble ball, that operation is the same for each of those subtypes, so when your talking about the dribble ball operation you want to refer exclusively to the generalized class of basketball player. Then when the operation of dribble ball is executed the basketball player object will take on one of several forms. Now the flip side of that is a polymorphic operation in a polymorphic operation the operation may be carried out in different ways, based on the class of the object that's the operation. In other words polymorphism allows you to treat derived class members in the same way as their parents class members. This lets objects of different types respond to the method calls of the same method with each object responding with the appropriate behavior for it's type. So for our example here we have two types of the animal class. We have a dog and we have a fish. And if we are talking about the polymorphic operation breathe at runtime the breathe operation will be performed differently by the fish, breathing water through its gills and producing bubbles then it will by the dog that will breathe air and pant.
Tutorial Information
| Course: | UML |
| Author: | Nancy Conner |
| SKU: | 33815 |
| ISBN: | 1-934743-23-2 |
| Release Date: | 2007-10-26 |
| Duration: | 7 hrs / 95 lessons |
| Captions: | For Online University members only |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 