polymorphism
In programming, polymorphism lets one command, method, or interface work with different kinds of objects or data.
A feature of a programming language or design that allows the same interface, operation, or function name to work with values or objects of different types, often with behavior chosen according to the actual type.
In biology, a polymorphism is a common difference in form or DNA found among members of the same species or population.
The existence, within a species or population, of two or more common genetic variants, physical forms, or phenotypes, especially genetic variants.
In chemistry, polymorphism means that the same substance can form different solid crystal structures.
The ability of a substance, especially a solid compound, to exist in more than one crystal structure or solid form.
In a very formal use, polymorphism means the quality of having many different forms.
The condition or quality of appearing in several different forms, especially in formal or abstract writing outside a specific technical field.
- Base: polymorphism
- Plural: polymorphisms
ad hoc polymorphism
1type-specific implementations under one name
Ad hoc polymorphism means the same name can do different things for different types.
- The + operator often uses ad hoc polymorphism, since it may add numbers or combine strings depending on the types.
- Type classes in Haskell are a well-known way to express ad hoc polymorphism.
- Function overloading is a common example of ad hoc polymorphism.
- The same operator can work in different ways.
- That is ad hoc polymorphism.
balanced polymorphism
1variation maintained by selection
Balanced polymorphism means natural selection keeps more than one form or gene variant in a population.
- Balanced polymorphism can preserve both alleles when heterozygotes have higher fitness.
- The sickle-cell trait in malaria regions is often cited as an example of balanced polymorphism.
- Frequency-dependent selection can produce balanced polymorphism in a population.
- Balanced polymorphism keeps two gene forms in a group.
- Selection helps both forms remain.
compile-time polymorphism
1behavior chosen before running
Compile-time polymorphism means the compiler chooses the right function or method before the program runs.
- With compile-time polymorphism, the compiler selects the overloaded function before the program runs.
- C++ templates are often used to achieve compile-time polymorphism.
- Compile-time polymorphism can improve performance because some decisions are made before execution.
- Compile-time polymorphism is decided before the program runs.
- Function overloading is a common example.
parametric polymorphism
1same code for any type
Parametric polymorphism lets one piece of code work with many types by using a type variable or type parameter.
- The same function can reverse a list of strings or a list of numbers because it uses parametric polymorphism.
- Generics in many languages are a common way to express parametric polymorphism.
- The identity function is a classic example of parametric polymorphism.
- A generic list uses parametric polymorphism.
- The code works for many types.
restriction fragment length polymorphism
1enzyme-cut DNA length variation
A restriction fragment length polymorphism is a DNA difference that makes enzyme-cut DNA pieces have different lengths.
- Before whole-genome sequencing became cheap, researchers often used restriction fragment length polymorphism to map genes.
- A restriction fragment length polymorphism can reveal that two samples produce different DNA fragment patterns after enzyme digestion.
- RFLP analysis depends on restriction fragment length polymorphisms in the DNA being tested.
- Scientists can use an RFLP to compare DNA samples.
- The DNA pieces have different lengths.
runtime polymorphism
1behavior chosen while running
Runtime polymorphism means the program chooses the right method while it is running.
- The framework uses runtime polymorphism to call the correct render method for each widget.
- In C++, virtual functions provide runtime polymorphism.
- Runtime polymorphism lets the program respond to the real type of an object, not just the declared type.
- Runtime polymorphism chooses the method during the program.
- A virtual method can use runtime polymorphism.
single nucleotide polymorphism
1one-base DNA variation
A single nucleotide polymorphism is a one-letter difference in DNA that is found in a population.
- The test looks for a single nucleotide polymorphism in the gene that affects how the body processes warfarin.
- Millions of single nucleotide polymorphisms have been cataloged in the human genome.
- A single nucleotide polymorphism can be harmless, helpful, or linked to disease risk.
- A single nucleotide polymorphism is a small DNA difference.
- Scientists often call it an SNP.
subtype polymorphism
1subtypes through a common interface
Subtype polymorphism lets a more specific type be used where a more general type is expected.
- The code relies on subtype polymorphism: any class that implements the Logger interface can be passed to the service.
- Subtype polymorphism lets the program treat a Square as a Shape while still using the Square's own drawing behavior.
- Many object-oriented designs use subtype polymorphism to reduce repeated conditional logic.
- A Dog object can be used where an Animal is expected.
- This is subtype polymorphism.