This article needs additional citations for verification. (May 2017) |
In computer programming, boilerplate code, or simply boilerplate, are sections of code that are repeated in multiple places with little to no variation. When using languages that are considered verbose, the programmer must write a lot of boilerplate code to accomplish only minor functionality.[1]
The need for boilerplate can be reduced through high-level mechanisms such as metaprogramming (which has the computer automatically write the needed boilerplate code or insert it at compile time), convention over configuration (which provides good default values, reducing the need to specify program details in every project) and model-driven engineering (which uses models and model-to-code generators, eliminating the need for manual boilerplate code).
It is also possible to move boilerplate code to an abstract class so that it can be inherited by any number of concrete classes. Another option would be to move it into a subroutine so that it can be called instead of being duplicated.