Boilerplate code
Code that has to be included in many places with little or no alteration / From Wikipedia, the free encyclopedia
Dear Wikiwand AI, let's keep it short by simply answering these key questions:
Can you list the top facts and stats about Boilerplate code?
Summarize this article for a 10 year old
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]
This article needs additional citations for verification. (May 2017) |
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.