Polymorphism
While programming in C, we get close to the system.
In this course, we'll use C to examine how building-blocks are built and gain a deeper understanding of polymorphism. Let's explore its internals.
In this course, we'll use C to examine how building-blocks are built and gain a deeper understanding of polymorphism. Let's explore its internals.
Polymorphism
It means 'occurring in different forms'. It is an indispensable aspect of modern software production. For example, doctors want different forms of imaging for different parts of the body; developers want different forms of environments for testing and production - Code often needs to run in different contexts. And these contexts keep growing over time.
There are many ways to realize these 'different forms'. Let's look at a trivial way, which doesn't use polymorphism.
Suppose we had a row of different heavy artillery machines. They look alike, but are made by different companies. Each company has provided its own function to fire the projectile. For example, the Howitzer equipment has a function called 'howitzer_v1_fire', while Dhanush provides a function called 'dhanush_fire' and so on. These functions accept an equipment-identifier to distinguish the one to be fired.
Our job is to program them to fire in quick succession.
There are many ways to realize these 'different forms'. Let's look at a trivial way, which doesn't use polymorphism.
Suppose we had a row of different heavy artillery machines. They look alike, but are made by different companies. Each company has provided its own function to fire the projectile. For example, the Howitzer equipment has a function called 'howitzer_v1_fire', while Dhanush provides a function called 'dhanush_fire' and so on. These functions accept an equipment-identifier to distinguish the one to be fired.
Our job is to program them to fire in quick succession.
U.S. Army photo by Pfc. Dasol Choi, 1st Armored Brigade Combat Team Public Affairs, 1st Cav. Div.
To do this, I wrote the following function:
void synchronized_fire() {
howitzer_v1_fire(GUN_ID1);
dhanush_fire(GUN_ID2);
bofors_v2_fire(GUN_ID3);
howitzer_v2_fire(GUN_ID4);
dhanush_fire(GUN_ID5);
}
What's wrong in writing the function this way?
Feel free to comment below. The topic is continued here
Is there really a problem? The function works, right?
ReplyDeleteYes, but think about deployment. Every new sequence of guns will require a new program. So if there are deployments along the border and each has a different set of guns, each of them will require a different version of this program. Very soon, the number of versions will become huge.
DeleteAdding a gun from a new manufacturer will require a re-release of all these versions, increasing the effort and cost involved in maintenance.
"Let's look at a trivial way, which doesn't use polymorphism" - what do you mean by these lines? Can you explain these lines?
DeleteGood blog,Great experience for me by reading this article.
ReplyDeletecore java training in chennai
C++ programming course
c++ course fees
C and C++ institute
c c++ course
javascript course in chennai
Appium Training in Chennai
JMeter Training in Chennai
Superb ! Your blog is incredible. I am impressed with it. Thanks for sharing this content under this topic.
ReplyDeleteSeo Training in Bangalore
Best Seo Training in Bangalore
Data Analytics Courses in Bangalore
Data Science Courses in Bangalore
Digital Marketing Courses in Bangalore
German Classes in Bangalore
Python Training in Bangalore
Selenium Training in Bangalore
Wonderful article, Which you have shared here about the Polymorphism. Your article is very informative and I liked your way to share your knowledge in this post. If anyone interested to join the Best C++ With Data Structures Course In Delhi, codingbytes is good for you.
ReplyDeleteThis is what we want. You have pointed out some great info here. Register for best selenium course online now
ReplyDeleteAnvsoft Syncios 8.7.4 Crack can be an IOS manager, report moving, conversation, the file coping with, iPhone, iPod, i-pad, PC, Touch.Syncios crack
ReplyDeleteAVS Video Converter 12.4.2 Crack is a free program that efficient, easy-to-use tool that converts videos between the most popular formats .Avs Video Compressor
ReplyDelete