Generic Programming

Programs where types are specified later. Usually, the "type to be specified later" is denoted by a placeholder.

In addition to helping reusability, this is also safer than Type Systems#Casting, which can be error-prone.

Compile time checks

  • Restrictions: This might seem to be a type safety disaster, but strongly typed languages allow these generic types to be constrained by the programmer.

  • Flexibility: Languages also allow wildcards or some sort of type variance when the type is unclear while using it. This also allows for some Type Systems#Variance when dealing with types.

    For example, method parameters can be variant in OOP, but if required you can make them contravariant using generic type wildcards.

Metaprogramming

Technique which helps write generic programs, by allowing program to read and manipulate information about their own or other program's metadata at runtime, like type and names.

A lot of languages like Java and ABAP offer these functionalities.

Introspection

When a program is able to read or examine the type or properties at runtime.

Reflection

Reflection goes a step further from introspection. Its when a program can manipulate the type or properties at runtime.

References

© 2025 All rights reservedBuilt with Flowershow Cloud

Built with LogoFlowershow Cloud