Glossary Updates12 new terms added to the glossaries · October 2, 2026, 22:44 CEST
AI TechDocKnowledge

Glossary · Automation software engineering and architecture

Generic programming

Also known as: Generics, Templates (programming)

German: Generische Programmierung

In software engineering, generic programming is a programming style in which algorithms and data structures are written in terms of type parameters to be specified later, so the same code can work with different data types while keeping type safety, for example with C++ templates or generics in C# and Java.

  • Software engineering

In one sentence

Generic programming writes algorithms and data structures with type parameters, so the same code works safely with different types.

Example

A generic ring buffer class is used for both integer sensor samples and alarm message structures without duplicating the code.

How it applies

  • Engineering: Generic code avoids duplication and keeps type checking at compile time. Standard libraries use it heavily for containers and algorithms.
  • Automation context: IEC 61131-3 offers limited generic features, such as generic data types for standard functions, ANY-type inputs in some implementations and variable-length arrays in the third edition. Vendors differ in what they support, so generic PLC libraries may not be portable.
  • Documentation: Document the requirements on type parameters, for example which operations a type must support, and the tested types. Error messages from generic code can be hard to read, so developer documentation benefits from examples of typical misuse.

Generic programming vs. inheritance

Inheritance reuses code through type hierarchies decided at design time, often with runtime dispatch. Generic programming reuses code through type parameters, typically resolved at compile time. Both reduce duplication, with different trade-offs in flexibility, performance and complexity.

By knowledge.aitechdoc.world · Published September 26, 2026 · Last reviewed

Source: AI TechDoc Knowledge editorial definition, based on programming language practice

Definitions follow the cited standards and specifications. Where a source is a copyrighted publication, such as an ISO, IEC or EN standard, the definition is a close paraphrase, not a verbatim quotation, so as not to infringe copyright. We recommend reading the original publication. The sections “How it applies” are editorial commentary by AI TechDoc Knowledge and are not part of any standard.

Seen a mistake? Send us a note!