Generic Programming
Programming using parametric polymorphism.
Generic programming is a way to engineer software that operates on data whose type is to be specified later.
Oftentimes statically-typed languages use general data structures that can store any data (a queue of integers is no different from a queue of characters in terms of functionality) and include common operations (insertion, deletion, resizing, search, access) that do not rely on types. Hence, in order to preserve type safety and keep the codebase reusable (hence avoiding the circumstance to need to rewrite the whole data structure repeatedly just to enable a new type), generic programming creates a promise that data structure (often a class) work with imaginary type (often called T) that will be substituted with the type specified when said data structure is used [1]. Compilers will take care to generate a new type that will be type-safe and available on-demand.
Generic programming is often called generics. Generics, aside from classes, can also apply to individual functions and also substitute the return type. Generics are implemented in a number of programming languages, including: Java, C#, Ada, C++, Go, Rust, Swift, TypeScript, etc. In C++ generics are implemented as template metaprogramming whose parameters may be both types and individual values that must be both known during compile-time and are part of the type definition itself [2, 2-5]. Template variable is treated as a constant.
The basic idea of generic programming is to define a function such as equality by induction on the structure of types. Thus, generic equality takes three arguments, a type and two values of that type, and proceeds by case analysis on the type argument .
Sources:Dictionary of Computer and Internet Terms (Vol. 1) John C. Rigdon, 2016 – 1471 c. – 549
B. Venners, B. Eckel. (2004). Generics in C#, Java, and C++. A Conversation with Anders Hejlsberg, Part VII. Retrieved from: https://www.artima.com/articles/generics-in-c-java-and-c#part2
B. Stroustrup, G. D. Reis. (2003). Concepts -- Design choices for template argument checking. [pg. 2-5] Retrieved from: https://www.stroustrup.com/N1522-concept-criteria.pdf