Skip to content
Search

Boilerplate code

lastmod 2025-03-14created 2017-02-115 edits

In computer programming, boilerplate code, or boilerplate, is code that must be included in many places with little or no modification. Such code is often used in languages where a lot of code has to be written to do minimal work. Ways to avoid boilerplate include advanced mechanisms such as metaprogramming (the computer automatically generates the needed boilerplate), 'convention over configuration' (defaults are provided, reducing the need to specify details for each project's program), or model-driven engineering (using models and model-to-code generators removes the need to write boilerplate by hand).

A related term, bookkeeping code, refers to code that is not part of the business logic but is interleaved with it to maintain data structures or handle secondary aspects of the program.

Example

The following is an example of boilerplate in the C/C++ programming languages: the #include guard.

#ifndef _MYINTERFACE_H
#define _MYINTERFACE_H
// ...
#endif

SaaS Boilerplate

See also

Favorite site

author Zer0 sitemap