This week, we reviewed about the concepts and the differences between the five terms, which were abstraction, interface, inheritance, encapsulation, and polymorphism. However, the term polymorphism confused me a lot during the class. The only thing that I remembered about polymorphism was that a class or an object could exist in many forms, but I could not explain to myself what “forms” mean. So, I did some searching on the term polymorphism in the hope that I could recall what I had learned and also learn more about the characteristics of polymorphism.
Fortunately, I found a good resource, called Polymorphism, Encapsulation, Data Abstraction, and Inheritance in Object Oriented Programming, written by Nick. Through this blog, Nick provides readers with concise definitions of abstraction, encapsulation, inheritance, and polymorphism with typical properties respect to each term. The writer also analyzes the important role of each concept in programming. Furthermore, after defining each term, Nick also has at least one example to describe the definition making the terms easier to understand for code newbies. This is one of the reasons that I chose this blog as my resource. In particular, in the polymorphism section, Nick gives an example of the class “Move” and the classes of animals to explain the phrase “exists in many forms”. The class “Move” does not have a concrete type, so it can be inherited/extended by any type of animal. For example, a Snail will crawl to move, a fish will swim to move, or a Kangaroo will leap to move. Hence, the concept of polymorphism is applied to make the code more flexible and extensible. This is a good blog to read and very useful if you want to understand clearly about the concepts of polymorphism, encapsulation, abstraction, and inheritance. I might forget these concepts if I don’t use them for a while. However, this blog gives me a key to remember those concepts in the long run by keeping in mind the real life examples provided by the blog.
Another thing is that after reading the blog, I know that there are several different types of polymorphism, but the writer does not analyze those types in depth in the blog. Therefore, I searched other sources to learn more about polymorphism. Different resources give me different numbers of polymorphism types. However, there is an article, called Polymorphism in Java, that gives me the necessary information about the types of polymorphism. There are many types of polymorphism, but in Java language, there are only two, which are compile-time polymorphism (overloading) and runtime polymorphism (overriding). Throughout the article, each type is described and analyzed using code examples. For myself, this is a good resource because although the article is short but concise, it contains all the information I need to know. Moreover, before reading the article, I had a chance to learn about the concepts of overloading and overriding, but I did not know how those two methods relate to the concept of polymorphism. So, the article not only helped me review my old knowledge, but also helped me to come up with the idea that I would organize all the concepts that I have learned into a diagram, where the diagram will show how concepts relate to each other. I believe the diagram will be one of my best tools that I can use to remember and distinguish all the important concepts in programming.
From the blog CS@Worcester – T's CSblog by tyahhhh and used with permission of the author. All other rights reserved by the author.