We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.

What is Polymorphism?

By Troy Holmes
Updated May 16, 2024
Our promise to you
EasyTechJunkie is dedicated to creating trustworthy, high-quality content that always prioritizes transparency, integrity, and inclusivity above all else. Our ensure that our content creation and review process includes rigorous fact-checking, evidence-based, and continual updates to ensure accuracy and reliability.

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

Editorial Standards

At EasyTechJunkie, we are committed to creating content that you can trust. Our editorial process is designed to ensure that every piece of content we publish is accurate, reliable, and informative.

Our team of experienced writers and editors follows a strict set of guidelines to ensure the highest quality content. We conduct thorough research, fact-check all information, and rely on credible sources to back up our claims. Our content is reviewed by subject-matter experts to ensure accuracy and clarity.

We believe in transparency and maintain editorial independence from our advertisers. Our team does not receive direct compensation from advertisers, allowing us to create unbiased content that prioritizes your interests.

In software programming, object-oriented programming (OOP) is a framework that attempts to create objects out of real-world things. The theory and practice of polymorphism is strongly encouraged within OOP principles. In general, an object should be created to have base features and behaviors with the understanding that these will change when it becomes a specific type.

Polymorphism is the ability to have a variable, function, or an object with more than one meaning within the program. There are multiple architecture designs that demonstrate polymorphism. These designs outline how an object will be reused within an application for multiple purposes.

Many programming languages support the use of polymorphism. This process enables the reuse of business rules and software code throughout an application. Not all programming languages support full polymorphic behavior but most support the basic concept. All of the true OOP languages including Java®, .net, and C++® support more advanced approaches and techniques.

A bank account is a good example of base object that could support polymorphism. All bank accounts have account numbers, names, and a balance. What makes an account unique is the type of account. Some examples of types are savings accounts, checking accounts, or a money market accounts. Within polymorphism, a bank account would be the base object with the more specific accounts using the features of the base bank account. Each account could then have additional behaviors to support interest rates, or withdrawal penalties while reusing the information about a bank account.

Using the theories of polymorphism saves developers time by reducing wasted code. It makes code easier to write and easier for others to understand. Additionally, it makes the software extensible, because future types can be added later using the base ancestor object within the existing code. In general, applications developed in this manner are more flexible and easier to extend by requiring less code for future modifications

The theories of polymorphism also apply to functions. A function is a piece of software code that performs a specific task. Functions can also be written in a polymorphic manner. This approach makes the code more flexible because the functions can be reused for other business rules within the software.

A good example of polymorphism with a function would be a sort function. This type of function would sort a list of numbers. A polymorphic function could not only sort numbers but could also sort any type of objects. This makes the function more efficient because it works on multiple types of data.

EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
By Lostnfound — On May 14, 2014

@Grivusnagel -- I nearly spit my coffee out when I read your post. Too funny! I think that describes a lot of us who have to depend on computers and mainframes to do our work.

You actually (probably unintentionally) hit the nail on the head in your comment. For polymorphism to work in the technology environment, every polymorphic element has to do every one of its several jobs equally well. Some programs are better at it than others.

Our front end publishing program, according to the IT guy who actually knows something, is slow because it gets too hung up in archiving files, even though that's not what you're asking it to do. You can be moving a file, but it wants to archive everything, so it slows the system way down. It's a quirk of this particular system. Other systems don't have these issues.

By Grivusangel — On May 13, 2014

This explains a lot about our computer system at work. It does too many things, and none of them very well. Now I understand.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.